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:
import re

S = input()
de_list = ['dream', 'dreamer', 'erase', 'eraser']

def del_r(s):
    success = False
    for de in de_list:
        if s.rfind(de) > -1:
            s = s[::-1].replace(de[::-1], '')
            success = True
    return success, s

roop_flg = True
while(roop_flg):
    roop_flg, S = del_r(S)

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

Submission status: Wrong Answer

Solution code:
import re

S = input()
de_list = ['dream', 'dreamer', 'erase', 'eraser']

for de1 in de_list:
    search = de1+'$'
    if re.search(search, S) is not None:
        S = re.sub(search, '', S)
        for de2 in de_list:
            search = de2+'$'
            S = re.sub(search, '', S)

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

Submission status: Wrong Answer

Solution code:
import re
S = input()
num = []
l = []


if ("eraser" in S)  == True:
	S.replace("eraser", "")

if ("erase" in S)   == True:
	S.replace("erase", "")

if ("dreamer" in S) == True:
	S.replace("dreamer", "")

if ("dream" in S)   == True:
	S.replace("dreamer", "")

"""
if ("eraser" in S)  == True:
	num.append(S.count("eraser"))
	for i in range(S.count("eraser")):
		a.append(S.find("eraser"))
		S[S.find("eraser"):6]

if ("erase" in S)   == True:
	num.append(S.count("erase"))
	for i in range(S.count("erase")):
		a.append(S.find("erase"))
		S[S.find("erase"):5]

if ("dreamer" in S) == True:
	num.append(S.count("dreamer"))
	for i in range(S.count("dreamer")):
		a.append(S.find("dreamer"))
		S[S.find("dreamer"):7]

if ("dream" in S)   == True:
	num.append(S.count("dream"))
	for i in range(S.count("dream")):
		a.append(S.find("dream"))
		S[S.find("dream"):5]
"""
if len(S) == 0:
	print("YES")

if len(S) != 0:
	print("NO")

Submission status: Wrong Answer

Solution code:
import re
S = input()
num = []
l = []

if ("eraser" in S)  == True:
	S = S.strip("eraser")

if ("erase" in S)   == True:
	S = S.strip("erase")

if ("dreamer" in S) == True:
	S = S.strip("dreamer")

if ("dream" in S)   == True:
	S = S.strip("dream")
	
"""
if ("eraser" in S)  == True:
	num.append(S.count("eraser"))
	for i in range(S.count("eraser")):
		a.append(S.find("eraser"))
		S[S.find("eraser"):6]

if ("erase" in S)   == True:
	num.append(S.count("erase"))
	for i in range(S.count("erase")):
		a.append(S.find("erase"))
		S[S.find("erase"):5]

if ("dreamer" in S) == True:
	num.append(S.count("dreamer"))
	for i in range(S.count("dreamer")):
		a.append(S.find("dreamer"))
		S[S.find("dreamer"):7]

if ("dream" in S)   == True:
	num.append(S.count("dream"))
	for i in range(S.count("dream")):
		a.append(S.find("dream"))
		S[S.find("dream"):5]
"""
if len(S) == 0:
	print("YES")

if len(S) != 0:
	print("NO")
print(S)

Submission status: Wrong Answer

Solution code:
import re
S = input()
a = []
num = []
l = []
re.split("\d+",S)
if ("dream" in S)   == True:
	num.append(S.count("dream"))
	for i in range(S.count("dream")):
		a.append(S.find("dream"))
		S[S.find("dream"):5]

if ("dreamer" in S) == True:
	num.append(S.count("dreamer"))
	for i in range(S.count("dreamer")):
		a.append(S.find("dreamer"))
		S[S.find("dreamer"):7]

if ("erase" in S)   == True:
	num.append(S.count("erase"))
	for i in range(S.count("erase")):
		a.append(S.find("erase"))
		S[S.find("erase"):5]

if ("eraser" in S)  == True:
	num.append(S.count("eraser"))
	for i in range(S.count("eraser")):
		a.append(S.find("eraser"))
		S[S.find("eraser"):6]

if ("dream" in S) and ("erase" in S) == False:
	print("YES")

else:
	print("NO")
 
"""
print(num[0])
print(num[1])
print(num[2])
print(a[0])
print(a[1])
print(a[2])
print(a[3])
"""

Submission status: Wrong Answer

