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 erase_end(string):
    if string.endswith("dream"):
        string = string.rstrip("dream")
    elif string.endswith("dreamer"):
        string = string.rstrip("dreamer")
    elif string.endswith("erase"):
        string = string.rstrip("erase")
    elif string.endswith("eraser"):
        string = string.rstrip("eraser")
    elif string == "":
        string = "YES"
    else:
        string = "NO"
    return string
    
string = input()

while True:
    string = erase_end(string)
    if string == "YES" or string == "NO":
        break

print(string)

Submission status: Wrong Answer

Solution code:
s=input()
if s=='erasedream':
  exit()
s=s.split('eraser')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('erase')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('dreamer')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('dream')
if s.count('')>0:
  s.remove('')
s=''.join(s)
if s=='':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
s=s.split('eraser')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('erase')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('dream')
if s.count('')>0:
  s.remove('')
s=''.join(s)
s=s.split('dreamer')
if s.count('')>0:
  s.remove('')
s=''.join(s)
if s=='':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
t = ["dream","dreamer","erase","eraser"]
while True:
    if len(s) == 0:
        print("YES")
        break
    elif s[:5] in t:
        s = s[5:]
    elif s[:6] in t:
        s = s[6]
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
S=input()
S=S.split("dream")
S="".join(S)
S=S.split("dreamer")
S="".join(S)
S=S.split("erase")
S="".join(S)
S=S.split("eraser")
S="".join(S)
print("YES") if S=="" else print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

def calc(s):
    if s == "":
        return print("Yes")
    if s.find("dreameraser") != -1:
        s = s.replace("dreameraser", "")
        return calc(s)
    elif s.find("dreamerase") != -1:
        s = s.replace("dreamerase", "")
        return calc(s)        
    elif s.find("dreamer") != -1:
        s = s.replace("dreamer", "")
        return calc(s)
    elif s.find("dream") != -1:
        s = s.replace("dream", "")
        return calc(s)
    elif s.find("eraser") != -1:
        s = s.replace("eraser", "")
        return calc(s)
    elif s.find("erase") != -1:
        s = s.replace("erase", "")
        return calc(s)
    return print("No")

calc(s)

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
ac = T.count("eraser")
T = T.replace("eraser","xxxxxx",ac)
cc = T.count("erase")
T = T.replace("erase","xxxxx",cc)
bc = T.count("dreamer")
T = T.replace("dreamer","xxxxxxx",bc)
dc = T.count("dream")
T = T.replace("dream","xxxxx",dc)
D = T.count("x")
print(T)
print(D)
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
bc = T.count("dreamer")
T = T.replace("dreamer","xxxxxxx",bc)
dc = T.count("dream")
T = T.replace("dream","xxxxx",dc)
ac = T.count("eraser")
T = T.replace("eraser","xxxxxx",ac)
cc = T.count("erase")
T = T.replace("erase","xxxxx",cc)
D = T.count("x")
print(T)
print(D)
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
bc = T.count("dreamer")
T = T.replace("dreamer","xxxxxxx",bc)
ac = T.count("eraser")
T = T.replace("eraser","xxxxxx",ac)
cc = T.count("erase")
T = T.replace("erase","xxxxx",cc)
dc = T.count("dream")
T = T.replace("dream","xxxxx",dc)
D = T.count("x")
print(T)
print(D)
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
ac = T.count("eraser")
T = T.replace("eraser","xxxxxx",ac)
bc = T.count("dreamer")
T = T.replace("dreamer","xxxxxxx",bc)
cc = T.count("erase")
T = T.replace("erase","xxxxx",cc)
dc = T.count("dream")
T = T.replace("dream","xxxxx",dc)
D = T.count("x")
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
ac = T.count("eraser")
a = T.replace("eraser","xxxxxx",ac)
bc = a.count("dreamer")
b = a.replace("dreamer","xxxxxxx",bc)
cc = b.count("erase")
c = b.replace("erase","xxxxx",cc)
dc = c.count("dream")
d = c.replace("dream","xxxxx",dc)
D = d.count("x")
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = str(input())
lenT = len(T)
ac = T.count("eraser")
a = T.replace("eraser","xxxxxx",ac)
bc = T.count("dreamer")
b = a.replace("dreamer","xxxxxxx",bc)
cc = T.count("erase")
c = b.replace("erase","xxxxx",cc)
dc = T.count("dream")
d = c.replace("dream","xxxxx",dc)
D = d.count("x")
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
ac = T.count("eraser")
a = T.replace("eraser","xxxxxx",ac)
bc = T.count("dreamer")
b = a.replace("dreamer","xxxxxxx",bc)
cc = T.count("erase")
c = b.replace("erase","xxxxx",cc)
dc = T.count("dream")
d = c.replace("dream","xxxxx",dc)
D = d.count("x")
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
a = T.replace("eraser","xxxxxx")
b = a.replace("dreamer","xxxxxxx")
c = b.replace("erase","xxxxx")
d = c.replace("dream","xxxxx")
D = d.count("x")
if D == lenT:
  print("YES")
