Problem:


Score : 300 points

Problem Statement

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

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

Constraints

1≦|S|≦10^5

S consists of lowercase English letters.

Input

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

S

Output

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

Sample Input 1

erasedream

Sample Output 1

YES

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

Sample Input 2

dreameraser

Sample Output 2

YES

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

Sample Input 3

dreamerer

Sample Output 3

NO



Sample input:
erasedream


Sample output:
YES

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    N = len(S)
    ok = set(['dream','erase','dreamer','eraser'])
    if N < 6 and S not in ok:
        print("NO")
        exit()
    i = 0
    while i < N-5:
        tmp = S[i:i+5]
        if tmp == 'dream':
            if i+6 < N and S[i+5:i+7] == 'er':
                i += 7
            else:
                i += 5
        elif tmp == 'erase':
            if i+5<N and S[i+5] == 'r':
                i += 6
            else:
                i += 5
        else:
            print('NO')
            exit()
    if S[i:] not in ok:
        print('NO')
        exit()
    print('YES')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    N = len(S)
    ok = set(['dream','erase','dreamer','eraser'])
    if N < 6 and S not in ok:
        print("NO")
        exit()
    i = 0
    while i < N-5:
        tmp = S[i:i+5]
        if tmp in ok:
            if i+5 < N and S[i+5] == 'r':
                i += 6
            else:
                i += 5
        else:
            print('NO')
            exit()
    if S[i:] not in ok:
        print('NO')
        exit()
    print('YES')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    N = len(S)
    i = 0
    ok = set(['dream','erase','dreamer','eraser'])
    while i < N-5:
        tmp = S[i:i+5]
        if tmp in ok:
            if i+5 < N and S[i+5] == 'r':
                i += 6
            else:
                i += 5
        else:
            print('NO')
            exit()
    if S[i:] not in ok:
        print('NO')
        exit()
    print('YES')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

l5 = ["dream"[::-1], "erase"[::-1]]
l6 = ["dreamer"[::-1], "eraser"[::-1]]

ans = "YES"

while len(s) > 4:
    if s[:5] in l5:
        s = s[5:]
    elif s[:6] in l6:
        s = s[6:]
    else:
        ans = "NO"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
S=input()

for i in range(10000):
  if S[-7:]=="dreamer":
    S=S[:-7]
  elif S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S=="":
    print("YES")
    break
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S=input()

for i in range(10000):
  if S[-7:]=="dreamer":
    S=S[:-7]
  elif S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S==[]:
    print("YES")
    break
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S=input()

for i in range(10000):
  if S[-6:]=="dreamer" or S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S==[]:
    print("YES")
    break
else:
  print("NO")

Submission status: Wrong Answer

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

kari = ['dream', 'dreamer', 'erase', 'eraser']
 
words = [i[::-1] for i in kari]
 
l = len(S)
cnt = ''

for i in range(l):
    cnt += S[i]
    if cnt in words:
        cnt = ''

if cnt!='':
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

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

words = [i[::-1] for i in kari]

l = len(S)
i = 0

while True:
    if S[i:i+5]==words[0] or S[i:i+5]==words[2]:
        i += 5
    elif S[i:i+6]==words[3]:
        i += 6
    elif S[i-7:i+7]==words[1]:
        i += 7
    else:
        print('NO')
        exit()
    if i == l:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
#049_C
s = input()

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

Submission status: Wrong Answer

Solution code:
#049_C
s = input()

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

Submission status: Wrong Answer

Solution code:
#049_C
s = input()

s = s.replace('dream', '').replace('dreamr', '').replace('erase', '').replace('eraser', '')
print('YES' if s == '' else 'NO')

Submission status: Wrong Answer

Solution code:
s=input()
s1=s.replace("eraser","0").replace("erase","0").replace("dreamer","0").replace("dream","0")
n=len(s1)
flag=False
for  i in range(0,n):
    if s1[i]!='0':
        flag=True
        break
        