Solution code:
import re
S = input()
a = []
num = []
l = []
re.split("\d+",S)
if ("dream" in S)   == True:
	num.append(S.count("dream"))
	a.append(S.find("dream"))
	S[S.find("dream"):5]

if ("dreamer" in S) == True:
	num.append(S.count("dreamer"))
	a.append(S.find("dreamer"))
	S[S.find("dreamer"):7]

if ("erase" in S)   == True:
	num.append(S.count("erase"))
	a.append(S.find("erase"))
	S[S.find("erase"):5]

if ("eraser" in S)  == True:
	num.append(S.count("eraser"))
	a.append(S.find("eraser"))
	S[S.find("eraser"):6]

if ("dream" in S) and ("erase" in S) == False:
	print("NO")

elif (num[0] or num[1] or num[2] or num[3])> 0:
	print("YES")
 
"""
print(num[0])
print(num[1])
print(num[2])
print(a[0])
print(a[1])
print(a[2])
print(a[3])
"""

Submission status: Wrong Answer

Solution code:
S=input()
n=0
#print(S)
while S[:]!=S[:n]:
    if S[n:n+8]=="dreamer" and S[n:n+9]!="dreamera":
        n+=7 #dreamer
    elif S[n:n+6]=="dream":
        n+=5 #dream
    elif S[n:n+6]=="erase" and S[n+7]!="eraser":
        n+=5 #erase
    elif S[n:n+7]=="eraser":
        n+=6 #eraser
    #elif S[:]==S[:n-1]:
        #print("YES")
        #exit()
    else:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
S=input()
n=0
#print(S)
while S[:]!=S[:n]:
    if S[n:n+7]=="dreamer" and S[n:n+7]!="dreamera":
        n+=7 #dreamer
    elif S[n:n+5]=="dream":
        n+=5 #dream
    elif S[n:n+5]=="erase" and S[n+6]!="eraser":
        n+=5 #erase
    elif S[n:n+6]=="eraser":
        n+=6 #eraser
    #elif S[:]==S[:n-1]:
        #print("YES")
        #exit()
    else:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
S=input()
n=0
#print(S)
while S[:]!=S[:n]:
    if S[n:n+7]=="dreamer" and S[n:n+7]!="dreamera":
        n+=7 #dreamer
    elif S[n:n+5]=="dream":
        n+=5 #dream
    elif S[n:n+5]=="erase" and S[n+6]!="eraser":
        n+=5 #erase
    elif S[n:n+6]=="eraser" and S[n+6]!="a":
        n+=6 #eraser
    #elif S[:]==S[:n-1]:
        #print("YES")
        #exit()
    else:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
S=input()
n=0
#print(S)
while S[:]!=S[:n]:
    if S[n:n+5]=="dream" and S[n:n+7]!="dreamer":
        n+=5
    elif S[n:n+7]=="dreamer":
        n+=7
    elif S[n:n+5]=="erase" and S[n+6]!="eraser":
        n+=5
    elif S[n:n+6]=="eraser":
        n+=6
    #elif S[:]==S[:n-1]:
        #print("YES")
        #exit()
    else:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import re
text = input()
matche_str = re.compile(r'^(dream|dreamer|erase|eraser)+$')
mo = matche_str.search(text)

if mo != None:
    print('yes')
else:
    print('no')

Submission status: Wrong Answer

Solution code:
s = input()

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

print(s)
if s !="":
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
str = ["dream","dreamer","erase","eraser"]
a = S.count(str[1])
b = S.count(str[0]) - a
c = S.count(str[3])
d = S.count(str[2]) - c
if a*6+b*5+c*6+d*5==len(S):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

def solve(S):
    s = S.replace("eraser", "").replace("erase", "").replace("dream", "").replace("dreamer", "")

    if(s==""):
        print("YES")
    else:
        print("NO")
    
if __name__ == '__main__':
    S = input()
  
    solve(S)

Submission status: Wrong Answer

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

def solve(S):
    S.replace("eraser", "").replace("erase", "").replace("dream", "").replace("dreamer", "")
    if(S==""):
        print("YES")
    else:
        print("NO")
    
if __name__ == '__main__':
    S = input()
  
    solve(S)

Submission status: Wrong Answer

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

s = "".join(S[-1::-1].split(l[0][-1::-1]))

for i in range(1, 4):
    s = "".join(s.split(l[i][-1::-1]))

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