elif lenT > D:
  print("NO")
else :
  print("error")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
a = T.replace("eraser","xxxxxx")
b = a.replace("dreamer","xxxxxxx")
c = b.replace("erase","xxxxx")
d = c.replace("dream","xxxxx")
D = d.count("x")
if D != lenT:
  print("NO")
else :
  print("YES")

Submission status: Wrong Answer

Solution code:
T = input()
lenT = len(T)
a = T.replace("eraser","xxxxxx")
b = a.replace("dreamer","xxxxxxx")
c = b.replace("erase","xxxxx")
d = c.replace("dream","xxxxx")

if len(d) != lenT:
  print("NO")
else :
  print("YES")

Submission status: Wrong Answer

Solution code:
T = input()
 
w0 = "dream"
w1 = "dreamer"
w2 = "erase"
w3 = "eraser"
 
dict_sen = {0:w0,1:w1,2:w2,3:w3}
 
dp = ""
cnt = 0
cnt1= 0
time = int(len(T)/5)
time2 = int(len(T)/7)
 
while(cnt < time2):
  cnt += 1
  for i in range(4):
    if T[:len(dict_sen[i])] == dict_sen[i]:
      T = T[len(dict_sen[i]):]
      cnt1 += 1
      break
 
if cnt1 < time:
  print("NO")
else :
  print("YES")

Submission status: Wrong Answer

Solution code:
T = input()
 
w0 = "dream"
w1 = "dreamer"
w2 = "erase"
w3 = "eraser"
 
dict_sen = {0:w0,1:w1,2:w2,3:w3}
 
dp = ""
cnt = 0
cnt1= 0
time = int(len(T)/5)
time2 = int(len(T)/7)
 
while(cnt < time):
  cnt += 1
  for i in range(4):
    if T[:len(dict_sen[i])] == dict_sen[i]:
      T = T[len(dict_sen[i]):]
      cnt1 += 1
      break
 
if cnt1 < time2:
  print("NO")
else :
  print("YES")

Submission status: Wrong Answer

Solution code:
T = input()

w0 = "dream"
w1 = "dreamer"
w2 = "erase"
w3 = "eraser"

dict_sen = {0:w0,1:w1,2:w2,3:w3}

dp = ""

while(len(dp) < len(T)):
  for i in range(4):
    if T[len(dp):len(dp)+len(dict_sen[i])] == dict_sen[i]:
      dp = dp + dict_sen[i]
      break
if dp == T :
  print("yes")
else :
  print("no")

Submission status: Wrong Answer

Solution code:
S=str(input()) #Sの入力
Smojisuu=len(S)
c=S.count("eraser")
S=S.replace("eraser","xxxxxx",c)
print(S)
d=S.count("erase")
S=S.replace("erase","xxxxx",d)
print(S)
e=S.count("dreamer")
S=S.replace("dreamer","xxxxxxx",e)
f=S.count("dream")
S=S.replace("dream","xxxxx",f)
print(S)
g=S.count("x")
if len(S)>g:
  print("NO")
