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:
a=['dream','dreamer','erase','eraser']
s=input()

def check(x):
  if x=='':
    return True
  for t in a:
    if len(x)>=len(t) and x[0:len(t)]==a:
      return check(x[len(t):])
if check(s):
  ans='YES'
else:
  ans='NO'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
i = 0
while s:
    s = s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
    i += 1
    if i>100000/22:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

splits = [s.split(i) for i in labels]

for item in splits:
  for label in labels:
    if label in item:
      print("YES")
      break
  else:
    continue
  break
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
flag = 0
for _ in range(25000):
    if flag==4 or len(s)==0:
        break
    else:
        flag=0
    for word in words:
        l = len(word)
        if s[0:l] == word:
            s = s[l:]
        else:
            flag+=1
if flag==4:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
flag = 0
for _ in range(25000):
    if flag==4:
        break
    else:
        flag=0
    for word in words:
        l = len(word)
        if s[0:l] == word:
            s = s[l:]
        else:
            flag+=1
if flag==4:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
flag = 0
for _ in range(25000):
    if flag==4:
        break
    else:
        flag=0
    for word in words:
        l = len(word)
        if s[0:l] == word:
            s = s[l:]
        else:
            flag+=1
if flag==4:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
flag = 0
for _ in range(25000):
    if flag==4:
        break
    else:
        flag=0
    for word in words:
        l = len(word)
        if s[0:l] == word:
            s = s[l:]
            break
        else:
            flag+=1
if flag==4:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
flag = 0
for _ in range(25000):
    if flag==1:
        break
    for word in words:
        l = len(word)
        if s[0:l] == word:
            s = s[l:]
        else:
            flag=1
if len(s)==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
count = 0
for _ in range(25000):
    if count==4:
        break
    for word in words:
        count = 0
        l = len(word)
        if s[0:l] == word:
            s = s[l:]
        else:
            count+=1
if len(s)==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(words)) :
    words[i] = words[i][::-1]

S = input()[::-1]

ans = True

i = 0

while True :
    flag = False
    for w in words :
        if S[i:i + len(w)] == w :
            i += len(w)
            flag = True
            break
    if flag == False:
        ans = False
        break
    if i == len(S) :
        break

if ans :
    print('YES')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
sample=['maerd', 'resare', 'remaerd', 'esare', '']

i=0
while True:
    for d in sample:
        if s[:len(d)] == d:
            s = s[len(d):]
            break
    
    if d =='':
        print ("NO")
        break

    if len(s) ==0:
        print("OK")
        break

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
sample=['maerd', 'resare', 'remaerd', 'esare', '']

i=0
while True:
    for d in sample:
        
        if s[:len(d)] == d:
            s = s[len(d):]
            break
    
    if d =='':
        print ("NG")
        break

    if len(s) ==0:
        print("OK")
        break

Submission status: Wrong Answer

Solution code:
s=input()

sample={"dream":"er","erase":"r"}


i=0
while i < len(s):
    e=i+5
    if s[i:e] in sample:
        if s[ e: e + len(sample[s[i:e]] ) ] == sample[s[i:e]]:
            i  = e + len(sample[s[i:e]])
        else:
            i = e
        if i == len(s) :
            print("OK")
            break
    else:
        print ("NG")
        break

Submission status: Wrong Answer

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

sample={'maerd':"", 'remae':"rd", 'esare':"", 'resar':"e"}
while True:
    if s[:5] in sample and s[5:5+len(sample[s[:5]])] == sample[s[:5]]:
       s = s[5+len(sample[s[:5]]):]
    else:
        print("NO")
        break

    if len(s) ==0:
        print("OK")
        break

Submission status: Wrong Answer

Solution code:
S = input()
T = ''
idx = 0

while(len(T) < len(S)):
    
    if(S[idx: idx + 5] == 'dream'):
        T += 'dream'
        idx += 5
    
    elif(S[idx: idx + 7] == 'dreamer'):
        T += 'dreamer'
        idx += 7
    
    elif(S[idx: idx + 5] == 'erase'):
        T += 'erase'
        idx += 5
    
    elif(S[idx: idx + 6] == 'eraser'):
        T += 'eraser'
        idx += 6
    
    else:
        break

