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:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

S=input()
N=len(S)
ans=True
i=0
while ans:
    if i==N:
        break
    if S[i]=='e':
        if S[i:i+6]=='eraser':
            i+=6
        elif S[i:i+5]=='erase':
            i+=5
        else:
            ans=False
    if S[i]=='d':
        if S[i:i+10]=='dreamerase':
            i+=5
        elif S[i:i+7]=='dreamer':
            i+=7
        elif S[i:i+5]=='dream':
            i+=5
        else:
            ans=False
    else:
        ans=False
judge(ans,['YES','NO'])

Submission status: Runtime Error

Solution code:

url = "https://atcoder.jp//contests/abc049/tasks/abc049_b"

def main():
    h, w = list(map(int, input().split()))
    ss = [input() for _ in range(h)]
    for s in ss:
        print(s)
        print(s)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)

s = 'HAKUTYUMU' + input()


def check(s):
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == 'HAKUTYUMU':
        return True

    if s == next_s:
        return False

    return check(next_s)


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

Submission status: Runtime Error

Solution code:
s = 'HAKUTYUMU' + input()


def check(s):
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == 'HAKUTYUMU':
        return True

    if s == next_s:
        return False

    return check(next_s)


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

Submission status: Runtime Error

Solution code:
#!/user/bin/env pypy3
import itertools
import sys


def fast_input():
    return sys.stdin.readline()[:-1]


def print_format(b: bool) -> str:
    return "YES" if b else "NO"


def solve(s: str) -> bool:
    tokens = ["dream", "erase", "eraser", "dreamer"]

    def dfs(pos: int) -> bool:
        if pos == len(s):
            return True
        for token in tokens:
            if (pos + len(token)) > len(s):
                break
            if s[pos:pos + len(token)] == token:
                if dfs(pos + len(token)):
                    return True

    return dfs(0)


def main():
    result = solve(fast_input())
    print(print_format(result))


main()

Submission status: Runtime Error

Solution code:
ans = []


def solve(s):
    if s == 'dream' or s == 'dreamer' or s == 'erase' or s == 'eraser':
        ans.append(1)
    else:
        if len(s) >=5 and s[:5] == 'dream':
            solve(s[5:])
        if len(s) >=7 and s[:7] == 'dreamer':
            solve(s[7:])
        if len(s) >=5 and s[:5] == 'erase':
            solve(s[5:])
        if len(s) >=6 and s[:6] == 'eraser':
            solve(s[6:])
        else:
            ans.append(0)
solve(input())
if 1 in ans:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
S = input()
def trans(s,i):
    if s == "":
        return "YES"
    if i == 0:
        t = s[:5]
        if t == "dream":
            return trans(s[5:],1)
        elif t == "erase":
            return trans(s[5:],2)
        else:
            return "NO"
    elif i == 1:
        if s[:5] == "dream":
            return trans(s[5:],1)
        elif s[:2] == "er":
            return trans(s[2:],3)
        else:
            return "NO"
    elif i == 2:
        if s[:5] == "dream":
            return trans(s[5:],1)
        elif s[:5] == "erase":
            return trans(s[5:],2)
        elif s[:1] == "r":
            return trans(s[1:],0)
        else:
            return "NO"
    elif i == 3:
        if s[:5] == "dream":
            return trans(s[5:],1)
        elif s[:3] == "ase":
            return trans(s[3:],2)
        elif s[:5] == "erase":
            return trans(s[5:],2)
        else:
            return "NO"
    
print(trans(S,0))

Submission status: Runtime Error

Solution code:
S = list(input())
N = len(S)

def f(x):
    print(x)
    exit()

if N < 5:
    f("NO")
elif S[0] == "d":
    w = 1
elif S[0] == "e":
    w = -1
else:
    f("NO")

i = 0
while True:
    if w > 0:
        if S[i]+S[i+1]+S[i+2]+S[i+3]+S[i+4] == "dream":
            i += 5
            if i == N:
                f("YES")
            elif S[i] == "d":
                pass
            elif S[i] == "e":
                if i+1 <= N-1:
                    if S[i+1] == "r":
                        if i+1 == N-1:
                            f("YES")
                        elif S[i+2] == "a":
                            w *= -1
                        elif S[i+2] == "e":
                            i += 2
                            w *= -1
                        elif S[i+2] == "d":
                            i += 2
                        else:
                            f("NO")
                    else:
                        f("NO")
                else:
                    f("NO")
            else:
                f("NO")
        else:
            f("NO")
    elif w < 0:
        if S[i]+S[i+1]+S[i+2]+S[i+3]+S[i+4] == "erase":
            i += 5
            if i == N:
            if S[i] == "r":
                i += 1
                if i == N:
            if S[i] == "d":
                w *= -1
            elif S[i] == "e":
                pass
            else:
                f("NO")
        else:
            f("NO")
    if i+4 > N-1:
        f("NO")

