Problem:


Score : 300 points

Problem Statement

You are given a string S consisting of lowercase English letters.
Another string T is initially empty.
Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:

Append one of the following at the end of T: dream, dreamer, erase and eraser.

Constraints

1≦|S|≦10^5

S consists of lowercase English letters.

Input

The input is given from Standard Input in the following format:

S

Output

If it is possible to obtain S = T, print YES. Otherwise, print NO.

Sample Input 1

erasedream

Sample Output 1

YES

Append erase and dream at the end of T in this order, to obtain S = T.

Sample Input 2

dreameraser

Sample Output 2

YES

Append dream and eraser at the end of T in this order, to obtain S = T.

Sample Input 3

dreamerer

Sample Output 3

NO



Sample input:
erasedream


Sample output:
YES

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#main
s=input()
s=s.replace("dreamer","").replace("eraser","").replace("dream","").replace("erase","")
print("YES" if s=="" else "NO")

Submission status: Wrong Answer

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

i = 0
res = "YES"

       
print(res)

Submission status: Wrong Answer

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" or 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
        
print(res)

Submission status: Wrong Answer

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+1 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
  else:
    res = "NO"
    break
        
print(res)

Submission status: Wrong Answer

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+1 < length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
  else:
    res ="NO"
    break
        
print(res)

Submission status: Wrong Answer

Solution code:
string = input()
 
flg = True
while len(string) > 0:
  if string.endswith('dream'):
    string = string[:-5]
  elif string.endswith('dreamer'):
    string = string[:-7]
  elif string.endswith('erase'):
    string = string[:-6]
  elif string.endswith('eraser'):
    string = string[:-6]
  else:
    print('NO')
    flg = False
    break
if flg:
  print('YES')

Submission status: Wrong Answer

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

S = S.replace("dream"[::-1], "")
S = S.replace("dreamer"[::-1], "")
S = S.replace("erase"[::-1], "")
S = S.replace("eraser"[::-1], "")

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

Submission status: Wrong Answer

Solution code:
import re

def solve(s):
    return 'YES' if re.match('^((dream|erase)r?)*$', s) else 'NO'