elif len(S)==g:
  print("YES")
else:
  print("error")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
words = ["dream", "dreamer", "erase", "eraser"]
words = [words[_][::-1] for _ in range(len(words))]
i = 0
while len(S) > 0:
	d = words[i]
	if S[:5] == d[:5]:
		S = S.lstrip(d)
		i = -1
	elif S[:6] == d[:6]:
		S = S.lstrip(d)
		i = -1
	elif S[:7] == d[:7]:
		S = S.lstrip(d)
		i = -1	
	if i >= 3:
		break
	i += 1
print("YES") if S == "" else print("NO")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
words = ["dream", "dreamer", "erase", "eraser"]
words = [words[_][::-1] for _ in range(len(words))]
i = 0
while len(S) > 0:
	d = words[i]
	if S[:5] == d[:5]:
		S = S.lstrip(d)
		i = -1
	elif i >= 3:
		break
	i += 1
if S == "":
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
words = ["dream", "dreamer", "erase", "eraser"]
words = [words[_][::-1] for _ in range(len(words))]
i = 0
while len(S) > 0:
	d = words[i]
	if str(S[:4]) == str(d[:4]):
		S = S.replace(d,"")
		i = -1
	elif i >= 3:
		break
	i += 1
if S == "":
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
def solve(S):
    if S in ["dream","dreamer","erase","eraser"]:
        return True
    elif len(S) <= 7:
        return False
    if S[0:7] == "dreamer":
        return solve(S[7:]) or solve(S[5:])
    elif S[0:5] == "dream":
        return solve(S[5:])
    if S[0:7] == "eraser":
        return solve(S[7:]) or solve(S[5:])
    elif S[0:5] == "erase":
        return solve(S[5:])

    return False

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

Submission status: Wrong Answer

Solution code:
def solve(S):
    if S in ["dream","dreamer","erase","eraser"]:
        return True
    elif len(S) <= 7:
        return False
    if S[0:7] == "dreamer":
        return solve(S[7:]) or solve(S[5:])
    elif S[0:5] == "dream":
        return solve(S[5:])
    if S[0:7] == "eraser":
        return solve(S[7:0]) or solve(S[5:])
    elif S[0:5] == "erase":
        return solve(S[5:])

    return False

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

s = stdin.readline().rstrip()

s.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")

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

Submission status: Wrong Answer

Solution code:
def separater(i,ss):
  k = ""
  for j in range(i):
    k += ss[j]
  return k

S = str(input())
s_list = list(S)
ss = []
i = 1
while True:
    k = i * (-1)
    ss.append(s_list[k]) 
    i += 1
    if (len(ss) == len(s_list)):
        for i in range(9):
            ss.append("A")
        break
while True:
    a_1 = separater(5,ss)
    a_2 = separater(6,ss)
    a_3 = separater(7,ss)
    if (ss[0] == "A"):
        print("Yes")
        break
    elif(a_1 == "esare"):
        for u in range(5):
            del ss[u]
    elif(a_1 == "maerd"):
        for u in range(5):
            del ss[u]
    elif(a_2 == "resare"):
        for u in range(6):
            del ss[u]
    elif(a_3 == "remaerd"):
        for u in range(7):
            del ss[u]
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
def separater(i,ss):
  d = []
  for j in range(i):
    d.append(ss[j])
  k = str(d)
  return k

S = str(input())
s_list = list(S)
ss = []
i = 1
while True:
    k = i * (-1)
    ss.append(s_list[k]) 
    i += 1
    if (len(ss) == len(s_list)):
        for i in range(9):
            ss.append("A")
        break
while True:
    a_1 = separater(5,ss)
    a_2 = separater(6,ss)
    a_3 = separater(7,ss)
    if (ss[0] == "A"):
        print("Yes")
        break
    elif(a_1 == "esare"):
        for u in range(5):
            del ss[u]
    elif(a_1 == "maerd"):
        for u in range(5):
            del ss[u]
    elif(a_2 == "resare"):
        for u in range(6):
            del ss[u]
    elif(a_3 == "remaerd"):
        for u in range(7):
            del ss[u]
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
def separater(i,ss):
  d = []
  for j in range(i):
    d.append(ss[j])
  k = str(d)
  return k