if flag==False:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = input()
u = ['dreamer', 'eraser', 'dream', 'erase']
while s:
    start = len(s)
    for i in u:
        if s[-len(i):len(s)] == i:
            s = s[:len(s)-len(i)]
    if start == len(s):
        print('No')
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
u = ['dreamer', 'eraser', 'dream', 'erase']
while len(s) > 0:
    for i in u:
        if s[-len(i):len(s)] == i:
            s = s.rstrip(i)
            break
    else:
        print('No')
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
u = ['dreamer', 'eraser', 'dream', 'erase']
while len(s) > 0:
    for i in u:
        if s[-len(i):-0] == i:
            s = s.rstrip(i)
            break
    else:
        print('No')
        exit()
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
res = "Yes"
while s:
  start = len(s)
  for t in ['maerd', 'remaerd', 'esare', 'resare']:
    if t == s[:len(t)]:
      s = s[len(t):]
  if start == len(s):
    res = "No"
    break
print(res)

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
s=str(input())
s=s[::-1]
print(s)
stack=""
for i in s:
  stack=i+stack
  if stack=="dream"or stack=="dreamer"or stack=="erase"or stack=="eraser":
    stack=""
  elif len(stack)>7:
    print("NO")
    exit()
print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input().replace('eraser', '').replace('erace', '').replace('dreamer', '').replace('dream', '')
if s:
    print('no')
else:
    print('yes')

Submission status: Wrong Answer

Solution code:
txt = input()
cands = ["dream", "dreamer", "erase", "eraser"]

success = True
while len(txt) > 0:
    flag = False

    for cand in cands:
        subtxt = txt[len(txt) - len(cand):]
        if subtxt == cand:
            txt = txt[:len(txt) - len(cand)]
            flag = True
            break

    if not flag:
        success = False
        break

if success:
    print("YES")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import re
s = input()
if re.fullmatch(r"(dream|dreamer|erase|eraser)+",s):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

while(1):
    for i in temp:
        if S.startswith(i):
            S = S.replace(i, '')
            break
    else:
        break
if len(S) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

while(1):
    for i in temp:
        if S.startswith(i):
            S = S.lstrip(i)
            break
    else:
        break

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

Submission status: Wrong Answer

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

while(1):
    for i in temp:
        if S.startswith(i):
            S = S.lstrip(i)
            break
    else:
        break

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

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    dp = ["*"]*(len(s)+10)
    dp[0] = True
    for i in range(len(s)):
        if s[i:i+5] == "dream" and (dp[i] == "*" or dp[i] == True):
            for j in range(i, i+5):
                dp[j] = True
        if s[i:i+7] == "dreamer" and (dp[i] == "*" or dp[i] == True):
            for j in range(i, i+7):
                dp[j] = True
        if s[i:i+5] == "erase" and (dp[i] == "*" or dp[i] == True):
            for j in range(i, i+5):
                dp[j] = True
        if s[i:i+6] == "eraser" and (dp[i] == "*" or dp[i] == True):
            for j in range(i, i+6):
                dp[j] = True
    print("YES" if dp[len(s)-1] == True else "NO")
main()

Submission status: Wrong Answer

Solution code:
s = input()
ans = "YES"
while s != "":
    if len(s) < 5:
        ans = "NO"
        break
    elif s[len(s) - 5:] == "dream" or s[len(s) - 5:] == "erase":
        s = s[:len(s) - 5]
    elif s[len(s) - 6:] == "eraser":
        s = s[:len(s) - 6]
    elif s[len(s) - 7] == "dreamer":
        s = s[:len(s) - 7]
    else:
        ans = "NO"
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = str(input())

while len(S) > 0:
  if S[-5:] == 'dream' or S[-5:] == 'erase':
    S = S[:-5]
  elif S[-7:] == 'dreamer' or S[-7:] == 'eraser':
    S = S[:-7]
  else:
    break

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

Submission status: Wrong Answer