_s = input()
print(solve(_s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

]

for s in string:
    S.replace(s, "1")
S.replace("1", "")
if len(S) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
string = list(map(
    lambda x: x[::-1],
    [
        "dream",
        "dreamer",
        "erase",
        "eraser"

    ]))

for s in string:
    S.replace(s, "1")
S.replace("1", "")
if len(S) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
string = list(map(
    lambda x: x[::-1],
    [
        "dream",
        "dreamer",
        "erase",
        "eraser"

    ]))
index = 0
while 1:
    for x in string:
        match = S.find(x, index)
        if match == -1:
            continue
        elif match > -1:
            index += match + len(x)
        if index == len(S):
            print("YES")
            exit()

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
string = list(map(
    lambda x: x[::-1],
    [
        "dream",
        "dreamer",
        "erase",
        "eraser"
    ]))
index = 0
while 1:
    for x in string:
        match = S.find(x, index)
        if match == -1:
            continue
        elif match > -1:
            index += len(x)
        if index == len(S):
            print("YES")
            exit()

Submission status: Wrong Answer

Solution code:
S = input()
Mozi = ["resare","esare","remaerd","maerd"]

S = S[::-1]
for i in Mozi:
    S = S.replace(i,"")
if not S:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#import random
S = input()
#Mozi_f = ["eraser","erase","dreamer","dream"]
Mozi = ["resare","esare","remaerd","maerd"]
#S = random.choice(Mozi_f)
#S = "".join([random.choice(Mozi_f) for x in range(10)])
S = S[::-1]

for i in Mozi:
    S = S.replace(i,"")
if not S:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
from collections import deque

divide = ["dream", "dreamer", "erase", "eraser"];

s = input()
que = deque()

can = "NO"

que.append(0)

while(len(que) > 0):
  t = que[0]
  que.pop()
  if (t == len(s)):
    can = "YES"
    break
  for e in divide:
    if s[t:t+len(e)] == e:
      que.append(t+len(e))
print(can)

Submission status: Wrong Answer

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

if S not in "X":
    for i in Mozi:
        T = S.replace(i,"X")
        S = T.strip("X")

    if not S:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

for i in Mozi:
    T = S.replace(i,"X")
    S = T.strip("X")

if not S:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for i in Mozi:
    T = S.strip(i)
    S = T
if not S:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for i in Mozi:
    T = S.replace(i,"X")
    S = T
if S not in "X":
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()

sc = ["dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"]
for i in sc:
    S = S.replace(i, '')

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

Submission status: Wrong Answer

Solution code:
s = input()

sc = ["dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"]
for i in sc:
    s = s.replace(i, '')

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

Submission status: Wrong Answer

Solution code:
s = input()

sc = ["dreameracer", "dreamerace", "dreamer", "dream", "eracer", "erace"]
for i in sc:
    s = s.replace(i, '')

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

Submission status: Wrong Answer

Solution code:
s = input()

sc = ["dreameraser", "dreamerase", "dreamer", "dream", "eracer", "erace"]
for i in sc:
    s = s.replace(i, '')

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

Submission status: Wrong Answer

Solution code:
s = input()
s_reverse = s[::-1]

arr = ['dream', 'dreamer', 'erase', 'eraser']
arr_reversed = list(map(lambda item: item[::-1], arr))
able = True
t = ""
idx = 0
while s_reverse != t and able:
    for i in range(len(arr_reversed)):
        item = arr_reversed[i]
        if s_reverse[idx: idx + len(item)] == item:
            
            idx += len(item)
            t += item
            break
        if i == len(arr_reversed) - 1:
            able = False
    else:
        continue
    break

print("YES" if able else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_reverse = s[::-1]

arr = ['dream', 'dreamer', 'erase', 'eraser']
arr_reversed = list(map(lambda item: item[::-1], arr))
able = True
t = ""
idx = 0
while s_reverse != t and able:
    for i in range(len(arr_reversed)):
        item = arr_reversed[i]
        if s_reverse[idx: len(item)] == item:
            
            idx += len(item)
            t += item
            break
        elif i == len(arr_reversed) - 1:
            able = False
    else:
        continue
    break

print("YES" if able else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_reverse = s[::-1]

arr = ['dream', 'dreamer', 'erase', 'eraser']
arr_reversed = list(map(lambda item: item[::-1], arr))
able = True
t = ""
idx = 0
while s_reverse != t and able:
    for i in range(len(arr_reversed)):
        item = arr_reversed[i]
        if s_reverse[idx: len(item)] == item:
            
            idx += len(item)
            t += item
            break
        if i == len(arr_reversed) - 1:
            able = False
    else:
        continue
    break

print("YES" if able else "NO")

Submission status: Wrong Answer

Solution code:
S = input()

num_5 = ["dream", "erase"]
num_6 = ["dreamer", "eraser"]
while len(S) != 0:
    if S[0:6] in num_6:
        S = S[6:]
    elif S[0:5] in num_5:
        S = S[5:]
    else:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
a = 0
t = ("")

if len(s) < 5:
    print("NO")

while a < len(s):
    if s[a+0:a+5] == ("dream") and s[a+0+2:a+5+2] != ("er"):
        a += 5

    elif s[a+0:a+5] == ("dream") and s[a+0+2:a+5+2] == ("er"):
        if s[a+7+0:a+7+3] != ("ase"):
            a += 7

        elif s[a+7+0:a+7+3] == ("ase") and s[a+10+0:a+10+1] != ("r"):
            a += 10

        elif s[a+7+0:a+7+3] == ("ase") and s[a+10+0:a+10+1] == ("r"):
            a += 11

    elif s[a+0:a+5] == ("erase") and s[a+5+0:a+5+1] != ("r"):
        a += 5

    elif s[a+0:a+5] == ("erase") and s[a+5+0:a+5+1] == ("r"):
        a += 6

    else:
        break

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

Submission status: Wrong Answer

Solution code:
s = input()
a = 0
t = ("")

while a < len(s):
    if s[a+0:a+5] == ("dream") and s[a+0+2:a+5+2] != ("er"):
        a += 5
        t += ("dream")

    elif s[a+0:a+5] == ("dream") and s[a+0+2:a+5+2] == ("er"):
        if s[a+7+0:a+7+3] != ("ase"):
            a += 7
            t += ("dreamer")

        elif s[a+7+0:a+7+3] == ("ase") and s[a+10+0:a+10+1] != ("r"):
            a += 10
            t += ("dreamerase")

        elif s[a+7+0:a+7+3] == ("ase") and s[a+10+0:a+10+1] == ("r"):
            a += 11
            t += ("dreameraser")

    elif s[a+0:a+5] == ("erase") and s[a+5+0:a+5+1] != ("r"):
        a += 5
        t += ("erase")

    elif s[a+0:a+5] == ("erase") and s[a+5+0:a+5+1] == ("r"):
        a += 6
        t += ("eraser")

    else:
        break

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

Submission status: Wrong Answer

Solution code:
s = input()
a = 0
t = ("")

while a < len(s):
    if s[a+0:a+5] == ("dream") and s[a+0+2:a+5+2] != ("er"):
        a += 5
        t += ("dream")

    elif s[a+0:a+5] == ("dream") and s[a+0+2:a+5+2] == ("er"):
        if s[a+7+0:a+7+3] != ("ase"):
            a += 7
            t += ("dreamer")

        elif s[a+7+0:a+7+3] == ("ase") and s[a+10+0:a+10+1] != ("r"):
            a += 10
            t += ("dreamerase")

        elif s[a+7+0:a+7+3] == ("ase") and s[a+10+0:a+10+1] == ("r"):
            a += 11
            t += ("dreameraser")

    elif s[a+0:a+5] == ("erase") and s[a+5+0:a+5+1] != ("r"):
        a += 5
        t += ("erase")

    elif s[a+0:a+5] == ("erase") and s[a+5+0:a+5+1] == ("r"):
        a += 6
        t += ("eraser")

    else:
        break

print(t)

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

Submission status: Wrong Answer

Solution code:
s="dreamerer"

s=s.replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','')

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

Submission status: Wrong Answer

Solution code:
s = input()
s = list(s)
s = s[::-1]

word_list = ['maerd', 'remaerd', 'esare', 'resare']
i = 0
while i != len(s):
    a = s[i:i+5]
    a = ''.join(a)
    b = s[i:i+6]
    b = ''.join(b)
    if a in word_list:
        i += 5
    elif b in word_list:
        i += 6
    else:
        print('NO')
        exit()

print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

if "dream"and "dreamer" and "eraser" and "erase" in s:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = input().rstrip()

while S:
    if S[-5:] == "dream":
        S = S[:-5]
    elif S[-5] == "erase":
        S = S[:-5]
    elif S[-6:] == "eraser":
        S = S[:-6]
    elif S[-7:] == "dreamer":
        S = S[:-7]
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
n = 0
while n == 0:
  if s[len(s)-5:len(s)] == "dream":
    s = s.rstrip("ream")
    s = s[:len(s)-1]
  elif s[len(s)-5:len(s)] == "erase":
    s = s.rstrip("rase")
    s = s[:len(s)-1]
  elif s[len(s)-7:len(s)] == "dreamer":
    s = s.rstrip("reamer")
    s = s[:len(s)-1]
  elif s[len(s)-6:len(s)] == "eraser":
    s = s.rstrip("raser")
    s = s[:len(s)-1]
  else:
    if len(s) == 0:
      n = 1
      print("YES")
    else:
      n = -1
      print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s2 = s.split('eraser')
s3 = ''.join(s2).split('erase')
s4 = ''.join(s3).split('dreamer')
s5 = ''.join(s4).split('dream')

if len(s5) == 1 and s5[0] == '':
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s2 = s.split('dream')
s3 = ''.join(s2).split('erase')
try:
  s3.remove('er')
  s3.remove('r')
except ValueError:
  pass
if s3[0] != '':
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
n = 0
while n == 0:
  if s[len(s)-5:len(s)] == "dream":
    s = s.rstrip("dream")
    #s = s.rstrip("d")
  elif s[len(s)-5:len(s)] == "erase":
    s = s.rstrip("erase")
    #s = s.rstrip("e")
  elif s[len(s)-7:len(s)] == "dreamer":
    s = s.rstrip("dreamer")
    #s = s.rstrip("d")
  elif s[len(s)-6:len(s)] == "eraser":
    s = s.rstrip("eraser")
    #s = s.rstrip("e")
  else:
    if len(s) == 0:
      n = 1
      print("YES")
    else:
      n = -1
      print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
n = 0
while n == 0:
  if s[len(s)-5:len(s)] == "dream":
    s = s.rstrip("ream")
    s = s.rstrip("d")
  elif s[len(s)-5:len(s)] == "erase":
    s = s.rstrip("rase")
    s = s.rstrip("e")
  elif s[len(s)-7:len(s)] == "dreamer":
    s = s.rstrip("reamer")
    s = s.rstrip("d")
  elif s[len(s)-6:len(s)] == "eraser":
    s = s.rstrip("raser")
    s = s.rstrip("e")
  else:
    if len(s) == 0:
      n = 1
      print("YES")
    else:
      n = -1
      print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
n = 0
while n == 0:
  if s[len(s)-5:len(s)] == "dream":
    s = s.rstrip("ream")
    s = s.rstrip("d")
  elif s[len(s)-5:len(s)] == "erase":
    s = s.rstrip("rase")
    s = s.rstrip("e")
  elif s[len(s)-7:len(s)] == "dreamer":
    s = s.rstrip("reamer")
    s = s.rstrip("d")
  elif s[len(s)-6:len(s)] == "eraser":
    s = s.rstrip("raser")
    s = s.rstrip("e")
  else:
    if len(s) == 0:
      n = 1
      print("Yes")
    else:
      n = -1
      print("No")

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
#!/usr/bin/env python
"""AtCoder Beginner Contest 049: C - 白昼夢 / Daydream
https://atcoder.jp/contests/abc049/tasks/arc065_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'

WORDS = ['dream', 'dreamer', 'erase', 'eraser']


def check(S):
    T = ''
    while True:
        for word in WORDS:
            if S.endswith(word):
                T += word
                S = S[:S.rfind(word)]
                if S == '':
                    return 'YES'
                continue
        return 'NO'


def main():
    S = input()
    answer = check(S)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

s=input().strip()
n=len(s)
s+="###################################"
i=0
while n-i>=1:
    """print(n-i)
    print(s[i:i+5])"""

    if s[i:i+5]=="dream":
        if s[i+5:i+7]=="er":
            #print(s[i+7:i+11])
            if s[i+7:i+10]=="ase":
                i+=10
            elif s[i+10]=="r":
                i+=11
            else:
                i+=7
        else:
            i+=5

    elif s[i:i+5]=="erase":
        #print(8)
        if s[i+5]=="r":
            i+=6
        else:
            i+=5
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

s=input().strip()
n=len(s)
s+="###################################"
i=0
while n-i>=1:
    """print(n-i)
    print(s[i:i+5])"""

    if s[i:i+5]=="dream":
        if s[i+5:i+7]=="er":
            #print(s[i+7:i+11])
            if s[i+7:i+11]=="aser":
                i+=11
            else:
                i+=7
        else:
            i+=5

    elif s[i:i+5]=="erase":
        #print(8)
        if s[i+5]=="r":
            i+=6
        else:
            i+=5
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

s=input().strip()
n=len(s)
s+="###################################"
i=0
while n-i>=1:
    """print(n-i)
    print(s[i:i+5])"""

    if s[i:i+5]=="dream":
        if s[i+5:i+7]=="er":
            #print(s[i+7:i+11])
            if s[i+7:i+11]=="aser":
                i+=11
            else:
                i+=7
        else:
            i+=5

    elif s[i:i+5]=="erase":
        #print(8)
        if s[i+5]=="r":
            i+=6
        else:
            i+=5
    else:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

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

s=input().strip()
n=len(s)
s+="###################################"
i=0
while n-i>=1:
    """print(n-i)
    print(s[i:i+5])"""

    if s[i:i+5]=="dream":
        if s[i+5:i+7]=="er":
            #print(s[i+7:i+11])
            if s[i+7:i+11]=="aser":
                i+=11
            else:
                print("NO")
                exit()
        else:
            i+=5

    elif s[i:i+5]=="erase":
        #print(8)
        if s[i+5]=="r":
            i+=6
        else:
            i+=5
    else:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

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

s = S[::]
a = 'dream'[::-1]
b = 'dreamer'[::-1]
c = 'erase'[::-1]
d = 'eraser'[::-1]
tmp = [a, b, c, d]

idx = 1
for _ in range(1, len(S)):
    _s = s[:idx]
    if _s in tmp:
        s = _s
        idx = 1
        continue
    idx += 1
if _s in tmp:
    s = []

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

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
S = S.replace('dream'[::-1], '').replace('erase'[::-1], '').replace(
    'eraser'[::-1], '').replace('dreamer'[::-1], '')

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

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
S = S.replace('dream'[::-1], '').replace('dreamer'[::-1], '').replace(
    'eraser'[::-1], '').replace('erase'[::-1], '')

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

Submission status: Wrong Answer

Solution code:
S = input()
S = S.replace('dream'[::-1], '').replace('dreamer'[::-1], '').replace(
    'eraser'[::-1], '').replace('erase'[::-1], '')

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S = input()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
S = s[::-1]
D = ['dream', 'dreamer']
E = ['erase', 'eraser']
T = ['dream', 'dreamer', 'erase', 'eraser']
K = ['maerd', 'remae', 'esare', 'resar']

if s[0] == 'd':
    for d in D:
        for t in T:
            if s == d + t and S[0:5] in K:
                print('YES')
                exit()

if s[0] == 'e':
    for e in E:
        for t in T:
            if s == e + t and S[0:5] in K:
                print('YES')
                exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
t =['maerd', 'remae', 'esare', 'resar']

if s[0:5] in t:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
t =['maerd', 'remae', 'esare', 'resar']

if s[0:-5] in t:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
s = input()[::-1]
t =['maerd', 'rmaer', 'esare', 'resar']

if s[0:5] in t:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
D = ['dream', 'dreamer']
E = ['erase', 'eraser']
T = ['dream', 'dreamer', 'erase', 'eraser']
K = ['', 'dream', 'dreamer', 'erase', 'eraser']

if s[0] == 'd':
    for d in D:
        for t in T:
            for k in K:
                if s == d+t+k:
                    print('YES')
                    exit()

if s[0] == 'e':
    for e in E:
        for t in T:
            for k in K:
                if s == e+t+k:
                    print('YES')
                    exit()

print('NO')

Submission status: Wrong Answer

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

if s[0] == 'd':
    for d in D:
        for t in T:
            for t in T:
                if s == d+t+t:
                    print('YES')
                    exit()

if s[0] == 'e':
    for e in E:
        for t in T:
            for t in T:
                if s == e+t+t:
                    print('YES')
                    exit()

print('NO')

Submission status: Wrong Answer

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

if s[0] == 'd':
    for d in D:
        for t in T:
            if s == d+t:
                print('YES')
                exit()

if s[0] == 'e':
    for e in E:
        for t in T:
            if s == e+t:
                print('YES')
                exit()

print('NO')

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
s = input()
a = 'dream'
b = 'dreamer'
c = 'erase'
d = 'eraser'
for i in range(len(s)):  
  if not s[i] == a[i//5] or s[i] == b[i//7] or s[i] == c[i//5] or s[i] == d[i//6]:
    print('NO')
    exit()
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
a = 'dream'
b = 'dreamer'
c = 'erase'
d = 'eraser'
for i in range(len(s)):  
  if not s[i] == a[i//4] or s[i] == b[i//5] or s[i] == c[i//4] or s[i] == d[i//5]:
    print('NO')
    sys.exit( )
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
a = 'dream'
b = 'dreamer'
c = 'erase'
d = 'eraser'
for i in range(len(s)):  
  if not s[i] == a[i//4] or s[i] == b[i//5] or s[i] == c[i//4] or s[i] == d[i//5]:
    print('NO')
    exit()
print('YES')

Submission status: Wrong Answer

Solution code:
#49c
S = str(input()) #1≦|S|≦10**5
#Tが空文字列である状態から始め、以下の操作を好きな回数繰り返すことで S=Tとすることができるか判定してください。
#    Tの末尾に dream dreamer erase eraser のいずれかを追加する。

#末尾から見ていく
i = len(S) - 5
if i < 0:
    print("NO")
else:
    while i >= 0:
        end_5_char = S[i:i+5]

        #print(i,end_5_char)

        if end_5_char == "eamer":
            print(i,S[i-2:i])
            if i < 2 or S[i-2:i] != "dr":
                print("NO")
                break
            else:
                i -= 2
        elif end_5_char == "raser":
            print(i,S[i-1:i])
            if i < 1 or S[i-1:i] != "e":
                print("NO")
                break
            else:
                i -= 1
        elif end_5_char != "dream" and end_5_char != "erase":
            print("NO")
            break

        i -= 5
    else:
        print("YES")

Submission status: Wrong Answer

Solution code:
#49c
S = str(input()) #1≦|S|≦10**5
#Tが空文字列である状態から始め、以下の操作を好きな回数繰り返すことで S=Tとすることができるか判定してください。
#    Tの末尾に dream dreamer erase eraser のいずれかを追加する。

#末尾から見ていく
i = len(S) - 5
if i < 0:
    print("NO")
else:
    while i >= 0:
        end_5_char = S[i:i+5]

        #print(i,end_5_char)

        if end_5_char == "eamer":
            print(i,S[i-2:i])
            if i < 2 or S[i-2:i] != "dr":
                print("NO")
                break
            else:
                i -= 2
        elif end_5_char == "raser":
            print(i,S[i-1:i])
            if i < 1 or S[i-1:i] != "e":
                print("NO")
                break
            else:
                i -= 1
        elif end_5_char != "dream" and end_5_char != "erase":
            print("NO")
            break

        i -= 5
    else:
        print("OK")

Submission status: Wrong Answer

Solution code:
#49c
S = str(input()) #1≦|S|≦10**5
#Tが空文字列である状態から始め、以下の操作を好きな回数繰り返すことで S=Tとすることができるか判定してください。
#    Tの末尾に dream dreamer erase eraser のいずれかを追加する。

#末尾から見ていく
i = len(S) - 5
if i < 0:
    print("NO")
else:
    while i >= 0:
        end_5_char = S[i:i+5]

        print(i,end_5_char)

        if end_5_char == "eamer":
            print(i,S[i-2:i])
            if i < 2 or S[i-2:i] != "dr":
                print("NO")
                break
            else:
                i -= 2
        elif end_5_char == "raser":
            print(i,S[i-1:i])
            if i < 1 or S[i-1:i] != "e":
                print("NO")
                break
            else:
                i -= 1
        elif end_5_char != "dream" and end_5_char != "erase":
            print("NO")
            break

        i -= 5
    else:
        print("OK")

Submission status: Wrong Answer

Solution code:
s = str(input())

i = 0
while i < len(s):      
    if s[i:i+11] == 'dreameraser':
        i += 11
    elif s[i:i+10] == 'dreamerase':
        i += 10
    elif s[i:i+6] == 'dreamer':
        i += 6
    elif s[i:i+5] == 'dream':
        i += 5
    elif s[i:i+6] == 'eraser':
        i += 6
    elif s[i:i+5] == 'erase':
        i += 5
    else:
        break
if i == len(s):
    ans = 'YES'
else:
    ans = 'NO'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
lst = ["eraser","erase","dreamer","dream"]
for w in lst:
    s.replace(w,"")
    
if len(s) == 0:
    ans = "YES"
else:
    ans = "NO"

print(ans)

Submission status: Wrong Answer

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) or a.endswith(ere)):
        a = a[:len(a)-7]
    else:
        ret = "NO"
        break
        
print(ret)