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:
def main():
    Ss = input()
    S = list(Ss)
    now = 0
    T = ''
    while True:
        tmp5 = S[now:now+5]
        if tmp5[0] == 'd':
            tmp = S[now:now+7]
        elif tmp5[0] == 'e':
            tmp = S[now:now+6]
        if tmp5 == ['d','r','e','a','m'] and tmp == ['d','r','e','a','m','e','r']:
            if now+7 < len(S) and S[now+7] == 'e':
                T += 'dreamer'
                now += 7
            else:
                T += 'dream'
                now += 5
        elif tmp5 == ['e','r','a','s','e'] and tmp == ['e','r','a','s','e','r']:
            if now+6 == len(S)  or (now+6 < len(S) and S[now+6] == 'e'):
                T += 'eraser'
                now += 6
            else:
                T += 'erase'
                now += 5
        elif tmp5 == ['d','r','e','a','m']:
            T += 'dream'
            now += 5
        elif tmp5 == ['e','r','a','s','e']:
            T += 'erase'
            now += 5
        else:
            print('NO')
            return
        if now >= len(S):
            break
    if Ss == T:
        print('YES')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    Ss = input()
    S = list(Ss)
    now = 0
    T = ''
    while True:
        tmp5 = S[now:now+5]
        if tmp5[0] == 'd':
            tmp = S[now:now+7]
        elif tmp5[0] == 'e':
            tmp = S[now:now+6]
        if tmp5 == ['d','r','e','a','m'] and tmp == ['d','r','e','a','m','e','r']:
            if now+7 < len(S) and S[now+7] == 'e':
                T += 'dreamer'
                now += 7
            else:
                T += 'dream'
                now += 5
        elif tmp5 == ['e','r','a','s','e'] and tmp == ['e','r','a','s','e','r']:
            if now+6 == len(S)  or (now+6 < len(S) and S[now+6] == 'e'):
                T += 'eraser'
                now += 6
            else:
                T += 'erase'
                now += 5
        elif tmp5 == ['d','r','e','a','m']:
            T += 'dream'
            now += 5
        elif tmp5 == ['e','r','a','s','e']:
            T += 'erase'
            now += 5
        else:
            print('No')
            return
        if now >= len(S):
            break
    if Ss == T:
        print('Yes')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()

while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-6:] == 'dreamer':
        s = s[:-6]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break

print('NO' if len(s) > 0 else 'YES')

Submission status: Wrong Answer

Solution code:
from collections import deque

d = deque()
s = list(input())
s = deque(s)
while s:
    if len(s) >= 5:
        st = [s.popleft() for _ in range(5)]
        if st[0] == "d" and st[1] == "r" and st[2] == "e" and st[3] == "a" and st[4] == "m":
            if len(s) >= 3:
                l = [s.popleft() for _ in range(3)]
                if (l[0] == "e" and l[1] == "r" and l[2] == "a") or  (l[0] == "d" and l[1] == "r" and l[2] == "e"):
                    s.appendleft(l[2])
                    s.appendleft(l[1])
                    s.appendleft(l[0])
                elif l[0] == "e" and l[1] == "r" and (l[2] == "d" or l[2] == "e"):
                    continue
                else:
                    print("NO")
                    exit()
            else:
                if len(s) == 0:
                    break
                else:
                    print("NO")
                    exit()
        elif st[0] == "e" and st[1] == "r" and st[2] == "a" and st[3] == "s" and st[4] == "e":
            l = s.popleft()
            if l == "r":
                continue
            elif l == "d" or l == "e":
                s.appendleft(l)
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
R = ''.join(list(reversed(list(S))))
#print(R)

while R:
    if R[:5]=='maerd':
        R = R[5:]
    elif R[:7]=='remaerd':
        R = R[7:]
    elif R[:5]=='esare':
        R = R[5:]
    elif R[:6]=='resare':
        R = R[6:]
    else:
        print('No')
        break
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s = STR()
i = 0
l = len(s)
while i < l:
    debug(i, s[i])
    if s[i] == 'd': #dream or dreamer
        if i + 5 > l or s[i:i + 5] != 'dream':
            print('NO')
            exit()
        if i + 7 <= l:
            if s[i:i + 5] != 'dreamer': #dream
                i += 5
            else:
                if i + 7 > l: #dreamer
                    i += 7
                elif i + 7 < l and s[i + 7] == 'a': #erase or eraser
                    i += 5
                else: #dreamer
                    i += 7
        else:
            i += 5
    elif s[i] == 'e':
        if i + 5 > l or s[i:i + 5] != 'erase':
            print('NO')
            exit()
        if i + 6 <= l:
            if s[i:i + 6] != 'eraser':
                i += 5
            else:
                if i + 6 > l:
                    i += 6
                elif i + 6 < l and s[i + 6] == 'a':
                    i += 5
                else:
                    i += 6
        else:
            i += 5
    else:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