Submission status: Runtime Error

Solution code:
A = input()
A = A[::-1]
divide = [i[::-1] for i  in ["dream", "dreamer", "erase", "eraser"]]

flag = 1
while flag and A:
  flag = 0
  for word in divide:
    if A.startswith(word):
      A = A[len(word):]
      print(A)
      flag = 1

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

Submission status: Runtime Error

Solution code:
A = input()
A = A[::-1]
divide = [i[::-1] for i  in ["dream", "dreamer", "erase", "eraser"]]
print(A)
print(divide)
flag = 1
while flag and A:
  flag = 0
  for word in divide:
    if A.startswith(word):
      A = A[len(word):]
      print(A)
      flag = 1

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

Submission status: Runtime Error

Solution code:
A = input()
A = A[::-1]
divide = [i[::-1] for i  in ["dream", "dreamer", "erase", "eraser"]]

flag = 1
while flag and A:
  flag = 0
  for word in divide:
    if A.startswith(word): # 先頭が一致したら
      A = A[len(word):] # 該当文字分だけスライス
      print(A)
      flag = 1

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

Submission status: Runtime Error

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

def search(s):
  if len(s) == 0:
    return 1
  
  flg = 0
  for t in text:
    if len(s) < len(t):
      continue
    if s.find(t) == 0:
      flg |= search(s[len(t):])
      
  return flg

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

Submission status: Runtime Error

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

def search(s):
  if len(s) == 0:
    return 1
  
  flg = 0
  for t in text:
    if s.find(t) == 0:
      flg |= search(s[len(t):])
      
  return flg

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

Submission status: Runtime Error

Solution code:
s = list(input())

a = list("dream")
b = list("dreamer")
c = list("erase")
d = list("eraser")
flag = 0

while(flag == 0):
    print(s)
    if s[-7:] == b:
        del s[-7:]
    elif s[-6:] == d:
        del s[-6:]
    elif s[-5:] == a or s[-5:] == c:
        del s[-5:]
    elif s == []:
        print("YES")
        flag = 1
    else:
        print("NO")
        flag = 1

Submission status: Runtime Error

Solution code:
# dfs

C = ['dream', 'dreamer', 'erase', 'eraser']
S = input()
L = len(S)


def dfs(x):
    l = len(x)
    if l >= L:
        if S == x:
            return True
        else:
            return False

    match = S[l:l+7]
    for c in C:
        if match.find(c) == 0:
            if dfs(x+c):
                return True
    return False


print('YES' if dfs('') else 'NO')

Submission status: Runtime Error

Solution code:
words = [w[::-1] for w in ['dream','dreamer', 'erase', 'eraser']]
s = raw_input()[::-1]
while(i < len(s)):
	for w in words:
		if w == s[:len(w)]:
			i += len(w)
			break



print 'YES' if i == len(s) else 'NO'

Submission status: Runtime Error

Solution code:
import re

s = input()
s = re.sub("dreamer","",s)
s = re.sub("dream","",s)
s = re.sub("eraser","",s)
s = re.sub("erase","",s)

if int(s) == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = input()                    
def search(l):
    if l>=len(s):
        return 1
    a = b = c = d = 0
    if s[l:l+5]=="dream":
        a = search(l+5)
    if s[l:l+5]=="erase":
        b = search(l+5)
    if s[l:l+6]=="eraser":
        c = search(l+6) 
    if s[l:l+7]=="dreamer":
        d = search(l+7) 
    return max(a,b,c,d)

if search(0):
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
def search(l):
    if l>=len(s):
        return 1
    if s[l:l+5]=="dream":
        search(l+5)
    if s[l:l+5]=="erase":
        search(l+5)
    if s[l:l+6]=="eraser":
        search(l+6) 
    if s[l:l+7]=="dreamer":
        search(l+7) 
    else:
        return 0  

if search(0):
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
S=input()[::-1]
def a(s):
    if s:
        if s[:5]=='maerd':
            return a(s[5:])
        elif s[:5]=='esare':
            return a(s[5:])
        elif s[:6]=='resare':
            return a(s[6:])
        elif s[:7]=='remaerd':
            return a(s[7:])
        else:
            return False
    else:
        return True