if(S == T):
    print('YES')

else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
S = list(input())
#print(S)
i = 0
er_c = 0
while True:
    c = 0
    if i < len(S) and S[i] == "d":
        er_c = 0
        #print(i,"d")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i,"e")
                i += 1
                if i < len(S) and S[i] == "a":
                    #print(i,"a")
                    i += 1
                    if i < len(S) and S[i] == "m":
                        #print(i,"m")
                        i += 1
                        if i < len(S) and S[i] == "e":
                            #print(i,"e")
                            i += 1
                            if i < len(S) and S[i] == "r":
                                #print(i, "r")
                                i += 1
                                c = 1
                                er_c = 1
                                if i == len(S):
                                    break
                        elif i == len(S):
                            c = 1
                            #print("dream")
                            break
                        elif S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif i < len(S) and S[i] == "e":
        er_c = 0
        #print(i,"e")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "a":
                #print(i,"a")
                i += 1
                if i < len(S) and S[i] == "s":
                    #print(i,"s")
                    i += 1
                    if i < len(S) and S[i] == "e":
                        #print(i,"e")
                        i += 1
                        if i < len(S) and S[i] == "r":
                            #print(i,"r")
                            i += 1
                            c = 1
                            if i == len(S):
                                break
                        elif i == len(S):
                            c = 1
                            break
                        elif  S[i] != "d" or "e":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif er_c == 1 and S[i] == "a":
        er_c = 0
        #print(i, "a")
        i += 1
        if i < len(S) and S[i] == "s":
            #print(i, "s")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i, "e")
                i += 1
                if i < len(S) and S[i] == "r":
                    #print(i, "r")
                    i += 1
                    c = 1
                    if i == len(S):
                        break
                elif i == len(S):
                    c = 1
                    break
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
if c == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
S = list(input())
#print(S)
i = 0
er_c = 0
while True:
    c = 0
    if i < len(S) and S[i] == "d":
        er_c = 0
        #print(i,"d")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i,"e")
                i += 1
                if i < len(S) and S[i] == "a":
                    #print(i,"a")
                    i += 1
                    if i < len(S) and S[i] == "m":
                        #print(i,"m")
                        i += 1
                        if i < len(S) and S[i] == "e":
                            #print(i,"e")
                            i += 1
                            if i < len(S) and S[i] == "r":
                                #print(i, "r")
                                i += 1
                                c = 1
                                er_c = 1
                                if i == len(S):
                                    break
                        elif i == len(S):
                            c = 1
                            #print("dream")
                            break
                        elif S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif i < len(S) and S[i] == "e":
        er_c = 0
        #print(i,"e")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "a":
                #print(i,"a")
                i += 1
                if i < len(S) and S[i] == "s":
                    #print(i,"s")
                    i += 1
                    if i < len(S) and S[i] == "e":
                        #print(i,"e")
                        i += 1
                        if i < len(S) and S[i] == "r":
                            #print(i,"r")
                            i += 1
                            c = 1
                            if i == len(S):
                                break
                        elif i == len(S):
                            c = 1
                            break
                        elif  S[i] != "d" or "e":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif er_c == 1 and S[i] == "a":
        er_c = 0
        #print(i, "a")
        i += 1
        if i < len(S) and S[i] == "s":
            #print(i, "s")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i, "e")
                i += 1
                if i < len(S) and S[i] == "r":
                    #print(i, "r")
                    i += 1
                    c = 1
                    if i == len(S):
                        break
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
if c == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

s = input()
s_rev = s[::-1]  # 左右反転
divide_rev = []
for i in range(4):
    divide_rev.append(divide[i][::-1])  # 左右反転

can = True
for i in range(len(s)):
    can2 = False
    for j in range(4):
        d = divide_rev[j]
        if s_rev[i:len(d)] == d:
            can2 = True
            i += len(d)
        if not can2:
            can = False
            break
    
    if can:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import sys