rev_s = ''.join(list(reversed(input())))
rev_w = ['maerd', 'remaerd', 'esare', 'resare']

while rev_s != '':
    for item1 in rev_w:
        if rev_s.find(item1) == 0:
            rev_s = rev_s[len(item1):]
            break
    if item1 == rev_w[-1]:
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

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

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

can = True
i = 0
while i < len(S):
    can2 = False
    for t in T:
        if S[i:i + len(t)] == t:
            can2 = True
            i += len(t)
    if can2 == False:
        can = False
        break
    i += 1

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

Submission status: Wrong Answer

Solution code:
x=list(str(input()))

chk=0

while chk==0 and len(x)>=5:

	if x[-5]=='d' and x[-4]=='r' and x[-3]=='e' and x[-2]=='a' and x[-1]=='m' :
		x=x[:-5]

	elif x[-5]=='e' and x[-4]=='r' and x[-3]=='a' and x[-2]=='s' and x[-1]=='e' :
		x=x[:-5]

	elif x[-7]=='d' and x[-6]=='r' and x[-5]=='e' and x[-4]=='a' and x[-3]=='m' and x[-2]=='e' and x[-1]=='r':
		x=x[:-7]

	elif x[-6]=='e' and x[-5]=='r' and x[-4]=='a' and x[-3]=='s' and x[-2]=='e' and x[-1]=='r':
		x=x[:-6]

	else:
		chk=1

if chk==0 and len(x)==0:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
import re

S = input()

s = re.sub(r"(dreamer)|(eraser)", "", S)
s = re.sub(r"(dream)|(erase)", "", s)

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

Submission status: Wrong Answer

Solution code:
import re

S = input()

s = re.sub(r"(dream)|(erase)|(dreamer)|(eraser)", "", S)
if len(s) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = s.count("dream")
b = s.count("dreamer")
c = s.count("erase")
d = s.count("eraser")
e = s.count("dreamera")
f = s.count("erasera")
b = b-e
d = d-f
a = a-b
c = c-e
if (a+c)*5 + b*7 + d*6 == len(s):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = s.count("dream")
b = s.count("dreamer")
c = s.count("erase")
d = s.count("eraser")
e = s.count("dreamera")
f = s.count("erasera")
b = b-e
d = d-f
a = a-b
c = c-e
if (a+c)*5 + b*7 + d*6 == len(s):
  print("YES")
else:
  print("N0")

Submission status: Wrong Answer

Solution code:
s = input()
a = s.count("dream")
b = s.count("dreamer")
c = s.count("erase")
d = s.count("eraser")
e = s.count("dreamera")
f = s.count("erasera")
b = b-e
d = d-f
a = a-b
c = c-e
if (a+c)*5 + b*7 + d*6 == len(s):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import re

s = input()
print('Yes' if re.match('^(dream|dreamer|erase|eraser)+$', s) else 'No')

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
i=1
for j in range(n):
    if s[-i:-i-5:-1]=="maerd":
        i+=5
 
    if s[-i:-i-5:-1]=="esare":
        i+=5

    if s[-i:-i-6:-1]=="resare":
        i+=6

    if s[-i:-i-7:-1]=="remeard":
        i+=7

    if i==n+1:
        print("YES")
        break

if i != n+1:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
i=1
for j in range(n):
    if s[-i:-i-5:-1]=="maerd":
        i+=5
 
    if s[-i:-i-5:-1]=="esare":
        i+=5

    if s[-i:-i-6:-1]=="resare":
        i+=6

    if s[-i:-i-7:-1]=="remeard":
        i+=7
        
    if i==n+1:
        print("YES")
        break

if i !=n:
    print("NO")

Submission status: Wrong Answer

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

T = S.replace('remaerd','')
U = T.replace('resare','')
V = U.replace('maerd','')
W = V.replace('esare','')

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

Submission status: Wrong Answer

Solution code:
S=input()
reversed(S)

T = S.replace('remaerd','')
U = T.replace('resare','')
V = U.replace('maerd','')
W = V.replace('esare','')

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