print(a(S))

Submission status: Runtime Error

Solution code:
s = input()

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

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

s.sort()

if s[0] == s[-1] and s[-1] == "x":
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
S = input()
strs = list(reversed(S))
rev_S = ''.join(strs)
while True:
  if rev_S[:6] == 'resare'
    rev_S = rev_S[6:]
    continue
  elif rev_S[:7] == 'remaerd':
    rev_S = rev_S[7:]
    continue
  elif rev_S[:5] == 'esare' or rev_S[:5] == 'maerd':
    rev_S = rev_S[5:]
    continue
  else:
    break

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

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


def main():
    sys.setrecursionlimit(10000)
    S = input()

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


def judgeStr(target: str) -> bool:
    for item in PARTS:
        if target.startswith(item):
            tempStr = target.replace(item, "", 1)
            if tempStr == "" or judgeStr(tempStr):
                return True

    return False


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

import sys

PARTS = ["eraser", "erase", "dreamer", "dream"]
PARTS2 = []


def main():
    global PARTS2
    sys.setrecursionlimit(5000)
    S = input()

    for i in range(0, 4):
        for j in range(0, 4):
            PARTS2.append(PARTS[i] + PARTS[j])

    PARTS2 = PARTS2 + PARTS

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


def judgeStr(target: str) -> bool:
    global PARTS2
    for item in PARTS2:
        if target.startswith(item):
            tempStr = target.replace(item, "", 1)
            if tempStr == "" or judgeStr(tempStr):
                return True

    return False


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:


import sys

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


def main():
    sys.setrecursionlimit(5000)
    S = input()

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


def judgeStr(target: str) -> bool:
    for item in PARTS:
        if target.startswith(item):
            tempStr = target.replace(item, "", 1)
            if tempStr == "" or judgeStr(tempStr):
                return True

    return False


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

import sys

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


def main():
    sys.setrecursionlimit(5000)
    S = input()

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


def judgeStr(target: str) -> bool:
    for item in PARTS:
        if target.startswith(item):
            tempStr = target.replace(item, "", 1)
            if tempStr == "" or judgeStr(tempStr):
                return True

    return False


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

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


def main():
    S = input()

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


def judgeStr(target: str) -> bool:
    for item in PARTS:
        if target.startswith(item):
            tempStr = target.replace(item, "", 1)
            if tempStr == "" or judgeStr(tempStr):
                return True

    return False


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

def bfs(t):
  if t == s:
    return 1
  if len(t) >= len(s):
    return 0
  if t != s[:len(t)]:
    return 0
  ans = 0
  for tx in text:
    ans += bfs(t+tx)
  return ans

if bfs('') > 0:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

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

while len(ls_S) != 0:
  print(ls_S)
  if "".join(ls_S[len(ls_S)-5:]) == "dream":
    ls_S = ls_S[:len(ls_S)-5]
  elif "".join(ls_S[len(ls_S)-5:]) == "erase":
    ls_S = ls_S[:len(ls_S)-5]
  elif "".join(ls_S[len(ls_S)-7:]) == "dreamer":
    ls_S = ls_S[:len(ls_S)-7] 
  elif "".join(ls_S[len(ls_S)-6:]) == "eraser":
    ls_S = ls_S[:len(ls_S)-6]
  else:
    ans = "No"
    break
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)
def saiki(T):
  if len(T)<=len(S):
    if T==S:
      print("YES")
      exit()
    return saiki(T+"dream"),saiki(T+"erase"),saiki(T+"dreamer"),saiki(T+"eraser")
S=input()
saiki("")
print("NO")

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50

def dfs(seq):
    if seq in ['dreamer', 'dream', 'erase', 'eraser']:
        return True

    if seq[:7] == 'dreamer':
        if dfs[5:] or dfs[7:]:
            return True
        else:
            return False

    elif seq[:5] == 'dream':
        return dfs(seq[5:])

    elif seq[:6] == 'eraser':
        return dfs(seq[6:])

    elif seq[:5] == 'erase':
        return dfs(seq[5:])
    else:
        return False


def run():
    S = input()
    if dfs(S):
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    run()

Submission status: Runtime Error

Solution code:
s=input()
t=''
while s!='':
  if s[:5]=='dream':
    if s[5:10]=='erase':
      s=s[5:]
      continue
    elif s[5:7]=='er':
      s=s[7:]
      continue
    else:
      s=s[5:]
      continue
  elif s[:5]=='erase':
    if s[5]=='r':
      s=s[6:]
      continue
    else:
      s=s[5:]
      continue
      
  else:
    break
    
