Problem:


Score : 300 points

Problem Statement

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

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

Constraints

1≦|S|≦10^5

S consists of lowercase English letters.

Input

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

S

Output

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

Sample Input 1

erasedream

Sample Output 1

YES

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

Sample Input 2

dreameraser

Sample Output 2

YES

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

Sample Input 3

dreamerer

Sample Output 3

NO



Sample input:
erasedream


Sample output:
YES

Submission status: Wrong Answer

Solution code:
s = input()

bool = [False]

def hantei(s):
    # print(s)
    if s=='':
        bool[0]=True
        return

    if s.count('dream')>=1:
        r=s.replace('dream','')
        hantei(r)

    if s.count('dreamer')>=1:
        r=s.replace('dreamer','')
        hantei(r)

    if s.count('erase')>=1:
        r=s.replace('erase','')
        hantei(r)

    if s.count('eraser')>=1:
        r=s.replace('eraser','')
        hantei(r)
    return

hantei(s)
        

if bool[0]==True:
    print('Yes')

if bool[0]==False:
    print('No')

Submission status: Wrong Answer

Solution code:
strings = ['eraser','erase','dream' ,'dreamer' ]
# strings = [s[::-1] for s in strings]

S = str(input())
# S = S[::-1]
# print(S,strings)
for s in strings:
    S = S.replace(s, "")

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

Submission status: Wrong Answer

Solution code:
import sys
# N,M = [int(n) for n in input().split()]

# T = str(input())
# a,b,c = [int(n) for n in input().split()]

strings = ['eraser','erase','dream' ,'dreamer' ]
strings = [s[::-1] for s in strings]

S = str(input())
S = S[::-1]
for s in strings:
    S = S.replace(s, "")

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

Submission status: Wrong Answer

Solution code:
strings = ['eraser','erase','dream' ,'dreamer' ]
strings = [s[::-1] for s in strings]

S = str(input())
S = S[::-1]
for s in strings:
    S = "".join(S.split(s))
if S == "":
    print('YES')
else:
    print("NO")

Submission status: Wrong Answer

Solution code:

strings = ['eraser','erase','dream' ,'dreamer' ]
strings = [s[::-1] for s in strings]

S = str(input())
S = S[::-1]
for s in strings:
    S = "".join(S.split(s))
if S == "":
    print('YES')
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

cnt = 0
j = len(S) - 1

for i in range(len(S)-1, -1, -1):
    if j-1 > len("dreamer"):
        break
    for dd in ("dream", "dreamer", "erase", "eraser"):
        if S[i:j+1] == dd:
            j = i-1
            cnt += len(dd)

print(("NO", "YES")[len(S) == cnt])

Submission status: Wrong Answer

Solution code:
S = input()

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

for s in partstrs:
    S = S.replace(s , "") 
if S=="":
    print("YES")
else:
    print("N")

Submission status: Wrong Answer

Solution code:
S = input()

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

for s in partstrs:
    S = S.replace(s , "") 