Submission status: Wrong Answer

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

s = "".join(S[-1::-1].split(l[0][-1::-1]))

for i in range(1, 4):
    s = "".join(s.split(l[i][-1::-1]))

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

Submission status: Wrong Answer

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

s = "".join(S.split(l[0]))

for i in range(1, 4):
    s = "".join(s.split(l[i]))

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

Submission status: Wrong Answer

Solution code:
import itertools

S = input()
l = ['dream', 'dreamer', 'erase', 'eraser']
data = []

for i in  itertools.permutations(l, 2):
    data.append(i[0] + i[1])

f = False

for d in data:
    if S == d:
        f = True

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

Submission status: Wrong Answer

Solution code:
import sys
S = input()

length = len(S)
i = length

while i > 0:
    if S[i-5:i] == 'dream':
        i -= 5
    elif S[i-6:i] == 'dreamr':
        i -= 6
    elif S[i-5:i] == 'erase':
        i -= 5
    elif S[i-6:i] == 'eraser':
        i -= 6
    else:
        print('NO')
        sys.exit()
    
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
 
x = s.count("dreamerase")
y = s.count("dreameraser")
a = s.count("dreamer") - x - y
b = s.count("dream") - a 
c = s.count("eraser")
d = s.count("erase") - c

if a*7 + b*5 + c*6 + d*5 == len(s):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
 
a = s.count("dreamer")
b = s.count("dream") - a 
c = s.count("eraser")
d = s.count("erase") - c
if a*5 + b*7 + c*5 + 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")
if a*5 + b*7 + c*5 + d*6 == len(s):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
#
# abc049 c
#
s = input()
words = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
while len(s) > 0:
    flag = 0
    for w in words:
        w = w[::-1]
        if s[0:len(w)] == w:
            s = s.replace(w, "").lstrip()
            flag = 1
            break
    if flag == 0:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
#
# abc049 c
#
s = input()
words = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
while len(s) > 0:
    flag = 0
    for w in words:
        w = w[::-1]
        if s[0:len(w)] == w:
            s = s.replace(w, "")
            flag = 1
            break
    if flag == 0:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
#
# abc049 c
#
s = input()
words = ['dream', 'dreamer', 'erase', 'eraser']

while len(s) > 0:
    flag = 0
    for w in words:
        if s[-1 * len(w):] == w:
            s = s.replace(w, "").rstrip()
            flag = 1
            break
    if flag == 0:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
#
# abc049 c
#
s = input()
words = ['dream', 'dreamer', 'erase', 'eraser']

while len(s) > 0:
    flag = 0
    for w in words:
        if s[-1 * len(w):] == w:
            s = s.replace(w, "").rstrip()
            flag = 1
    if flag == 0:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
target = input()
n = 0
result = "YES"
while(n<len(target)):
    if target[n:n+5] in ["dream", "erase"]:
        if target[n:n+7] == "dreamer":
            n += 7
        elif target[n:n+6] == "eraser":
            n += 6
        else:
            n += 5
    elif target[n-2:n+3] in ["erase"]:
        n += 7 - 2
        if target[n-2:n+4] == "eraser":
            n += 5 - 2
    else:
        result = "NO"
        break
print(result)

Submission status: Wrong Answer

Solution code:
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = str(input())
 
inputs = inputs.replace("eraser", "").replace("erase", "")
inputs = inputs.replace("dreamer", "").replace("dream", "")

print(inputs)

if len(list(inputs)) > 0:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = str(input())
 
inputs = inputs.replace("eraser", "").replace("erase", "")
inputs = inputs.replace("dreamer", "").replace("dream", "")

print(inputs)

if len(list(inputs)) > 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = str(input())
 
inputs = inputs.replace("eraser", "").replace("dreamer", "")
inputs = inputs.replace("dream", "").replace("erase", "")

if len(list(inputs)) > 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = list(input())
 
tmp1 = []
 
for i, c in enumerate(reversed(inputs)):
  
  tmp1.append(c)
  
  tmp2 = "".join(reversed(tmp1))
  
  if tmp2 in words:
    #ans.append("".join(tmp2))
    ans.append(tmp2)
    tmp1.clear()
    #tmp2.clear()
    
  if i >= 7 and len(ans) == 0:
    break
 
ans = reversed(ans)
 
if "".join(ans) == "".join(inputs):
  print("YES")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = list(input())
 