Submission status: Wrong Answer

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

T = S.replace('dreamer','')
U = T.replace('eraser','')
V = U.replace('erase','')
W = V.replace('dream','')

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

Submission status: Wrong Answer

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

T = S.replace('eraser','')
U = T.replace('dreamer','')
V = U.replace('erase','')
W = V.replace('dream','')

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

Submission status: Wrong Answer

Solution code:
g=[]

def  jdream(l,i):
    if l[i:i+5]=="dream":
        i=i+5
        if i==len(l):
            g.append("Y")
            return
     
        else:
            return(jer(l,i),jdream(l,i))    
    else:
        g.append("N")
        return

def jerase(l,i):
    if l[i:i+5]=="erase":
        i=i+5
        if i==len(l):
            g.append("Y")
            return
        else:
            return(jr(l,i),jerase(l,i),jdream(l,i))
    else:
        g.append("N")
        return

def jer(l,i):
    if l[i:i+2]=="er":
        i=i+2
        if i==len(l):
            g.append("Y")
            return
        else:
            return(jase(l,i),jerase(l,i),jdream(l,i))
    else:
        g.append("N")
        return

def jase(l,i):
    if l[i:i+3]=="ase":
        i=i+3
        if i==len(l):
               g.append("Y")
               return
        else:
            return(jase(l,i),jerase(l,i),jr(l,i))
    else:
        g.append("N")
        return

def jr(l,i):
    if l[i:i+1]=="r":
        i=i+1
        if i==len(l):
                g.append("Y")
                return
        else:
            return(jdream(l,i),jerase(l,i))
    else:
        g.append("N")
        return

s=input()
n=0
m=len(s)


jdream(s,n)
jerase(s,n)

if "Y" in g :
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
g=[]

def  jdream(l,i):
    if l[i:i+5]=="dream":
        i=i+5
        if i==len(l):
            g.append("Y")
            return
     
        else:
            return(jer(l,i),jdream(l,i))    
    else:
        g.append("N")
        return

def jerase(l,i):
    if l[i:i+5]=="erase":
        i=i+5
        if i==len(l):
            g.append("Y")
            return
        else:
            return(jr(l,i),jerase(l,i),jdream(l,i))
    else:
        g.append("N")
        return

def jer(l,i):
    if l[i:i+2]=="er":
        i=i+2
        if i==len(l):
            g.append("Y")
            return
        else:
            return(jase(l,i),jerase(l,i),jdream(l,i))
    else:
        g.append("N")
        return

def jase(l,i):
    if l[i:i+3]=="ase":
        i=i+3
        if i==len(l):
               g.append("Y")
               return
        else:
            return(jase(l,i),jerase(l,i),jr(l,i))
    else:
        g.append("N")
        return

def jr(l,i):
    if l[i:i+1]=="r":
        i=i+1
        if i==len(l):
                g.append("Y")
                return
        else:
            return(jdream(l,i),jerase(l,i))
    else:
        g.append("N")
        return

s=input()
n=0
m=len(s)


jdream(s,n)
jerase(s,n)

print(g)
if "Y" in g :
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import random

S = input()
T =[]

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

for i in range(4):
    ADD = random.choice(mylist)
    T.append(ADD)
    print(T)
    if T == S:
        print("YES")
        exit(0)
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
d=raw_input().strip()
l=["dreamer", "eraser", "dream", "erase"]
loop=True
while loop:
  match=False
  for i in l:
    if d.startswith(i):
      match=True
      d = d[len(i):]
      if not d:
        loop=False
        break
  if not match:
    break

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

Submission status: Wrong Answer

Solution code:
s_init = input()
s_list = list(reversed(s_init))
s = ''.join(s_list)
t = ""
words = ["maerd", "remaerd", 'esare', 'resare']
s_list = list(s)
t_list = list(t)
while s != t:
    if len(s_list) < len(t_list):
        break
    elif t == 'gameover':
        break
    for word in words:
        if s.startswith(t + word):
            t = t + word
            break
        else:
            t = 'gameover'
if s == t:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
strs = ["erase", "eraser", "dreamer","dream"]
rtss = [s[::-1] for s in strs]
S = S[::-1]

ind = 0
while True:
    print(ind,S[ind])
    if S[ind:ind+5] in rtss:
        ind += 5
    elif S[ind:ind+6] in rtss:
        ind += 6
    elif S[ind:ind+7] in rtss:
        ind +=7
    else:
        print("NO")
        exit()
    if ind == len(S):
        print("YES")
        exit()