Solution code:
s = input()
d = { "eam":5, "mer":7, "ase":5, "ser":6}
index = len(s)
while index != 0:
  tmp = s[index-3:index]
  if tmp not in d.keys():
    break
  index -= d[tmp]
  if index < 0:
    break
else:
  print("YES")
  exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
d = { "eam":5, "mer":7, "ase":5, "ser":6}
index = len(s)
while index != 0:
  tmp = s[index-3:index]
  if tmp not in d.keys():
    break
  index -= d[tmp]
else:
  print("YES")
  exit()
print("NO")

Submission status: Wrong Answer

Solution code:
def main():
  s = input()
  dream = False
  erase = False

  while s:
    if s.startswith('dream'):
      s = s[5:]
      dream = True
      erase = False
    elif s.startswith('erase'):
      s = s[5:]
      dream = False
      erase = True
    elif s.startswith('er') and dream:
      s = s[2:]
      dream = False
    elif s.startswith('r') and erase:
      s = s[1:]
      erase = False
    else:
      return False
  
  return True

if main():
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
text = "".join(reversed(input()))
words = map(lambda word: "".join(reversed(word)), ["dreamer", "dream", "eraser", "erase"])

for word in words:
  text = text.replace(word, " ")

print("YES" if text.strip() == "" else "NO")

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)
c = 0
dream = list("dream")
dreamer = list("dreamer")
erase = list("erase")
eraser = list("eraser")
while True:
    if S[c:c + 5] == dream:
        c += 5
        if S[c:c + 5] != erase and S[c:c + 2] == list("er"):
            c += 2
        if c == N:
            print("YES")
            break
    elif S[c:c + 5] == erase:
        c += 5
        if S[c:c + 1] == "r":
            c += 1
        if c == N:
            print("YES")
            break
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)
c = 0
dream = list("dream")
dreamer = list("dreamer")
erase = list("erase")
eraser = list("eraser")
while True:
    if S[c:c + 5] == dream:
        c += 5
        if S[c:c + 5] != erase and S[c:c + 2] == list("er"):
            c += 2
        if c == N:
            print("YES")
            break
    elif S[c:c + 5] == erase:
        c += 5
        if S[c:c + 1] == "r":
            c += 1
        if c == N:
            print("YES")
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
S=input()
T=["dream","dreamer","erase","eraser"]
S=S.replace(T[3],"").replace(T[2],"").replace(T[1],"").replace(T[0],"")
if S=="":
    print("YRS")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
T=["dream","dreamer","erase","eraser"]
S=S.replace(T[3],"").replace(T[2],"").replace(T[1],"").replace(T[0],"")
if S=="":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import re
print("Yes" if re.match("^(dream|dreamer|erase|eraser)+$",input()) else "No")

Submission status: Wrong Answer

Solution code:
import re
print("Yes" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "No")

Submission status: Wrong Answer

Solution code:
import re

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

Submission status: Wrong Answer

Solution code:
import re

S = str(input())

print("Yes" if re.match("^(dream|dreamer|erase|eraser)+$", S) else "No")

Submission status: Wrong Answer

Solution code:
s = input()
ans = "YES"

while (len(s) - 5) > 2:
    c = s[-5:]
    if (c == "dream"):
        s = s[ : 5]
    else:
        if (c == "erase"):
            s = s[: 5]
        else:
            c = s[-6:]
            if (c == "eraser"):
                s = s[: 5]
            else:
                c = s[-7:]
                if (c == "dreamer"):
                    s = s[: 5]
                else:
                    ans = "NO"
                    break

                    
if s != "dream":
    if s != "erase":
        if s != "dreamer":
            if s != "eraser":
                ans = "NO"

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = "YES"

while (len(s) - 5) > 2:
    c = s[-5:]
    if (c == "dream"):
        s = s[ : 5]
    else:
        if (c == "erase"):
            s = s[: 5]
        else:
            c = s[-6:]
            if (c == "eraser"):
                s = s[: 6]
            else:
                c = s[-7:]
                if (c == "dreamer"):
                    s = s[: 7]
                else:
                    ans = "NO"
                    break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