if S=="":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = input()
i = 0
n = len(s)
p = 0
while i < n:
    if i == 0:
        if s[i] == "d":
            if i + 5 <= n:
                if s[i:i+5] == "dream":
                    i = i + 5
                    if i + 5 < n:
                        if s[i] != "e" and s[i] != "d":
                            print("NO")
                            exit()
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "e":
            if i + 2 <= n:
                if s[i:i+2] == "er":
                    i = i + 1
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    else:
        if s[i] == "d":
            if i + 5 <= n:
                if s[i:i+5] == "dream":
                    i = i + 5
                    if i + 5 < n:
                        if s[i] == "e" or s[i] == "d":
                            print("NO")
                            exit()
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "e":
            if i + 2 <= n:
                if s[i:i+2] == "er":
                    i = i + 1
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "r":
            if s[i - 5: i + 1] == "eraser" and i - 5 >= 0:
                if s[i - 2] != "r":
                    if i + 1 < n:
                        if s[i + 1] == "d":
                            i = i + 1
                        elif s[i + 1] == "e":
                            i = i + 1
                        else:
                            print("NO")
                            exit()
                        #p = 1
                    else:
                        print("YES")
                        exit()
            elif i + 4 <= n:
                if s[i - 2] != "r":
                    if i + 1 < n:
                        if s[i + 1] == "d":
                            i = i + 1
                        elif s[i + 1] == "e":
                            i = i + 1
                        p = 1
                    else:
                        print("YES")
                        exit()
                if s[i:i+4] == "rase":
                    i = i + 4
                    p = 1
                if p == 0:
                    print("NO")
                    exit()
            elif s[i - 2] != "r":
                if i + 1 < n:
                    if s[i + 1] == "d":
                        i = i + 1
                    elif s[i + 1] == "e":
                        i = i + 1
                    else:
                        print("NO")
                        exit()
                else:
                    print("YES")
                    exit()
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    p = 0
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
i = 0
n = len(s)
p = 0
while i < n:
    if i == 0:
        if s[i] == "d":
            if i + 5 <= n:
                if s[i:i+5] == "dream":
                    i = i + 5
                    if i + 5 < n:
                        if s[i] != "e" and s[i] != "d":
                            print("NO")
                            exit()
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "e":
            if i + 2 <= n:
                if s[i:i+2] == "er":
                    i = i + 1
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    else:
        if s[i] == "d":
            if i + 5 <= n:
                if s[i:i+5] == "dream":
                    i = i + 5
                    if i + 5 < n:
                        if s[i] == "e" or s[i] == "d":
                            print("NO")
                            exit()
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "e":
            if i + 2 <= n:
                if s[i:i+2] == "er":
                    i = i + 1
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "r":
            if i - 5 >= 0:
                if s[i - 5: i + 1] == "eraser":
                    if s[i - 2] != "r":
                        if i + 1 < n:
                            if s[i + 1] == "d":
                                i = i + 1
                            elif s[i + 1] == "e":
                                i = i + 1
                            else:
                                print("NO")
                                exit()
                            #p = 1
                        else:
                            print("YES")
                            exit()
            elif i + 4 <= n:
                if s[i - 2] != "r":
                    if i + 1 < n:
                        if s[i + 1] == "d":
                            i = i + 1
                        elif s[i + 1] == "e":
                            i = i + 1
                        p = 1
                    else:
                        print("YES")
                        exit()
                if s[i:i+4] == "rase":
                    i = i + 4
                    p = 1
                if p == 0:
                    print("NO")
                    exit()
            elif s[i - 2] != "r":
                if i + 1 < n:
                    if s[i + 1] == "d":
                        i = i + 1
                    elif s[i + 1] == "e":
                        i = i + 1
                    else:
                        print("NO")
                        exit()
                else:
                    print("YES")
                    exit()
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    p = 0
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
i = 0
n = len(s)
p = 0
while i < n:
    if i == 0:
        if s[i] == "d":
            if i + 5 <= n:
                if s[i:i+5] == "dream":
                    i = i + 5
                    if i + 5 < n:
                        if s[i] != "e" and s[i] != "d":
                            print("NO")
                            exit()
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "e":
            if i + 2 <= n:
                if s[i:i+2] == "er":
                    i = i + 1
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    else:
        if s[i] == "d":
            if i + 5 <= n:
                if s[i:i+5] == "dream":
                    i = i + 5
                    if i + 5 < n:
                        if s[i] == "e" or s[i] == "d":
                            print("NO")
                            exit()
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "e":
            if i + 2 <= n:
                if s[i:i+2] == "er":
                    i = i + 1
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
        elif s[i] == "r":
            if s[i - 5: i + 1] == "eraser":
                if s[i - 2] != "r":
                    if i + 1 < n:
                        if s[i + 1] == "d":
                            i = i + 1
                        elif s[i + 1] == "e":
                            i = i + 1
                        else:
                            print("NO")
                            exit()
                        p = 1
                    else:
                        print("YES")
                        exit()
            elif i + 4 <= n:
                if s[i - 2] != "r":
                    if i + 1 < n:
                        if s[i + 1] == "d":
                            i = i + 1
                        elif s[i + 1] == "e":
                            i = i + 1
                        p = 1
                    else:
                        print("YES")
                        exit()
                if s[i:i+4] == "rase":
                    i = i + 4
                    p = 1
                if p == 0:
                    print("NO")
                    exit()
            elif s[i - 2] != "r":
                if i + 1 < n:
                    if s[i + 1] == "d":
                        i = i + 1
                    elif s[i + 1] == "e":
                        i = i + 1
                    else:
                        print("NO")
                        exit()
                else:
                    print("YES")
                    exit()
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    p = 0
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
str_list = ["dream","dreamer","erase","eraser"]
for i in range(len(s) // 5):
    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]