S = str(input())
s_list = list(S)
ss = []
i = 1
while True:
    k = i * (-1)
    ss.append(s_list[k]) 
    i += 1
    if (len(ss) == len(s_list)):
        for i in range(9):
            ss.append("A")
        break
while True:
    a_1 = separater(5,ss)
    a_2 = separater(6,ss)
    a_3 = separater(7,ss)
    print(a_1,a_2,a_3)
    if (ss[0] == "A"):
        print("Yes")
        break
    elif(a_1 == "esare"):
        for u in range(5):
            del ss[u]
    elif(a_1 == "maerd"):
        for u in range(5):
            del ss[u]
    elif(a_2 == "resare"):
        for u in range(6):
            del ss[u]
    elif(a_3 == "remaerd"):
        for u in range(7):
            del ss[u]
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
def separater(i,ss):
  d = []
  for j in range(i):
    d.append(ss[j])
  k = str(d)
  return k

S = str(input())
s_list = list(S)
ss = []
i = 1
while True:
    k = i * (-1)
    ss.append(s_list[k]) 
    i += 1
    if (len(ss) == len(s_list)):
        for i in range(9):
            ss.append("A")
        break
while True:
    a_1 = separater(6,ss)
    a_2 = separater(7,ss)
    a_3 = separater(8,ss)
    if (ss[0] == "A"):
        print("YES")
        break
    elif(a_1 == "maerd")or(a_1 == "esare"):
        for u in range(6):
            del ss[u]
    elif(a_2 == "resare"):
        for u in range(7):
            del ss[u]
    elif(a_3 == "remaerd"):
        for u in range(8):
            del ss[u]
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
def separater(i,ss):
  d = []
  for j in range(i):
    d.append(ss[j])
  k = str(d)
  return k

S = str(input())
s_list = list(S)
ss = []
i = 1
while True:
    k = i * (-1)
    ss.append(s_list[k]) 
    i += 1
    if (len(ss) == len(s_list)):
        for i in range(9):
            ss.append("A")
        break
while True:
    a_1 = separater(6,ss)
    a_2 = separater(7,ss)
    a_3 = separater(8,ss)
    if (ss[0] == "A"):
        print("Yes")
        break
    elif(a_1 == "maerd")or(a_1 == "esare"):
        for u in range(6):
            del ss[u]
    elif(a_2 == "resare"):
        for u in range(7):
            del ss[u]
    elif(a_3 == "remaerd"):
        for u in range(8):
            del ss[u]
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
st=input()
c="0"
j="0"
u="0"
for i in st:
    if i=="d" and u=="0" and c=="0":
        u="d"
        j="1"
    elif i=="r" and u=="d":
        u="r1"
    elif i=="e" and u=="r1":
        u="e1"
    elif i=="a" and u=="e1":
        u="a1"
    elif i=="m" and u=="a1":
        u="0"
        
    elif i=="e" and u=="0" and c=="0":
        u="e2"
        if j !="1":
            c="1"
    elif i=="r" and u=="e2":
        u="0"
        j="2"
    elif i=="a" and u=="0" and j=="2":
        u="a2"
    elif i=="s" and u=="a2":
        u="s"
    elif i=="e" and u=="s":
        u="0"
        c="0"
        j="3"
    elif i=="r" and u=="0" and j=="3":
        j="0"
    else:
        print("NO")
        exit(0)