u = ['dreamer', 'eraser', 'dream', 'erase']
while len(s) > 0:
    for i in u:
        if s[0:len(i)] == i:
            s = s.lstrip(i)
            break
    else:
        print('No')
        exit()
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
u = ['dreamer', 'eraser', 'dream', 'erase']
while len(s) > 0:
    for i in u:
        if s[0:len(i)] == i:
            s = s.lstrip(i)
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
#input
S = input()
S = S.replace('eraser','') # 文字列の置き換えeraser を空文字に
S = S.replace('erase','')
S = S.replace('dreamer','')
S = S.replace('dream','')

#
if S:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
S = input()
S = S.replace('eraser','') # 文字列の置き換え
S = S.replace('erase','')
S = S.replace('dream','')
S = S.replace('dreamer','')

if S:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()
while True:
	S = s
	if len(S) < 5:
		print('NO')
		break
	if S == 'dream' or S == 'erase':
		print('YES')
		break
	else:
		if S[0] == 'd':
			if S[7] == 'a':
				T ='dream'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'dreamer'
				if S[:7] == T:
					S = S[7:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		if S[0] == 'e':
			if len(S) >= 6 and S[5] == 'r':
				T = 'eraser'
				if S[:6] == T:
					S = S[6:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'erase'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		else:
			print('NO')
			break

Submission status: Wrong Answer

Solution code:
s = input()
while True:
	S = s
	if len(S) < 5:
		print('NO')
		break
	if S == 'dream' or S == 'erase':
		print('YES')
		break
	else:
		if S[0] == 'd':
			if S[7] == 'a':
				T ='dream'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'dreamer'
				if S[:7] == T:
					S = S[7:]
					T = ""
					if S == "":
						print('Yes')
						break
					s = S
				else:
					print('NO')
					break
		if S[0] == 'e':
			if len(S) >= 6 and S[5] == 'r':
				T = 'eraser'
				if S[:6] == T:
					S = S[6:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'erase'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		else:
			print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
while True:
	S = s
	if len(S) < 5:
		print('No')
		break
	if S == 'dream' or S == 'erase':
		print('Yes')
		break
	else:
		if S[0] == 'd':
			if S[7] == 'a':
				T ='dream'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('Yes')
						break
					s = S
				else:
					print('No')
					break
			else:
				T = 'dreamer'
				if S[:7] == T:
					S = S[7:]
					T = ""
					if S == "":
						print('Yes')
						break
					s = S
				else:
					print('No')
					break
		if S[0] == 'e':
			if len(S) >= 6 and S[5] == 'r':
				T = 'eraser'
				if S[:6] == T:
					S = S[6:]
					T = ""
					if S == "":
						print('Yes')
						break
					s = S
				else:
					print('No')
					break
			else:
				T = 'erase'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('Yes')
						break
					s = S
				else:
					print('No')
					break
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
#ABC049

s = input()

while len(s) != 0:
    
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        print("NO")
        break
print("YES")

Submission status: Wrong Answer

Solution code:
#ABC049

s = input()

while len(s) != 0:
    
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        print("NO")
        break
    print("YES")

Submission status: Wrong Answer

Solution code:
S=input()

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

Submission status: Wrong Answer

Solution code:
S=input()

S=S.replace('eraser','')
S=S.replace('erase','')
S=S.replace('dreamer','')
S=S.replace('dream','')
if S=='':
  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 S=='':
  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 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 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 s=='':
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
s=input()
s=s[::-1]
voc=['dream','dreamer','erase','eraser']
for i in range(len(voc)):
  voc[i]=voc[i][::-1]
while True:
  flag=False
  for v in voc:
    if s[:len(v)]==v:
      s=s[len(v):]
      flag=True
  if s=='':
    print('Yes')
    break
  elif not flag:
    print('No')
    break

Submission status: Wrong Answer

Solution code:
S = input()

while True:
    if S[-3:] == "mer": 
        S = S[:-7]
    elif S[-3:] == "ser": 
        S = S[:-6]
    elif S[-3:] == "eam": 
        S = S[:-5]
    elif S[-3:] == "ase": 
        S = S[:-5]
    else:
        break
print("NO") if S else print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
while True:
    if S[-3:] == "mer": 
        S = S.replace("dreamer", "")
    elif S[-3:] == "ser": 
        S = S.replace("eraser", "")
    elif S[-3:] == "eam": 
        S = S.replace("dream", "")
    elif S[-3:] == "ase": 
        S = S.replace("erase", "")
    else:
        break
print("NO") if S else print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
while True:
    ma = S.find("dream")
    re = S.find("dreamer")
    es = S.find("erase")
    res = S.find("eraser")
    if max(ma, re, es, res) == -1:
        break
    elif re == max(ma, re, es, res):
        S = S.replace("dreamer", "")
    elif res == max(ma, re, es, res):
        S = S.replace("eraser", "")
    elif ma == max(ma, re, es, res):
        S = S.replace("dream", "")
    elif es == max(ma, re, es, res):
        S = S.replace("erase", "")
    else:
        break
print("NO") if S else print("YES")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
while True:
    ma = S.find("maerd")
    re = S.find("remaerd")
    es = S.find("esare")
    res = S.find("resare")
    if ma>=0:
        S = S.replace("maerd","")
    elif re>=0:
        S = S.replace("remaerd","")
    elif es>=0:
        S = S.replace("esare","")
    elif res>=0:
        S = S.replace("resare","")
    else:
        break
print("NO") if S else print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
div = ['maerd', 'remaerd', 'esare', 'resare']
s = input()
rs = ''.join(list(reversed(s)))

can1 = True
cnt = 0
for i in range(len(s)):
    if cnt != 0:
        cnt -= 1
        continue
    can2 = False 
    for d in range(len(div)):
        if (rs.find(div[d])) == i:
            can2 = True
            cnt = len(div[d]) -1
    if can2 == False:
        can1 = False

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

Submission status: Wrong Answer

Solution code:
div = ['maerd', 'remaerd', 'esare', 'resare']
s = input()
rs = ''.join(list(reversed(s)))

can1 = True
cnt = 0
for i in range(len(s)):
    if cnt != 0:
        cnt -= 1
        continue
    can2 = False 
    for d in range(len(div)):
        if (rs.find(div[d])) == i:
            can2 = True
            cnt = len(div[d]) -1
    if can2 == False:
        can1 = False

if can1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
div = ['maerd', 'remaerd', 'esare', 'resare']
s = input()
rs = ''.join(list(reversed(s)))

can1 = True
cnt = 0
for i in range(len(s)):
    if cnt != 0:
        cnt -= 1
        continue
    print(i)
    can2 = False 
    for d in range(len(div)):
        if (rs.find(div[d])) == i:
            can2 = True
            cnt = len(div[d]) -1
    if can2 == False:
        can1 = False

if can1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()

while(len(s)!=0):
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:]== 'eraser':
        s = s[:-6]
    elif s[-7:]=='dreamer':
        s = s[:-7]
    else:
        print('N0')
        break
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
flag = True
while(flag):
    if(len(s)==0):
        flag = False
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:]== 'eraser':
        s = s[:-6]
    elif s[-7:0]=='dreamer':
        s = s[:-7]
    else:
        break
if(flag):
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

while(len(s)!=0):
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:]== 'eraser':
        s = s[:-6]
    elif s[-7:0]=='dreamer':
        s = s[:-7]
    else:
        print('N0')
        break
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