ans = "YES" if s == "" else "No"
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
str_list = ["dream","dreamer","erase","eraser"]
for i in range(len(s) // 5):
    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]
ans = "YES" if s == "" else "No"
print(ans)

Submission status: Wrong Answer

Solution code:
rules = ['dream', 'dreamer', 'erase', 'eraser']

s = input()
stack = [0]
mem = [0]
ok = False
loop = 0
while len(stack) > 0:
    loop += 1
    #print(stack, mem)
    start_id = stack.pop()
    string = s[start_id:]
    if start_id == len(s):
        print('YES')
        ok = True
        break

    for rule in rules:
        if string.startswith(rule):
            next_start_id = start_id + len(rule)
            if next_start_id <= len(s):
                part = string[next_start_id:]
                if part.startswith('d') or part.startswith('e') or part == '':
                    if next_start_id not in mem:
                        stack.append(next_start_id)
                        mem.append(next_start_id)
if not ok:
    print('NO')

#print(loop)

Submission status: Wrong Answer

Solution code:
rules = ['dream', 'dreamer', 'erase', 'eraser']

s = input()
stack = [0]
mem = [0]
ok = False
while len(stack) > 0:
    start_id = stack.pop()
    string = s[start_id:]
    if string == '':
        print('YES')
        ok = True
        break
    for rule in rules:
        if string.startswith(rule):
            next_start_id = start_id + len(rule)
            if next_start_id <= len(s):
                part = string[next_start_id:]
                if part.startswith('d') or part.startswith('e') or part == '':
                    if next_start_id not in mem:
                        stack.append(next_start_id)
                        mem.append(next_start_id)
if not ok:
    print('NO')

Submission status: Wrong Answer

Solution code:
rules = ['dream', 'dreamer', 'erase', 'eraser']

s = input()
stack = [0]
mem = [0]
ok = False
while len(stack) > 0:
    start_id = stack.pop()
    string = s[start_id:]
    if string == '':
        print('YES')
        ok = True
        break
    for rule in rules:
        if string.startswith(rule):
            next_start_id = start_id + len(rule)
            if next_start_id < len(s):
                part = string[next_start_id:]
                if part.startswith('d') or part.startswith('e'):
                    if part not in mem:
                        stack.append(next_start_id)
                        mem.append(next_start_id)
if not ok:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
#L = ['dream', 'dreamer', 'erase', 'eraser']
L = ['eraser', 'erase', 'dreamer', 'dream']
cnt=0 
while len(S):
  for item in L:
    if S[-3:] == item[-3:]:
      S = S[:-1*len(item)]
  cnt+=1
  if len(S) == 0:
    print("YES")
  if cnt > 100001:
    print("NO")
    exit(0)

Submission status: Wrong Answer

Solution code:
S = input()
L = ['dream', 'dreamer', 'erase', 'eraser']
cnt=0
while len(S):
  for item in L:
    if S[-3:] == item[-3:]:
      S = S[:-1*len(item)]
  cnt+=1
  if len(S) == 0:
    print("YES")
  if cnt > 1000:
    print("NO")
    exit(0)

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