Submission status: Wrong Answer

Solution code:
S = input()
strs = ["erase", "eraser", "dreamer","dream"]
rtss = [s[::-1] for s in strs]
S_r = S[::-1]
for rts in rtss:
    S_r = S_r.replace(rts, "")
if len(S_r) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
strs = ["erase", "eraser", "dreamer","dream"]
rtss = [s[::-1] for s in strs]
S_r = S[::-1]
for rts in rtss:
    S_r = S_r.replace(rts, "")
if len(S_r) == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
strs = ["dream","dreamer","erase","eraser"]
ind = 0
while True:
    # print(ind,S[ind])
    if S[ind] == "e":
        if S[ind:ind+5] == "erase":
            if ind+5 == len(S): 
                print("YES")
                exit()
            if S[ind+5] == "r": 
                if ind + 6 ==len(S):
                    print("YES")
                    exit()
                ind+=6 #eraserで確定
            elif S[ind+5] == "d" or S[ind+5]=="e": 
                ind+=5 #dreamかeraser
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    elif S[ind] == "d":
        if S[ind:ind+5] == "dream":
            if ind + 5 == len(S):
                print("YES")
                exit()
            if S[ind+5] == "d" :ind += 5 #"dreamで確定"
            if S[ind+5] == "e":
                if S[ind+6] == "r":
                    if ind + 7 == len(S):
                        print("YES")
                        exit()
                    if S[ind+7] == "e" or S[ind+7] =="d": ind += 6 #dreamerで確定
                    elif S[ind+7] == "a": ind += 5 #"dream->eraseで確定"
                else:
                    print("NO")
                    exit()
        else:
            print("NO")
            exit()
    else:
        print("NO")
        exit()
    # print(ind)

Submission status: Wrong Answer

Solution code:
S = input()
strs = ["dream","dreamer","erase","eraser"]
ind = 0
while True:
    # print(ind,S[ind])
    if S[ind] == "e":
        if S[ind:ind+5] == "erase":
            if ind+5 == len(S): 
                print("YES")
                exit()
            if S[ind+5] == "r": 
                if ind + 6 ==len(S):
                    print("YES")
                    exit()
                ind+=6 #eraserで確定
            elif S[ind+5] == "d" or S[ind+5]=="e": 
                ind+=5 #dreamかeraser
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    elif S[ind] == "d":
        if S[ind:ind+5] == "dream":
            if ind + 5 == len(S):
                print("YES")
                exit()
            if S[ind+5] == "d" :ind += 5 #"dreamで確定"
            if S[ind+5] == "e":
                if S[ind+6] == "r":
                    if ind + 7 == len(S):
                        print("YES")
                        exit()
                    if S[ind+7] == "e" or S[ind+7] =="d": ind += 6 #dreamerで確定
                    elif S[ind+7] == "a": ind += 5 #"dream->eraseで確定"
                else:
                    print("NO")
                    exit()
        else:
            print("NO")
            exit()
    else:
        print("NO")
        exit()
    print(ind)

Submission status: Wrong Answer

Solution code:
S = input()
Sr = S[::-1]
token = ['dream', 'dreamer', 'erase', 'eraser']
tokenr = list(map(lambda x:x[::-1], token))
t = ''
while(len(Sr)>0):
    notFound = True
    for w in tokenr:
        if w==Sr[:len(w)]:
            Sr = Sr[len(w):]
            t+=w
            notFound = False
    if notFound:
        break
if Sr == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')

str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"


count = 0

while(count < len(c)):
  if(c[count:count+len(str1)] == str1):
    count += len(str1)
    continue
  elif(c[count:count+len(str2)] == str2):
    count += len(str2)
    continue
  elif(c[count:count+len(str3)] == str3):
    count += len(str3)
    continue
  elif(c[count:count+len(str4)] == str4):
    count += len(str4)
    continue
  else:
    print("NO")
    exit()

print("YES")

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')

str1 = "eraser"
str2 = "erase"
str3 = "dreamer"
str4 = "dream"


count = 0

while(count < len(c)):
  if(c[count:count+len(str1)] == str1):
    count += len(str1)
  elif(c[count:count+len(str2)] == str2):
    count += len(str2)
  elif(c[count:count+len(str3)] == str3):
    count += len(str3)
  elif(c[count:count+len(str4)] == str4):
    count += len(str4)
  else:
    print("NO")
    exit()

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:
c = input().rstrip('\n')