if s=='':
  print('YES')
  
else:
  print('NO')

Submission status: Runtime Error

Solution code:
s=input()
t=''
while s!='':
  if s[:5]=='dream':
    if s[5:10]=='erase':
      s=s[5:]
      continue
    elif s[5:7]='er':
      s=s[7:]
      continue
  elif s[:5]=='erase':
    if s[5]=='r':
      s=s[6:]
    else:
      s=s[5:]
      
  else:
    break
    
if s=='':
  print('YES')
  
else:
  print('NO')

Submission status: Runtime Error

Solution code:
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    elif a == 3:
        for j in range(6):
            if y[a][5-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    return c


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
c = 1
while len(temp) != 0 and c == 1:
    a = h(temp)
    c = H(temp,y,a)
    print(temp,a)
if c == 1:
    print("YES")
else :
    print("NO")

Submission status: Runtime Error

Solution code:
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[0]:
                break
        c = 1
    return c,temp


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
a = h(temp)
c = 1

while len(temp) != 0 and c == 1:
    c = H(temp,y,a)
    a = h(temp)
if c[0] == 1:
    print("YES")
else :
    print("NO")

Submission status: Runtime Error

Solution code:
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[j]:
                break
        c = 1
    return c,temp


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
a = h(temp)
c = 1

while len(temp) != 0 and c == 1:
    c = H(temp,y,a)
    a = h(temp)
if c[0] == 1:
    print("YES")
else :
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if len(s) < 5:
        frag = 1
        break
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                if s[i + 7] == "a" and s[i + 8] == "s" and s[i + 9] == "e":
                    i += 5
                    continue
                else:
                    i += 7
                    continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 7
                continue
        i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 6
                continue
        i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if len(s) < 5:
        frag = 1
        break
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 9 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a" and s[i + 8] == "s" and s[i + 9] == "e":
                i += 5
                continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 7
                continue
        i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 6
                continue
        i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if len(s) == 0:
        frag = 1
        break
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 9 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a" and s[i + 8] == "s" and s[i + 9] == "e":
                i += 5
                continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 7
                continue
        i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 6
                continue
        i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 9 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a" and s[i + 8] == "s" and s[i + 9] == "e":
                i += 5
                continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 7
                continue
        i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 6
                continue
        i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
if len(s) == 0:
    frag = 1
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 7 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a":
                i += 5
                continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 7
                continue
        i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 6
                continue
        i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 7 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a":
                i += 5
                continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 7
                continue
        i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 6
                continue
        i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 7 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a":
                i += 5
                continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 7
                continue
        i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 5
            else:
                i += 4
        else:
            i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 7 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a":
                i += 4
                continue
        if i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 6
            else:
                i += 4
        else:
            i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 5
            else:
                i += 4
        else:
            i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s=input()
while s:
    if s[-5:]=='erase':
        for i in range(5):
            s.pop()
    elif s[-5:]=='dream':
        for i in range(5):
            s.pop()
    elif s[-6:]=='eraser':
        for i in range(6):
            s.pop()
    elif s[-7:]=='dreamer':
        for i in range(7):
            s.pop()
    else:
        print('NO')
print('YES')

Submission status: Runtime Error

Solution code:
def test(t):
    if len(t)==len(s):
        print('YES')
        exit()
    if s[len(t):len(t)+5]=='dream':
        test(t+'dream')
    if s[len(t):len(t)+7]=='dreamer':
        test(t+'dreamer')
    if s[len(t):len(t)+5]=='erase':
        test(t+'erase')
    if s[len(t):len(t)+6]=='eraser':
        test(t+'eraser')
s=input()
test('')
print('NO')

Submission status: Runtime Error

Solution code:
import re
s = imput()

if re.match("(dreamer|dream|eraser|erase)+dreamer",s):
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
s = input()
s_reverse = ''.join(list(reversed(s)))
t = ''

while True:
    if s_reverse == t:
        print('YES')
        break
    n = len(t)
    if s_reverse[n] == 'm':
        t += ''.join(list(reversed('dream')))
    elif s_reverse[n] == 'e':
        t += ''.join(list(reversed('erase')))
    elif s_reverse[n:n+3] == 'rem':
        t += ''.join(list(reversed('dreamer')))
    elif s_reverse[n:n+3] == 'res':
        t += ''.join(list(reversed('eraser')))
    else:
        print('NO')
        break