while(len(s)!=0):
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:]== 'eraser':
        s = s[:-6]
    elif s[-7:0]=='dreamer':
        s = s[:-7]
    else:
        print('N0')
        break
print('YES')

Submission status: Wrong Answer

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

s = readline().rstrip().decode('utf-8')
n = len(s)
l = tuple(["dreamer","dream","eraser", "erase"])

i=0
while i < n:
    flag = 0
    for j in range(4):
        if i+len(l[j]) <= n and s[i:i+len(l[j])] == l[j]:
            if j==0 and s[len(l[j])]=="a":
                j = 1
            i += len(l[j])
            flag = 1
            break
    if not flag:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
# 動的計画法(DP)
s=input()
words = {"dream", "dreamer", "erase", "eraser"}

dp = dict()
for i in range(0, len(s)):
    if not dp.get(i):
        continue
    for word in words:
        if s[i:i+len(word)] == word:
            dp[i+len(word)] = 1

print("YES" if dp.get(len(s)) else "NO")

Submission status: Wrong Answer

Solution code:
# 動的計画法(DP)
s=input()
words = {"dream", "dreamer", "erase", "eraser"}

dp = dict()
for i in range(0, len(s)):
    for word in words:
        if s[i:i+len(word)] == word:
            dp[i+len(word)] = 1