Submission status: Wrong Answer

Solution code:
S = input()
d = ['dream', 'dreamer', 'erase', 'eraser']
cnt = 0
while True:
  for l in d:
    #print(S, l)
    if S[-3:] == l[-3:]:
      S = S[:-1*len(l)]
  #print(S)
  #exit(0)
  if len(S) == 0:
    print("YES")
    exit(0)
  cnt+=1
  if cnt > 10000:
    print("NO")
    break

Submission status: Wrong Answer

Solution code:
S = input()
d = ['dream', 'dreamer', 'erase', 'eraser']
cnt = 0
while True:
  for l in d:
    if S[-3:] == l[-3:]:
      S = S[:-1*len(l)]
  if len(S) == 0:
    print("YES")
    break
  cnt+=1
  if cnt > 1000:
    print("NO")
    break

Submission status: Wrong Answer

Solution code:
S = input()
d = ['dream', 'dreamer', 'erase' 'eraser']
cnt = 0
while True:
  for l in d:
    if S[-3:] == l[-3:]:
      S = S[len(l):]
  if len(S) == 0:
    print("YES")
    break
  cnt+=1
  if cnt > 1000:
    print("NO")
    break

Submission status: Wrong Answer

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

dp = [False] * (size + 1)
dp[0] = True

for i in range(5, size + 1):
    if dp[i - 5] and (s[i-5:i] == 'dream' or s[i-5:i] == 'erase'):
        dp[i] = True
    elif dp[i - 6] and s[i-6:i] == 'eraser':
        dp[i] = True
    elif dp[i - 7] and s[i-7:i] == 'eraser':
        dp[i] = True
    else:
        dp[i] = False
if dp[size]:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

ichi = 0
l = len(s)
cnt = l

while True:
    s_dreamer = s.rfind ("dreamer",ichi,14)
    s_eraser = s.rfind ("eraser",ichi,l)
    s_dream = s.rfind ("dream",ichi,l)
    s_erase = s.rfind ("erase",ichi,l)

    if s_dreamer == l - 7 and 0 <= l - 7:
        l = s_dreamer
        cnt -= 7 

    elif s_eraser == l - 6 and 0 <= l - 6:
        l = s_eraser
        cnt -= 6  

    elif s_dream == l - 5 and 0 <= l - 5:
        l = s_dream
        cnt -= 5  

    elif s_erase == l - 5 and 0 <= l - 5:
        l = s_erase
        cnt -= 5

    elif cnt == 0:
        print("YES")
        break

    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
s = input()

ichi = 0
cnt = 0
l = len(s)

while True:
    s_dreamer = s.find ("dreamer",ichi,l)
    s_eraser = s.find ("eraser",ichi,l)
    s_dream = s.find ("dream",ichi,l)
    s_erase = s.find ("erase",ichi,l)


    if s_dream == ichi:
        ichi = s_dreamer + 7
        cnt += 7 

    elif s_erase == ichi:
        ichi = s_eraser + 6
        cnt += 6  

    elif s_dreamer == ichi:
        ichi = s_dream + 5
        cnt += 5  

    elif s_eraser == ichi:
        ichi = s_erase + 5
        cnt += 5

    elif cnt == l:
        print("YES")
        break

    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
s = input()

ichi = 0
cnt = 0
l = len(s)

while True:
    s_dreamer = s.find ("dreamer",ichi,l)
    s_eraser = s.find ("eraser",ichi,l)
    s_dream = s.find ("dream",ichi,l)
    s_erase = s.find ("erase",ichi,l)


    if s_dreamer == ichi:
        ichi = s_dreamer + 7
        cnt += 7 

    elif s_eraser == ichi:
        ichi = s_eraser + 6
        cnt += 6  

    elif s_dream == ichi:
        ichi = s_dream + 5
        cnt += 5  

    elif s_erase == ichi:
        ichi = s_erase + 5
        cnt += 5

    elif cnt == l:
        print("YES")
        break

    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