tmp1 = []
 
for c in reversed(inputs):
  
  tmp1.append(c)
  
  tmp2 = "".join(reversed(tmp1))
  
  if tmp2 in words:
    #ans.append("".join(tmp2))
    ans.append(tmp2)
    tmp1.clear()
    #tmp2.clear()
 
ans = reversed(ans)
 
if "".join(ans) == "".join(inputs):
  print("YES")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
words = ["dream", "dreamer", "erase", "eraser"]

ans = []

inputs = list(input())

tmp1 = []

for c in reversed(inputs):
  
  tmp1.append(c)
  
  tmp2 = [x for x in reversed(tmp1)]
  
  if "".join(tmp2) in words:
    ans.append("".join(tmp2))
    tmp1.clear()

ans = [x for x in reversed(ans)]

if "".join(ans) == "".join(inputs):
  print("YES")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def main():
  a = input()
  
  flg = "YES"
  index = 0
  while True:
    if index == len(a):
      break
    
    if a.find("dreameraser", index) == index:
      index += len("dreameraser")
    elif a.find("dreamerase", index) == index:
      index += len("dreamerase")
    elif a.find("dreamer", index) == index:
      index += len("dreamer")
    elif a.find("dream", index) == index:
      index += len("dream")
    elif a.find("eraser", index) == index:
      index += len("eraser")
    elif a.find("erase", index) == index:
      index += len("erase")
    else:
      flg = "NO"
      print(a)
      break
      
  print(flg)
  
main()

Submission status: Wrong Answer

Solution code:
def main():
  a = input()
  
  flg = "YES"
  index = 0
  while True:
    if index == len(a):
      break
    
    if a.find("dreameraser", index) == index:
      index += len("dreameraser")
    elif a.find("dreamer", index) == index:
      index += len("dreamer")
    elif a.find("dream", index) == index:
      index += len("dream")
    elif a.find("eraser", index) == index:
      index += len("eraser")
    elif a.find("erase", index) == index:
      index += len("erase")
    else:
      flg = "NO"
      print(a)
      break
      
  print(flg)
  
main()

Submission status: Wrong Answer

Solution code:
import re