str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"


count = 0

while(count < len(c)-1):
  if(c[count:count+len(str1)] == str1):
    count += len(str1)
  elif(c[count:count+len(str2)] == str2):
    count += len(str2)
  elif(c[count:count+len(str3)] == str3):
    count += len(str3)
  elif(c[count:count+len(str4)] == str4):
    count += len(str4)
  else:
    print("NO")
    exit()

print("YES")

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')

str1 = 'dreamer'
str2 = 'dream'
str3 = 'eraser'
str4 = 'erase'


count = 0

while(count < len(c)):
  if(c[count:count+len(str1)] == str1):
    count += len(str1)
  elif(c[count:count+len(str2)] == str2):
    count += len(str2)
  elif(c[count:count+len(str3)] == str3):
    count += len(str3)
  elif(c[count:count+len(str4)] == str4):
    count += len(str4)
  else:
    print("NO")
    exit()

print("YES")

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')

str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"


count = 0

while(count < len(c)):
  if(c[count:count+len(str1)] == str1):
    count += len(str1)
  elif(c[count:count+len(str2)] == str2):
    count += len(str2)
  elif(c[count:count+len(str3)] == str3):
    count += len(str3)
  elif(c[count:count+len(str4)] == str4):
    count += len(str4)
  else:
    print("NO")
    exit()

print("YES")

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')
if (len(c) == 0):
  c = "nodata"

str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"


count = 0

while(count < len(c)):
  if(c[count:count+len(str1)] == str1):
    print(1)
    count += len(str1)
  elif(c[count:count+len(str2)] == str2):
    print(2)
    count += len(str2)
  elif(c[count:count+len(str3)] == str3):
    print(3)
    count += len(str3)
  elif(c[count:count+len(str4)] == str4):
    print(4)
    count += len(str4)
  else:
    print("NO")
    exit()

print("YES")

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')


str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"


count = 0

while(count < len(c)):
  if(c[count:count+len(str1)] == str1):
    count += len(str1)
  elif(c[count:count+len(str2)] == str2):
    count += len(str2)
  elif(c[count:count+len(str3)] == str3):
    count += len(str3)
  elif(c[count:count+len(str4)] == str4):
    count += len(str4)
  else:
    print("NO")
    exit()

print("YES")

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')
if (len(c) == 0):
  c = "f"
str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"

tmpstr = ""

endflag = False

while(c != ""):
  tmpstr = c
  c = c.replace(str1, "")
  c = c.replace(str2, "")
  c = c.replace(str3, "")
  c = c.replace(str4, "")
  
  if (c == tmpstr):
    endflag = True
    break

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

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')

str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"

tmpstr = ""

endflag = False

while(c != ""):
  tmpstr = c
  c = c.replace(str1, "")
  c = c.replace(str2, "")
  c = c.replace(str3, "")
  c = c.replace(str4, "")
  
  if (c == tmpstr):
    endflag = True
    break

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

Submission status: Wrong Answer

Solution code:
c = input().rstrip('\n')

str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"

tmpstr = ""

endflag = False

while(c != ""):
  tmpstr = c
  c = c.replace(str1, "")
  c = c.replace(str2, "")
  c = c.replace(str3, "")
  c = c.replace(str4, "")
  
  print("tmpstr:" + tmpstr)
  print("c:" + c)
  
  if (c == tmpstr):
    endflag = True
    break

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

Submission status: Wrong Answer

Solution code:
c = input()

str1 = "dream"
str2 = "dreamer"
str3 = "erase"
str4 = "eraser"

tmpstr = ""

endflag = False

while(True):
  tmpstr = c
  c.replace(c, str1)
  c.replace(c, str2)
  c.replace(c, str3)
  c.replace(c, str4)
  if (c == tmpstr):
    endflag = True
    break

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

Submission status: Wrong Answer

Solution code:
S = input()
S = ''.join(list(reversed([c for c in S])))

while S:
    if S[:7] == 'remaerd':
        S = S[7:]
    elif S[:6] == 'resare':
        S = S[6:]
    elif S[:5] == 'maerd':
        S = S[5:]
    elif S[:5] == 'esare':
        S = S[5:]
    else:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
s = s.replace('resare','/')
s = s.replace('esare', '/')
s = s.replace('resare','/')
s = s.replace('maerd','/')

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

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
s = s.replace('maerd','/')
s = s.replace('esare', '/')
s = s.replace('remaerd','/')
s = s.replace('resare','/')

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