s = input()

ichi = 0
cnt = 0
l = len(s)

while ichi <= l:
    s_dreamer = s.find ("dreamer",ichi,l)
    s_eraser = s.find ("eraser",ichi,l)
    s_dream = s.find ("dream",ichi,l)
    s_erase = s.find ("erase",ichi,l)


    if s_dreamer == ichi:
        ichi = s_dreamer + 7
        cnt += 7 

    elif s_eraser == ichi:
        ichi = s_eraser + 6
        cnt += 6  

    elif s_dream == ichi:
        ichi = s_dream + 5
        cnt += 5  

    elif s_erase == ichi:
        ichi = s_erase + 5
        cnt += 5

    elif cnt == l:
        print("YES")
        break

    else:
        print("NO")
        break

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 = str(input())
while len(s) >7:
    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('NO')
        break
if s == 'dream' or s == 'erase' or s == 'dreamer' or s == 'eraser':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = str(input())
while len(s) >7:
    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('NO')
        break
if s == 'dream' or s == 'erase' or s == 'dreamer' or s == 'eraser':
    print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
ind =0
len_s=len(s)
s = s+ "zzzzzzzzzz"

A = "dreamer"
B= "dream"
C= "erase"
D="eraser"

flag =True
while(1):
    if(s[ind] =="d"):
        if(s[ind + 5] =="d"):
            if(s[ind:ind+5]!=B):
                flag = False
                break
            else:
                ind+=5
        else:
            if(s[ind+5]!='e'):
                flag=False
                break
            if(s[ind+7] == "a"):
                if(s[ind:ind+5]!=B):
                    flag = False
                    break
                else:
                    ind+=5

            else:
                if(s[ind:ind+7] !=A):
                    flag = False
                    break
                else:
                    ind+=7
    elif(s[ind]=="e"):
        if(s[ind+5]=="r"):
            if(s[ind:ind+6]!=D):
                flag = False
                break
            else:
                ind+=6

        else:
            if(s[ind:ind +5] !=C):
                flag =False
                break
            else:
                ind+=5
    else:
        flag=False
        break
    if(ind == len_s):
        break
    if(ind > len_s):
        flag=False
        break
if(flag):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
ind =0
len_s=len(s)
s = s+ "zzzzzzzzzz"

A = "dreamer"
B= "dream"
C= "erase"
D="eraser"

flag =True
while(1):
    if(s[ind] =="d"):
        if(s[ind + 7] !="a"):
            if(s[ind:ind+7]!=A):
                flag = False
                break
            else:
                ind+=7
        else:
            if(s[ind:ind+5] !=B):
                flag = False
                break
            else:
                ind+=5
    elif(s[ind]=="e"):
        if(s[ind+5]=="r"):
            if(s[ind:ind+6]!=D):
                flag = False
                break
            else:
                ind+=6

        else:
            if(s[ind:ind +5] !=C):
                flag =False
                break
            else:
                ind+=5
    else:
        flag=False
        break
    if(ind == len_s):
        break
    if(ind > len(s)):
        flag=False
        break
if(flag):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
 
candi = ['dreamer', 'dream', 'eraser', 'erase']
 
for tmp in candi:
  s = s.replace(tmp,'')
if len(s) == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

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

for tmp in candi:
  s.replace(tmp,'')
if len(s) == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

while len(s) > 4:
    if s[-5:] == 'deram' or s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    else:
        break
        
if len(s) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
for n in range(4):
    s = s.replace(t[n], "")
if not s:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
flag = True
while s:
    for n in range(len(t)):
        if s[0:len(t[n])] == t[n]:
            s = s[len(t[n])::]
            flag = True
        else:
            flag = False
    if not flag:
        break
if not s:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
flag = True
while s:
    for n in range(len(t)):
        if s[0:len(t[n])] == t[n]:
            s = s.replace(t[n], "")
            flag = True
        else:
            flag = False
    if not flag:
        break