S = list(input())
#print(S)
i = 0
er_c = 0
while True:
    c = 0
    if i < len(S) and S[i] == "d":
        er_c = 0
        #print(i,"d")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i,"e")
                i += 1
                if i < len(S) and S[i] == "a":
                    #print(i,"a")
                    i += 1
                    if i < len(S) and S[i] == "m":
                        #print(i,"m")
                        i += 1
                        if i < len(S) and S[i] == "e":
                            #print(i,"e")
                            i += 1
                            if i < len(S) and S[i] == "r":
                                #print(i, "r")
                                i += 1
                                c = 1
                                er_c = 1
                                if i == len(S):
                                    break
                        elif i == len(S):
                            c = 1
                            #print("dream")
                            break
                        elif S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif i < len(S) and S[i] == "e":
        er_c = 0
        #print(i,"e")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "a":
                #print(i,"a")
                i += 1
                if i < len(S) and S[i] == "s":
                    #print(i,"s")
                    i += 1
                    if i < len(S) and S[i] == "e":
                        #print(i,"e")
                        i += 1
                        if i < len(S) and S[i] == "r":
                            #print(i,"r")
                            i += 1
                            c = 1
                            if i == len(S):
                                break
                        elif i == len(S):
                            c = 1
                            break
                        elif  S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif er_c == 1 and S[i] == "a":
        er_c = 0
        #print(i, "a")
        i += 1
        if i < len(S) and S[i] == "s":
            #print(i, "s")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i, "e")
                i += 1
                if i < len(S) and S[i] == "r":
                    #print(i, "r")
                    i += 1
                    c = 1
                    if i == len(S):
                        break
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
if c == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
S = list(input())
#print(S)
i = 0
er_c = 0
while True:
    c = 0
    if i < len(S) and S[i] == "d":
        er_c = 0
        #print(i,"d")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i,"e")
                i += 1
                if i < len(S) and S[i] == "a":
                    #print(i,"a")
                    i += 1
                    if i < len(S) and S[i] == "m":
                        #print(i,"m")
                        i += 1
                        if i < len(S) and S[i] == "e":
                            #print(i,"e")
                            i += 1
                            if i < len(S) and S[i] == "r":
                                #print(i, "r")
                                i += 1
                                c = 1
                                er_c = 1
                                if i == len(S):
                                    break
                        elif i == len(S):
                            c = 1
                            #print("dream")
                            break
                        elif S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif i < len(S) and S[i] == "e":
        er_c = 0
        #print(i,"e")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "a":
                #print(i,"a")
                i += 1
                if i < len(S) and S[i] == "s":
                    #print(i,"s")
                    i += 1
                    if i < len(S) and S[i] == "e":
                        #print(i,"e")
                        i += 1
                        if i < len(S) and S[i] == "r":
                            #print(i,"r")
                            i += 1
                            c = 1
                            if i == len(S):
                                break
                        elif i == len(S):
                            c = 1
                            break
                        elif  S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif er_c == 1 and S[i] == "a":
        er_c = 0
        #print(i, "a")
        i += 1
        if i < len(S) and S[i] == "s":
            #print(i, "s")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i, "e")
                i += 1
                if i < len(S) and S[i] == "r":
                    #print(i, "r")
                    i += 1
                    c = 1
                    if i == len(S):
                        break
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
if c == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
S = list(input())
#print(S)
i = 0
er_c = 0
while True:
    c = 0
    if i < len(S) and S[i] == "d":
        er_c = 0
        #print(i,"d")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i,"e")
                i += 1
                if i < len(S) and S[i] == "a":
                    #print(i,"a")
                    i += 1
                    if i < len(S) and S[i] == "m":
                        #print(i,"m")
                        i += 1
                        if i < len(S) and S[i] == "e":
                            #print(i,"e")
                            i += 1
                            if i < len(S) and S[i] == "r":
                                #print(i, "r")
                                i += 1
                                c = 1
                                er_c = 1
                                if i == len(S):
                                    break
                        elif i == len(S):
                            c = 1
                            #print("dream")
                            break
                        elif S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif i < len(S) and S[i] == "e":
        er_c = 0
        #print(i,"e")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "a":
                #print(i,"a")
                i += 1
                if i < len(S) and S[i] == "s":
                    #print(i,"s")
                    i += 1
                    if i < len(S) and S[i] == "e":
                        #print(i,"e")
                        i += 1
                        if i < len(S) and S[i] == "r":
                            #print(i,"r")
                            i += 1
                            c += 1
                            if i == len(S):
                                break
                        elif i == len(S):
                            c = 1
                            break
                        elif  S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif er_c == 1 and S[i] == "a":
        er_c = 0
        #print(i, "a")
        i += 1
        if i < len(S) and S[i] == "s":
            #print(i, "s")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i, "e")
                i += 1
                if i < len(S) and S[i] == "r":
                    #print(i, "r")
                    i += 1
                    c += 1
                    if i == len(S):
                        break
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
if c == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
S = list(input())
#print(S)
i = 0
er_c = 0
while True:
    c = 0
    if i < len(S) and S[i] == "d":
        er_c = 0
        #print(i,"d")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i,"e")
                i += 1
                if i < len(S) and S[i] == "a":
                    #print(i,"a")
                    i += 1
                    if i < len(S) and S[i] == "m":
                        #print(i,"m")
                        i += 1
                        if i < len(S) and S[i] == "e":
                            #print(i,"e")
                            i += 1
                            if i < len(S) and S[i] == "r":
                                #print(i, "r")
                                i += 1
                                c = 1
                                er_c = 1
                                if i == len(S):
                                    break
                        elif i == len(S):
                            c = 1
                            #print("dream")
                            break
                        elif S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif i < len(S) and S[i] == "e":
        er_c = 0
        #print(i,"e")
        i += 1
        if i < len(S) and S[i] == "r":
            #print(i,"r")
            i += 1
            if i < len(S) and S[i] == "a":
                #print(i,"a")
                i += 1
                if i < len(S) and S[i] == "s":
                    #print(i,"s")
                    i += 1
                    if i < len(S) and S[i] == "e":
                        #print(i,"e")
                        i += 1
                        if i < len(S) and S[i] == "r":
                            #print(i,"r")
                            i += 1
                            c += 1
                            if i == len(S):
                                break
                        elif i == len(S):
                            break
                        elif  S[i] != "d":
                            print("NO")
                            sys.exit()
                    else:
                        print("NO")
                        sys.exit()
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    elif er_c == 1 and S[i] == "a":
        er_c = 0
        #print(i, "a")
        i += 1
        if i < len(S) and S[i] == "s":
            #print(i, "s")
            i += 1
            if i < len(S) and S[i] == "e":
                #print(i, "e")
                i += 1
                if i < len(S) and S[i] == "r":
                    #print(i, "r")
                    i += 1
                    c += 1
                    if i == len(S):
                        break
                else:
                    print("NO")
                    sys.exit()
            else:
                print("NO")
                sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