s = input()
s = re.sub('eraser', '', s)
s = re.sub('erase', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('dream', '', s)
print(s)
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
import re

s = input()
s = re.sub('dreamer', '', s)
s = re.sub('dream', '', s)
s = re.sub('eraser', '', s)
s = re.sub('erase', '', s)
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
import re
s = input()

s = re.sub('dream', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('erase', '', s)
s = re.sub('eraser', '', s)
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
import re
s = input()

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

Submission status: Wrong Answer

Solution code:
import re
s = input()

re.sub('dream', '', s)
re.sub('dreamer', '', s)
re.sub('erase', '', s)
re.sub('eraser', '', s)
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
import re
s = input()

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

Submission status: Wrong Answer

Solution code:
import re
s = input()

re.sub("dream", '', s)
re.sub("dreamer", '', s)
re.sub("erase", '', s)
re.sub("eraser", '', s)
print('YES 'if len(s) == 0 else '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:
    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:
    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:
    print("YES")
else:
    print("NO")

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 len(s) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# Atcoder C - 白昼夢 / Daydream

s = input()
s = s[::-1]
Word = ["dream","dreamer","erase","eraser"]

m = ""
for i in s:
    m += i
for i in range(len(Word)):
    Word[i] = Word[i][::-1]

can = True
can2 = False
i = 1
while i <= len(s):
    for j in Word:
        if len(s) < len(j):
            pass
        if s[:len(j)].find(j) != -1:
            can2 = True
            i = i + len(j)
    i = i + 1
    if can2 == False:
        can = False
        break

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

Submission status: Wrong Answer

Solution code:
# Atcoder C - 白昼夢 / Daydream

s = input()
s = s[::-1]
Word = ["dream","dreamer","erase","eraser"]

m = ""
for i in s:
    m += i
for i in range(len(Word)):
    Word[i] = Word[i][::-1]

can = True
can2 = False
i = 1
while i <= len(s):
    for j in Word:
        if len(s) < len(j):
            can = False
            break
        if s[:len(j)].find(j) != -1:
            can2 = True
            i = i + len(j)
    i = i + 1
    if can2 == False:
        can = False
        break

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

Submission status: Wrong Answer

Solution code:
# Atcoder C - 白昼夢 / Daydream

s = input()
s = s[::-1]
Word = ["dream","dreamer","erase","eraser"]

m = ""
for i in s:
    m += i
for i in range(len(Word)):
    Word[i] = Word[i][::-1]

can = True
can2 = False
i = 1
while i <= len(s):
    for j in Word:
        if s[:len(j)].find(j) != -1:
            can2 = True
            i = i + len(j)
    i = i + 1
    if can2 == False:
        can = False
        break

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

Submission status: Wrong Answer

Solution code:
S = input()
import re
if re.match("(dream|dreamer|erase|erase)*$", S):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# Atcoder C - 白昼夢 / Daydream

s = input()
s = s[::-1]
Word = ["dream","dreamer","erase","eraser"]

m = ""
for i in s:
    m += i
for i in range(len(Word)):
    Word[i] = Word[i][::-1]

print(s,m)
    
can = False
for i in range(len(s)+1):
    for j in Word:
        if j in s[:i]:
            can = True
            i = i + len(j)

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

Submission status: Wrong Answer

Solution code:
def main():
	S = input()
	pattern_exist = True
	while S:
		if S.startswith("dreamer"):
			if len(S) == 7:
				break
			if S[7:].startswith("dream") or S[7:].startswith("erase"):
				S = S[7:]
				continue
		if S.startswith("dream"):
			S = S[5:]
			continue
		if S.startswith("eraser"):
			if len(S) == 6:
				break
			if S[6:].startswith("dream") or S[7:].startswith("erase"):
				S = S[6:]
				continue
		if S.startswith("erase"):
			S = S[5:]
			continue
		pattern_exist = False
		break
	if pattern_exist:
		print("YES")
	else:
		print("NO")


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
S = input().replace('eraser', '').replace('dreamer', '')
chk = S.replace('erase', '').replace('dream', '')
print(['YES', 'NO'][len(chk) > 0])

Submission status: Wrong Answer

Solution code:
def check(s: str):
  if len(s) >= 5 and s[-5:] in ['dream', 'erase']:
    return s[:-5]
  elif len(s) >= 6 and s[-6:] in ['eraser']:
    return s[:-6]
  elif len(s) >= 7 and s[-7:] in ['dreamer']:
    return s[:-7]
  return None

s = input()
matched = True
while len(s) > 0:
  s = check(s)
  if s is None:
    matched = False
    break
if matched:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
S = input()
reversed_S = "".join(list(reversed(S)))

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

for i in range(len(divide)):
    reversed_divide.append("".join(list(reversed(divide[i]))))

if ('resare' in reversed_S):
    reversed_S = reversed_S.replace('resare', '')
if ('esare' in reversed_S):
    reversed_S = reversed_S.replace('esare', '')
if ('maerd' in reversed_S):
    reversed_S = reversed_S.replace('maerd', '')
if ('remaerd' in reversed_S):
    reversed_S = reversed_S.replace('remaerd', '')
    
if reversed_S:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    T =  'dreamer', 'dream', 'eraser', 'erase'
    for t in T:
        # print(S, t)
        S = S.replace(t, '')

    if len(S) > 0:
        print('NO')
    else:
        print('YES')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    T =  'dream', 'dreamer', 'erase', 'eraser'
    for t in T:
        S = S.strip(t)
    if len(S) > 0:
        ans = 'NO'
    else:
        ans = 'YES'
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    T =  'dream', 'dreamer', 'erase', 'eraser'
    for t in T:
        print(t)
        S = S.strip(t)
    if len(S) > 0:
        ans = 'NO'
    else:
        ans = 'YES'
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
t = ''

for c in s:
  t = t + c
  if t=='maerd' or t=='remaerd' or t=='esare' or t=='resare':
    t = ''

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

Submission status: Wrong Answer

Solution code:
s = input()
while(1):
    if s.endswith('dream'):
        s = s.replace('dream', '')
    elif s.endswith('dreamer'):
        s = s.replace('dreamer', '')
    elif s.endswith('eraser'):
        s = s.replace('eraser', '')
    elif s.endswith('erase'):
        s = s.replace('erase', '')
    else:
        print("NO")
        quit()
    if s == '':
        break
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
while(1):
    if s.endswith('dream'):
        s = s.rstrip('dream')
    elif s.endswith('dreamer'):
        s = s.rstrip('dreamer')
    elif s.endswith('eraser'):
        s = s.rstrip('eraser')
    elif s.endswith('erase'):
        s = s.rstrip('erase')
    else:
        print("NO")
        quit()
    if s == '':
        break
print("YES")

Submission status: Wrong Answer

Solution code:
import sys

def main():
    S = input()

    S = S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')
    print('Yes' if len(S)==0 else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def main():
    S = input()

    S = S.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')
    print('Yes' if len(S)==0 else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def main():
    S = input()

    S = S.replace('dreamer', '').replace('dream', '').replace('erase', '').replace('eraser', '')
    print('Yes' if len(S)==0 else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

S = str(input())
T = ''
d1 = 'dream'
d2 = 'dreamer'
d3 =  'erase'
d4 =  'eraser'

if len(S) < 4:
  print('NO')

i = 0
while len(T) < len(S):
  if S[i:i+5] == 'dream':
    i += 5
    if S[i:i+2] == 'er':
      i += 2
      T += 'dreamer'
    else:
      T += 'dream'
  elif S[0:5] == 'erase':
    i += 5
    if S[5:6] == 'r':
      i += 1
      T += 'eraser'
    else:
      T += 'erase'
  else:
    print('NO')
    sys.exit(0)
  if i == len(S):
    print('YES')
    sys.exit(0)

print('NO')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S = input()

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

for i in range(4):
    try:
        S = S.split(lists[i])
    except:
        pass

S.sort()
S.reverse()

if S[0] == lists[0] or S[0] == lists[1] or S[0] == lists[2] or S[0] == lists[3]:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

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

for i in range(4):
    try:
        S = S.split(lists[i])
    except:
        pass

S.sort()
S.reverse()

if S[0] == lists[0] or S[0] == lists[1] or S[0] == lists[2] or S[0] == lists[3]:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

while s:
    if s[-5:] == d[0] or s[-5:] == d[2]:
        s = s[0:-5]
    elif s[-6:] == d[3]:
        s = s[0:-6]
    elif s[-7:] == d[2]:
        s = s[0:-7]
    else:
        break

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

Submission status: Wrong Answer

Solution code:
s=input()
ans=1
i=0
while 1:
  if i>=len(s):
    break
  if s[i:i+5]=="dream":
    i+=5
  elif s[i:i+5]=="erase":
    if s[i:i+6]=="eraser":
      i+=6
    else:
      i+=5
  elif s[i:i+2]=="er":
    i+=2
  else:
    ans=0
    break
if ans:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

while len(s) > 5:
  flag = False
  if s[-5:] == "dream":
    s = s[:-5]
    flag = True
  elif s[-5:] == "erase":
    s = s[:-5]
    flag = True
  elif s[-6:] == "dreamer":
    s = s[:-6]
    flag = True
  elif s[-6:] == "eraser":
    s = s[:-6]
    flag = True

  if flag == False:
    break


if s == 'dream':
  s = ""
elif s == 'erase':
  s = ""
elif s == "dreamer":
  s = ""
elif s == "eraser":
  s = ""
  
if (len(s)==0):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

while len(s) > 0:
  flag = False
  if s[-5:] == "dream":
    s = s[:-5]
    flag = True
  elif s[-5:] == "erase":
    s = s[:-5]
    flag = True
  elif s[-6:] == "dreamer":
    s = s[:-6]
    flag = True
  elif s[-6:] == "eraser":
    s = s[:-6]
    flag = True

  if flag == False:
    break


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

Submission status: Wrong Answer

Solution code:
s = input()

while len(s) > 0:
  flag = False
  if s[-5:] == "dream":
    s = s[:-5]
    flag = True
  elif s[-5:] == "erase":
    s = s[:-5]
    flag = True
  if s[-6:] == "dreamer":
    s = s[:-6]
    flag = True
  elif s[-6:] == "eraser":
    s = s[:-6]
    flag = True

  if flag == False:
    break


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

Submission status: Wrong Answer

Solution code:
S = input()

# Sから文字を抜いていって、空文字列になればいいはず
S = S.replace("dreamer", "")
S = S.replace("dream", "")
S = S.replace("eraser", "")
S = S.replace("erase", "")


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

Submission status: Wrong Answer

Solution code:
S = input()

# Sから文字を抜いていって、空文字列になればいいはず
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")

if (len(S) == 0) :
    print("Yes")
else :
    print("No")