if not s:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
flag = True
while s:
    for n in range(len(t)):
        if s[0:len(t[n])] == t[n]:
            s = s.replace(t[n], "")
            flag = True
        else:
            flag = False
    if not flag:
        break
if not s:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

s = input()
s = s[-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
flag = True
while s:
    for n in range(len(t)):
        if s[0:len(t[n])] == t[n]:
            s.lstrip(t[n])
            flag = True
        else:
            flag = False
    if not flag:
        break
if flag:
    print('Yes')
else:
    print('No')

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:
s = input()
s = s[::-1] # 文字列の末尾から 1 個ずつさかのぼって先頭まで要素を取りだす
while True:
    if s.find("maerd") == 0:
        s = s.lstrip("maerd")
    elif s.find("remaerd") == 0:
        s = s.lstrip("remaerd")
    elif s.find("esare") == 0:
        s = s.lstrip("esare")
    elif s.find("resare") == 0:
        s = s.lstrip("resare")
    else:
        break
if s :
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
S=input()
i=0
j=0
k=len(S)
while(1):
    if(i==k):
        print("YES")
        break
    if(S[i:i+5]=="dream" or S[i:i+5]=="erase"):
        i+=5
    if(S[i:i+6]=="eraser"):
        i+=6
    if(S[i:i+7]=="dreamer"):
        i+=7
    if(i==j):
        print("NO")
        break
    j=i

Submission status: Wrong Answer

Solution code:
S=input()
i=0
j=0
k=len(S)
while(1):
    if(i==k):
        print("YES")
        break
    if(i==j):
        print("NO")
        break
    j=i
    if(S[i:i+5]=="dream" or S[i:i+5]=="erase"):
        i+=5
    if(S[i:i+6]=="eraser"):
        i+=6
    if(S[i:i+7]=="dreamer"):
        i+=7

Submission status: Wrong Answer

Solution code:
S=input()
i=0
j=0
k=len(S)
while(1):
    if(i==k):
        print("yes")
        break
    if(i==j):
        print("No")
        break
    j=i
    if(S[i:i+5]=="dream" or S[i:i+5]=="erase"):
        i+=5
    if(S[i:i+6]=="eraser"):
        i+=6
    if(S[i:i+7]=="dreamer"):
        i+=7

Submission status: Wrong Answer

Solution code:
import sys
s = input()
i = 0
while s[i:i+5] != '':
    if s[i:i+5] == 'dream':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+7] == 'er':
            i += 7
        else:
            print('NO')
            sys.exit(0)
    elif s[i:i+5] == 'erase':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+6] == 'r':
            i += 6
        else:
            print('NO')
            sys.exit(0)
    else:
        print('NO')
        sys.exit(0)
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
i = 0
while s[i:i+5] != '':
    if s[i:5] == 'dream':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+7] == 'er':
            i += 7
        else:
            print('NO')
            sys.exit(0)
    elif s[i:5] == 'erase':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+6] == 'r':
            i += 6
        else:
            print('NO')
            sys.exit(0)
    else:
        print('NO')
        sys.exit(0)
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
i = 0
while s[i:5] != '':
    if s[i:5] == 'dream':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+7] == 'er':
            i += 7
        else:
            print('NO')
            sys.exit(0)
    elif s[i:5] == 'erase':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+6] == 'r':
            i += 6
        else:
            print('NO')
            sys.exit(0)
    else:
        print('NO')
        sys.exit(0)
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
i = 0
while s[i:5] != '':
    if s[i:5] == 'dream':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+7] == 'er':
            i += 7
        else:
            print('No')
            sys.exit(0)
    elif s[i:5] == 'erase':
        if s[i+5:i+10] == 'dream':
            i += 5
        elif s[i+5:i+10] == 'erase':
            i += 5
        elif s[i+5:i+6] == 'r':
            i += 6
        else:
            print('No')
            sys.exit(0)
    else:
        print('No')
        sys.exit(0)

print('Yes')