if c == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = list(input())
n = n[::-1]
a = "dream"
a = a[::-1]
b = "dreamer"
b = b[::-1]
c = "eraser"
c = c[::-1]
d = "erase"
d = d[::-1]
co = 0
su = 0
for i in range(len(n)):
    co += 1
    if co == 5:
        if n[i:i+co] == "dream" or n[i:i+co] == "erase":
            su += 5
            co = 0
    elif co == 6:
        if n[i:i+co] == "eraser":
            su += 6
            co = 0
    elif co == 7:
        if n[i:i+co] == "dreamer":
            su += 7
            co = 0
    elif co >= 8:
        break
if su == len(n):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
i = 0
while S:
    S = S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
    i += 1
    if i == 10**5+1:
        print("NO")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
s = input()
if s.find("1") != -1:
    print("NO")
elif s.find("2") != -1:
    print("NO")
else:
    a = s.replace("dream", "11111").replace("erase", "22222").replace("11111er", "1111111").replace("22222r", "111111")
    if a.count("1") == len(a):
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
if s.find("1") != -1:
    print("NO")
elif s.find("2") != -1:
    print("NO")
else:
    a = s.replace("dream", "11111").replace("erase", "22222").replace("11111er", "1111111").replace("22222r", "111111")
    print(a)
    if a.count("1") == len(a):
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
def erase_end(string):
    if string.endswith("dream"):
        string = string.rstrip("dream")
    elif string.endswith("dreamer"):
        string = string.rstrip("dreamer")
    elif string.endswith("erase"):
        string = string.rstrip("erase")
    elif string.endswith("eraser"):
        string = string.rstrip("eraser")
    elif string == "":
        string = "YES"
    else:
        string = "NO"
    return string
    
string = input()

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

print(string)