Submission status: Wrong Answer

Solution code:
def we_can(s):
    if len(s) == 0:
        return True
    else:
        if s[-5:] == 'dream' or s[-5:] == 'erase':
            if we_can(s[:-5]):
                return True
        elif s[-6:] == 'dreamer' or s[-6:] == 'eraser':
            if we_can(s[:-6]):
                return True
    return False


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

Submission status: Wrong Answer

Solution code:
def solution():
    s = input()
    T = ['dreamer', 'dream', 'eraser', 'erase']
    while True:
        match = False
        candidates = []
        for ss in T:
            if s.startswith(ss):
                if not s[len(ss):]:
                    print('YES')
                    return
                candidates.append(ss)
                match = True
                break
        if not match:
            print('NO')
            return
        match = False
        for c_ss in candidates:
            for ss in T: 
                if s[len(c_ss):].startswith(ss):
                    s = s[len(c_ss):]
                    match = True
                    break
        if not match:
            s = s[len(candidates[0]):]

solution()

Submission status: Wrong Answer

Solution code:
def solution():
    s = input()
    T = ['erase', 'eraser', 'dream', 'dreamer']
    while True:
        match = False
        candidates = []
        for ss in T:
            if s.startswith(ss):
                if not s[len(ss):]:
                    print('YES')
                    return
                candidates.append(ss)
                match = True
                break
        if not match:
            print('NO')
            return
        match = False
        for c_ss in candidates:
            for ss in T: 
                if s[len(c_ss):].startswith(ss):
                    s = s[len(c_ss):]
                    match = True
                    break
        if not match:
            s = s[len(candidates[0]):]

solution()

Submission status: Wrong Answer

Solution code:
def solution():
    s = input()
    T = ['eraser', 'erase', 'dream', 'dreamer']
    while True:
        match = False
        candidates = []
        for ss in T:
            if s.startswith(ss):
                if not s[len(ss):]:
                    print('YES')
                    return
                candidates.append(ss)
                match = True
                break
        if not match:
            print('NO')
            return
        match = False
        for c_ss in candidates:
            for ss in T: 
                if s[len(c_ss):].startswith(ss):
                    s = s[len(c_ss):]
                    match = True
                    break
        if not match:
            s = s[len(candidates[0]):]

solution()

Submission status: Wrong Answer

Solution code:
def solution():
    s = input()
    T = ['dreamer', 'dream', 'eraser', 'erase']
    while True:
        match = False
        for ss in T:
            if s.startswith(ss):
                s = s.lstrip(ss)
                if not s:
                    print('YES')
                    return
                match = True
                break
        if not match:
            print('NO')
            return

solution()

Submission status: Wrong Answer

Solution code:
def solution():
    s = input()
    T = ['dream', 'dreamer', 'erase', 'eraser']
    while True:
        match = False
        for ss in T:
            if s.startswith(ss):
                s = s.lstrip(ss)
                if not s:
                    print('YES')
                    return
                match = True
                break
        if not match:
            print('NO')
            return

solution()

Submission status: Wrong Answer

Solution code:
g=[]

def  jdream(l,i):
    if l[i:i+5]=="dream":
        i=i+5
        if i==len(l):
          g.append("Y")
          return
     
        else:
            return(jer(l,i),jdream(l,i))    
    else:
        g.append("N")
        return

def jerase(l,i):
    if l[i:i+5]=="erase":
        i=i+5
        if i==len(l):
          g.append("Y")
          return
        else:
          return(jr(l,i),jerase(l,i),jdream(l,i))
    else:
        g.append("N")
        return

def jer(l,i):
    if l[i:i+2]=="er":
        i=i+2
        if i==len(l):
          g.append("Y")
          return
        else:
          return(jase(l,i),jerase(l,i),jdream(l,i))
    else:
        g.append("N")
        return

def jase(l,i):
    if l[i:i+3]=="ase":
        i=i+3
        if i==len(l):
               g.append("Y")
               return
        else:
          return(jase(l,i),jerase(l,i),jr(l,i))
    else:
        g.append("N")
        return

def jr(l,i):
    if l[i:i+1]=="r":
        i=i+1
        if i==len(l):
               g.append("Y")
               return
        else:
          return(jdream(l,i),jerase(l,i))
    else:
        g.append("N")
        return

s=input()
n=0
m=len(s)


jdream(s,n)
jerase(s,n)


if "Y" in g :
    print("YES")
else:
  print("NO")