if u=="0":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
st=input()
c="0"
j="0"
u="0"
for i in st:
    if i=="d" and u=="0" and c=="0":
        u="d"
        j="1"
    elif i=="r" and u=="d":
        u="r1"
    elif i=="e" and u=="r1":
        u="e1"
    elif i=="a" and u=="e1":
        u="a1"
    elif i=="m" and u=="a1":
        u="0"
        
    elif i=="e" and u=="0":
        u="e2"
        if j !="1":
            c="1"
    elif i=="r" and u=="e2":
        u="0"
        j="2"
    elif i=="a" and u=="0" and j=="2":
        u="a2"
    elif i=="s" and u=="a2":
        u="s"
    elif i=="e" and u=="s":
        u="0"
        c="0"
        j="3"
    elif i=="r" and u=="0" and j=="3":
        j="0"
    else:
        print("NO")
        exit(0)
if u=="0":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
st=input()
c="0"
j="0"
u="0"
for i in st:
    if i=="d" and u=="0" and c=="0":
        u="d"
        j="1"
    elif i=="r" and u=="d":
        u="r1"
    elif i=="e" and u=="r1":
        u="e1"
    elif i=="a" and u=="e1":
        u="a1"
    elif i=="m" and u=="a1":
        u="0"
        
    elif i=="e" and u=="0":
        u="e2"
        if j !="1":
            c="1"
    elif i=="r" and u=="e2":
        u="0"
        j="2"
    elif i=="a" and u=="0" and j=="2":
        u="a2"
    elif i=="s" and u=="a2":
        u="s"
    elif i=="e" and u=="s":
        u="0"
        c="0"
        j="3"
    elif i=="r" and j=="3":
        j="0"
    else:
        print("NO")
        exit(0)
if u=="0":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
st=input()
j="0"
u="0"
for i in st:
    if i=="d" and u=="0":
        u="d"
        j="0"
    elif i=="r" and u=="d":
        u="r1"
    elif i=="e" and u=="r1":
        u="e1"
    elif i=="a" and u=="e1":
        u="a1"
    elif i=="m" and u=="a1":
        u="0"
        j="1"
    elif i=="r" and j=="1":
        j="0"
    elif i=="e" and u=="0":
        u="e2"
        j="0"
    elif i=="r" and u=="e2":
        u="r2"
    elif i=="a" and u=="r2":
        u="a2"
    elif i=="s" and u=="a2":
        u="s"
    elif i=="e" and u=="s":
        u="0"
        j="2"
    elif i=="r" and j=="2":
        j="0"
    else:
        print("NO")
        exit(0)
if u=="0":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

while i < len(s):
    if s[i:i+5] == 'maerd' or s[i:i+6] == 'esare':
        i += 5
    elif s[i:i+6] == 'resare':
        i += 6
    elif s[i:i+7] == 'remaerd':
        i += 7
    else:
        break

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

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
s = input()
while s:
    if s[:12] == "dreameraser":
        s = s[12:]
    elif s[:10] == "dreamerase":
        s = s[10:]
    elif s[:7] == "dreamer":
        s = s[7:]
    elif s[:6] == "eraser":
        s = s[6:]
    elif s[:5] == "dream":
        s = s[5:]
    elif s[:5] == "erase":
        s = s[5:]
    else:
        print("NO")
        quit()
print("YES")
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import re
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
s = input()
while s:
    group = re.search(r"(dream|erase)(erase)*(r?)",s)
    if group != None:
        s = s[group.span()[1]:]
    else:
        print("NO")
        quit()
print("YES")
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
S = input()
ss = S
T = []
while len(ss) > 0:
    if 'dream' in ss[-5:]:
        ss = ss[:-5]
        T.insert(0, 'dream')
        continue
    if 'dreamer' in ss[-7:]:
        ss = ss[:-7]
        T.insert(0,'dreamer')
        continue
    if 'erase' in ss[-5:]:
        ss = ss[:-5]
        T.insert(0, 'erase')
        continue
    if 'eraser' in ss[-6:]:
        ss = ss[:-6]
        T.insert(0, 'eraser')
        continue
    break
t = ''.join(T)
if S == t:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()
while len(S) > 0:
    if 'dream' in S[-5:]:
        S = S[:-5]
        continue
    if 'dreamer' in S[-7:]:
        S = S[:-7]
        continue
    if 'erase' in S[-5:]:
        S = S[:-5]
        continue
    if 'eraser' in S[-6:]:
        S = S[:-6]
        continue
    break