print("YES" if dp.get(len(s)) else "NO")

Submission status: Wrong Answer

Solution code:
s = input()

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

import re
def setudan(s):
  if s[-5:] == 'dream' or s[-5:] == 'erase':
    return s[:-5]
  elif s[-6:] == 'eraser':
    return s[:-6]
  elif s[-7:] == 'dreamer':
    return s[:-7]
  else:
    return 0

while True:
  s = setudan(s)
  if s == 0:
    print('No')
    break
  if s =='':
    print('Yes')
    break

Submission status: Wrong Answer

Solution code:
S0 = input()
S = S0[::-1]
cands = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
i = 0
while i < len(S):
  for word in cands:
    #print(S[i:],word)
    if S[i:].startswith(word):
    	i += len(word)
    	continue
  print("NO")
  exit(0)
#print(i)
if i == len(S):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S0 = input()
S = S0[::-1]
cands = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
i = 0
while i < len(S):
  for word in cands:
    #print(S[i:],word)
    if S[i:].startswith(word):
    	i += len(word)
    	continue
#print(i)
if i == len(S):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
S0 = input()
S = S0[::-1]
cands = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
i = 0
while i < len(S):
  for word in cands:
    #print(S[i:],word)
    if S[i:].startswith(word):
    	i += len(word)
    	continue
#print(i)
if i == len(S):
  print("True")
else:
  print("False")

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc049/tasks/arc065_a
# なんかこの問題知ってる気がする
# 前方向から貪欲にマッチしようとすると,dreamer なのか dream eraser なのかわかりにくい
# しかし後ろ三文字を見ると、eam,mer,ase,serと一意に決定できる。よって逆方向から貪欲にマッチングさせると即座に構成可能か判別できる

S = input()

i = len(S)
while i - 3 > 0:
    tri = S[i - 3:i]
    if tri == 'eam' or tri == 'ase':
        i -= 5
    elif tri == 'mer':
        i -= 7
    elif tri == 'ser':
        i -= 6
    else:
        print('NO')
        exit()

if i == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc049/tasks/arc065_a
# なんかこの問題知ってる気がする
# 前方向から貪欲にマッチしようとすると,dreamer なのか dream eraser なのかわかりにくい
# しかし後ろ三文字を見ると、eam,mer,ase,serと一意に決定できる。よって逆方向から貪欲にマッチングさせると即座に構成可能か判別できる

S = input()

i = len(S)
while i > 0:
    tri = S[i - 3:i]
    if tri == 'eam' or tri == 'ase':
        i -= 5
    elif tri == 'mer':
        i -= 7
    elif tri == 'ser':
        i -= 6
    else:
        print('NO')
        exit()

print('YES')

Submission status: Wrong Answer

Solution code:
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
MOD = 10 ** 9 + 7


S = input()
S = ''.join(list(reversed(S)))
while len(S) > 0:
    if S[:6] in ['resare', 'remaerd']:
        S = S[6:]
    elif S[:5] in ['esare', 'maerd']:
        S = S[5:]
    else:
        print('NO')
        exit(0)
print('YES')