if S == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()
a = S.replace('dreamer', '')
b = a.replace('dream', '')
c = b.replace('eraser', '')
d = c.replace('erase', '')
if d == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()
a = S.replace('dream', '')
b = a.replace('dreamer', '')
c = b.replace('erase', '')
d = c.replace('eraser', '')
if d == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=input()
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()
print(s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream",""))

Submission status: Wrong Answer

Solution code:
s = str(input())
l = ["dreamer","dream","eraser","erase"]
for i in l:
    s = s.replace(i,"")
if len(s) != 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = str(input())
l = ["dreamer","dream","eraser","erase"]
for i in l:
    s = s.replace(i,"")
if len(s) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
s = list(input())
check =['dream','dreamer','erase','eraser']
while len(s) >= 8:
    if ''.join(s[-5:]) == check[0]:
        for _ in range(5): s.pop()
        continue
    if ''.join(s[-7:]) == check[1]:
        for _ in range(7): s.pop()
        continue
    if ''.join(s[-5:]) == check[2]:
        for _ in range(5): s.pop()
        continue
    if ''.join(s[-6:]) == check[3]:
        for _ in range(6): s.pop()
        continue
    print('No')
    sys.exit()
if ''.join(s) == check[0] or ''.join(s) == check[1] or ''.join(s) == check[2] or ''.join(s) == check[3]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]

for i,_ in enumerate(add,1):
	for j in itertools.permutations(add,r=i):
		t.append("".join(j))

print(t)

temp=False
for i in range(len(t)):
	if(s==t[i]):
		temp=True
		break

if temp==True:
	print("Yes")
else:
	print("No")
	

"""

Submission status: Wrong Answer

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

s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]

for i,_ in enumerate(add,1):
	for j in itertools.permutations(add,r=i):
		t.append("".join(j))

print(t)

temp=False
for i in range(len(t)):
	if(s==t[i]):
		temp=True
		break

if temp==True:
	print("Yes")
else:
	print("No")
	

"""

Submission status: Wrong Answer

Solution code:
import itertools

s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]

for i,_ in enumerate(add,1):
	for j in itertools.permutations(add,r=i):
		t.append("".join(j))

temp=False
for i in range(len(t)):
	if(s==t[i]):
		temp=True
		break

if temp==True:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
s = input()
l_o = ['dream','dreamer', 'ereaser', 'erase']
l_r = [x[::-1] for x in l_o]

mi = min([len(word) for word in l_o])

def helper(s):
    if s == '':
        return True
    elif len(s) < mi:
        return False

    else:
        for word in l_r:
            if s.startswith(word):
                return helper(s[len(word):])
        return False


flag = helper(s[::-1])

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

Submission status: Wrong Answer

Solution code:

s = input()
l_o = ['dream','dreamer', 'ereaser', 'erase']
l_r = [x[::-1] for x in l_o]

mi = min([len(word) for word in l_o])

def helper(s):
    print(s)
    if s == '':
        return True
    elif len(s) < mi:
        return False

    else:
        for word in l_r:
            if s.startswith(word):
                return helper(s[len(word):])
        return False


flag = helper(s[::-1])

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

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
l_o = ['dream','dreamer', 'ereaser', 'erase']
l_r = [x[::-1] for x in l_o]

mi = min([len(word) for word in l_o])

def helper(s):
    print(s)
    if s == '':
        return True
    elif len(s) < mi:
        return False

    else:
        for word in l_r:
            if s.startswith(word):
                return helper(s[len(word):])
        return False


flag = helper(s[::-1])

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

Submission status: Wrong Answer

Solution code:
s=input()

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

for w in words:
  s=s.strip(w)

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

Submission status: Wrong Answer

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

r_words=['maerd', 'remaerd', 'esare', 'resare']

for w in r_words:
  s=s.strip(w)

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

Submission status: Wrong Answer

Solution code:
S = input()
words = ['dreamer', 'dream', 'eraser', 'erase']
for w in words:
    S = S.replace(w,"")
print("YES" if len(S) == 0 else "NO")

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
divide = list(map(lambda phrase:phrase[::-1], ['dream', 'dreamer', 'erase', 'eraser']))
print(divide)

flag = False
i = 0
while i != len(S):
    for d in divide:
        if S[i:i+len(d)] == d:
            flag = True
            i += len(d)
            break

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

Submission status: Wrong Answer

Solution code:
from collections import deque
S = input()


def bfs(s):
    queue = deque([s])
    while queue:
        s = queue.popleft()
        if s == S:
            return True
        elif len(s) > len(S):
            return False
        else:
            queue.append(s+'dream')
            queue.append(s+'dreamr')
            queue.append(s+'erase')
            queue.append(s+'eraser')


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

Submission status: Wrong Answer

Solution code:
import re

S = input()
S = re.split('dream|erase', S)
if S[0] != '':
    print('NO')
    exit()

print('YES' if set(S) <= {'', 'r'} else 'NO')

Submission status: Wrong Answer

Solution code:
import re

S = input()
S = set(re.split('dream|erase', S))
print('YES' if S <= {'', 'r'} else 'NO')

Submission status: Wrong Answer

Solution code:
S=input()
S=S[::-1]
divide=['dream','dreamer','erase','eraser'] 
flag=False
for i in range(4):
  divide[i]=divide[i][::-1]

i=0
while i<(len(S)-1):
  flag=False
  for d in divide:
    if i+(len(d)-1)<=(len(S)-1) and S[i:i+len(d)]==d:   
      flag=True
      i+=len(d)-1
      break
  break

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

Submission status: Wrong Answer

Solution code:
S=input()
S=S[::-1]
divide=['dream','dreamer','erase','eraser'] 
flag=False
for i in range(4):
  divide[i]=divide[i][::-1]

i=0
while i<(len(S)-1):
  flag=False
  for d in divide:
    if i+(len(d)-1)<(len(S)-1) and S[i:i+len(d)]==d:   
      flag=True
      i+=len(d)-1
      break
  break

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

Submission status: Wrong Answer

Solution code:
S=input()
S=S[::-1]
divide=['dream','dreamer','erase','eraser'] 
flag=False
for i in range(4):
  divide[i]=divide[i][::-1]

i=0
while i<(len(S)-1):
  flag=False
  for d in divide:
    if i+(len(d)-1):   
      flag=True
      i+=len(d)-1
      break

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

Submission status: Wrong Answer

Solution code:
s = input()
sr = s[::-1]
w = ["remaerd","maerd","resare","esare"]
for i in range(4):
    sr = sr.replace(w[i],"")
if sr == "":print("Yes")
else:print("No")
print(sr)

Submission status: Wrong Answer

Solution code:
s = input()
sr = s[::-1]
w = ["maerd","remaerd","esare","resare"]
for i in range(4):
    sr = sr.replace(w[i],"")
if sr == "":print("YES")
else:print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
sr = s[::-1]
w = ["maerd","remaerd","esare","resare"]
for i in range(4):
    sr = sr.replace(w[i],"")
if sr == "":print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
def checKString(S):
  while True:
    if S.find('eraser') >= 0:
      S = S.replace('eraser', '')
    elif S.find('erase') >= 0:
      S = S.replace('erase', '')
    elif S.find('dreamer') >= 0:
      S = S.replace('dreamer', '')
    elif S.find('dream') >= 0:
      S = S.replace('dream', '')
    else:
      break 
  return 'Yes' if len(S) == 0 else 'No'
  
if __name__ == '__main__':
    # print('入力してください')
    S = input()
    print(checKString(S))

Submission status: Wrong Answer

Solution code:
s = input()
word_list = ["dreamerase","eraser","dreamer","dream","erase",""]

for word in word_list:
    s = s.replace(word,"")
    
if s not in word_list:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
word_list = ["eraser","dreamer","dream","erase",""]

for word in word_list:
    s = s.replace(word,"")
    
if s not in word_list:
    print("NO")
else:
    print("YES")