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()
num=0
ans=0
num2=len(s)
d=list("dreamer")
e=list("eraser")
for i in range(num2):
    if num==num2:
        ans=1
        break
    if num+4>=num2:
        break
    if s[num]=="d":
        for j in range(5):
            if s[num]!=d[j]:
                ans=2
                break
            else:
                num+=1
        if ans==2:
            ans=0
            break
        if num==num2:
            ans=1
            break
        if num+1==num2:
            break
        if num2-num>=6:
            if s[num+2]=="e":
                for j in range(5,7):
                    if s[num]!=d[j]:
                        ans=2
                        break
                    else:
                        num+=1
        else:
            for j in range(5,7):
                if s[num]!=d[j]:
                    ans=2
                    break
                else:
                    num+=1
        if ans==2:
            ans=0
            break
    elif s[num]=="e":
        for j in range(5):
            if s[num]!=e[j]:
                ans=2
                break
            else:
                num+=1
        if ans==2:
            ans=0
            break
        if num==num2:
            ans=1
            break
        if num+1==num2:
            if s[-1]=="r":
                ans=1
            break
        if num2-num>=5:
            if s[num+1]=="d":
                for j in range(5,6):
                    if s[num]!=e[j]:
                        ans=2
                        break
                    else:
                        num+=1
        else:
            for j in range(5,6):
                if s[num]!=e[j]:
                    ans=2
                    break
                else:
                    num+=1
        if ans==2:
            ans=0
            break
if ans==0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
S = input()
print("YES" if re.match("(dream|dreamer|erase|erase)+", S) 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:
S = input()
A = "".join(list(reversed(S)))
print(A)
i = 0

while i != len(S):
    if A[i:i+5] == "maerd":
        i += 5
    elif A[i:i+5] == "esare":
        i += 5
    elif A[i:i+7] == "remaerd":
        i += 7
    elif A[i:i+6] == "resare":
        i += 6
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    elif a == 3:
        for j in range(6):
            if y[a][5-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[0]:
                return c
        c = 1
    return c


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
c = 1
while len(temp) != 0 and c == 1:
    a = h(temp)
    c = H(temp,y,a)
if c == 1:
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    elif a == 3:
        for j in range(6):
            if y[a][5-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[0]:
                return c
        c = 1
    return c


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
a = h(temp)
c = 1
while len(temp) != 0 and c == 1:
    a = h(temp)
    c = H(temp,y,a)
if c == 1:
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    elif a == 3:
        for j in range(6):
            if y[a][5-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            print(a)
            if y[a][6-j] != temp[0]:
                return c
        c = 1
    return c


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
a = h(temp)
c = 1
while len(temp) != 0 and c == 1:
    a = h(temp)
    c = H(temp,y,a)
if c == 1:
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
i=0
while i<len(s):
    if i+5<=len(s) and s[i:i+5]=='rsare':
        i+=5
    elif i+5<=len(s) and s[i:i+5]=='maerd':
        i+=5
    elif i+6<=len(s) and s[i:i+6]=='resare':
        i+=6
    elif i+7<=len(s) and s[i:i+7]=='remaerd':
        i+=7
    elif i<len(s):
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 7 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a":
                i += 4
        elif i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 6
            else:
                i += 4
        else:
            i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 < len(s):
            if s[i + 5] == "r":
                i += 5
            else:
                i += 4
        else:
            i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 7 <= len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a":
                i += 4
        elif i + 6 <= len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 6
            else:
                i += 4
        else:
            i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 <= len(s):
            if s[i + 5] == "r":
                i += 5
            else:
                i += 4
        else:
            i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = list(input())
frag = 0
i = 0
while i < len(s):
    if s[i] == "d" and s[i + 1] == "r" and s[i + 2] == "e" and s[i + 3] == "a" and s[i + 4] == "m":
        if i + 7 <= len(s):
            if s[i + 5] == "e" and s[i + 6] == "r" and s[i + 7] == "a":
                i += 4
        elif i + 6 < len(s):
            if s[i + 5] == "e" and s[i + 6] == "r":
                i += 6
            else:
                i += 4
        else:
            i += 4
    elif s[i] == "e" and s[i + 1] == "r" and s[i + 2] == "a" and s[i + 3] == "s" and s[i + 4] == "e":
        if i + 5 <= len(s):
            if s[i + 5] == "r":
                i += 5
            else:
                i += 4
        else:
            i += 4
    else:
        frag = 1
        break
    i += 1
if frag == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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


i=0
ans="Yes"
while True:
    if len(s)==i:
        break
    elif s[i:i+5]=="maerd":
        i+=5
    elif s[i:i+7]=="remared":
        i+=7
    elif s[i:i+5]=='esare':
        i+=5
    elif s[i:i+6]=='resare':
        i+=6
    else:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
ans="Yes"
while True:
    if len(s)==i:
        break
    elif s[i:i+5]==A[0]:
        i+=5
    elif s[i:i+7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
ans="Yes"
while True:
    if len(s)==i:
        break
    if s[i:i+5]==A[0]:
        i+=5
    elif s[i:i+7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
ans="Yes"
while True:
    if len(s)==i:
        break
    elif s[i:i+5]==A[0]:
        i+=5
    elif s[i:i+7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
ans="Yes"
while True:
    if len(s)==i:
        break
    elif s[i:i+5]==A[0]:
        i+=5
    elif s[i:7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
while True:
    if len(s)==i:
        ans="Yes"
        break
    elif s[i:i+5]==A[0]:
        i+=5
    elif s[i:7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
while True:
    if len(s)==i:
        print("Yes")
        break
    elif s[i:i+5]==A[0]:
        i+=5
    elif s[i:7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
s=input()
lst=["eraser","erase","dreamer","dream",]
for e in lst: 
  s=s.replace(e,"")
print(s)
print("YES" if s=="" else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
A=["","dream","dreamer","erase","eraser"]
flag=0
for a in range(1,5):
    for b in range(0,5):
        for c in range(0,5):
            for d in range(0,5):
                for e in range(0,5):
                    T=A[a]+A[b]+A[c]+A[d]+A[e]
                    if s==T:
                        flag=1

                
if flag==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = input()
A=["","dream","dreamer","erase","eraser"]
flag=0
for a in range(0,5):
    for b in range(0,5):
        for c in range(0,5):
            for d in range(0,5):
                T=A[a]+A[b]+A[c]+A[d]
                if s==T:
                     flag=1
if flag==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = input()
A=["","dream","dreamer","erase","eraser"]
flag=0
for a in range(0,5):
    for b in range(0,5):
        for c in range(0,5):
            for d in range(0,5):
                if a!=b or a!=c or a!=d or b!=c:
                    T=A[a]+A[b]+A[c]+A[d]
                    if s==T:
                        flag=1
if flag==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
word = ['dream','dreamer','erase','eraser']
for i in word:
    S = S.replace(i[::-1],'')
if S == '':print('YES')
else:print('NO')

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
word = ['dream','dreamer','erase','eraser']
for i in word:
    S = S.replace(i[::-1],'')
print(S)
if S == '':print('YES')
else:print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
s = reversed(S)

T = ''

for i in s:
    T += i
    if T in ['maerd', 'remaerd', 'esare', 'resare']:
       T = ''
    if len(T) >= 6:
        print('NO')
        break
if len(T) == 0:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = input().strip()
N = len(S)
cur = 0
flag = 0
while cur<N:
    if S[cur:cur+5]=="dream":
        if cur+5==N:
            cur += 5
        elif cur+5<N and S[cur+5]=="d":
            cur += 4
        elif S[cur:cur+7]=="dreamer":
            if cur+7==N:
                cur += 7
            elif S[cur+7] in ["d","e"]:
                cur += 7
            elif S[cur+7]=="a":
                cur += 5
    elif S[cur:cur+5]=="erase":
        if cur+5==N:
            cur += 5
        elif cur+5<N and S[cur+5]=="r":
            cur += 6
        elif cur+5<N and S[cur+5] in ["d","e"]:
            cur += 5
    else:
        flag=1
        break
if flag==0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = ""
i = 0
ok = True
while i <= len(s)-1:
    if len(a)<5:
        a += s[i]
        i += 1
    else:
        if a != "dream" and a != "erase": 
            ok = False
            break
        a = ""
        if i+1 <= len(s)-1 and s[i]+s[i+1]== "er":
            if i+2 <= len(s)-1 and s[i+2] == "a": i+=1
            else: i+=2
        else: i+=1
if a != "": ok = False
print("YES" if ok else "NO")

Submission status: Wrong Answer

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

s = input()

while True:
  chg_flg = False
  for w in words:
    if s.startswith(w):
      s = s[len(w):]
      chg_flg = True
  if not chg_flg:
    break

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

Submission status: Wrong Answer

Solution code:
import re

S = input()

list_string = ['dream', 'dreamer', 'erase', 'eraser']
regex = r'(dream(er)?eraser?)+|(eraser?dream(er)?)+|(((dream(er)?)|(eraser?))+)'

def check(list_string, regex, S):
    while S:
        if re.search(regex, S):
            S =  re.sub(regex, '', S)

        else:
            return 'NO'
    return 'YES'

print(check(list_string, regex, S))

Submission status: Wrong Answer

Solution code:
import re

S = input()

list_string = ['dream', 'dreamer', 'erase', 'eraser']
regex = r'((dream(er)?)|(eraser?))$'

def check(list_string, regex, S):
    while S:
        if re.search(regex, S):
            S =  re.sub(regex, '', S)
            print(S)

        else:
            return 'NO'
    return 'YES'

print(check(list_string, regex, S))

Submission status: Wrong Answer

Solution code:
import re

S = input()

list_string = ['dream', 'dreamer', 'erase', 'eraser']
regex = r'((dream(er)?)|(erase(er)?))$'

while True:
    if S:
        if re.search(regex, S):
            S =  re.sub(regex, '', S)

        else:
            print('NO')
            break
    else:
        print('YES')
        break

Submission status: Wrong Answer

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    word = ['eraser', 'erase', 'dreamer', 'dream']
    for x in word:
        s = s.replace(x, '')
    if s == '':
        print('Yes')
    else:
        print('No')
        
        
        
            
        
    
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
ones=s.split("eraser")
for one in ones:
    twos=one.split("erase")
    for two in twos:
        three=two.split("dreamer")
        if set(three)==set(["dream"]) or set(three)==set(["dream",""]) or set(three)==set([""]):
            pass
        else:
            ans+=1
if ans==0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

t_list = ['dreamdream', 'dreamdreamer', 'dreamerase', 'dreameraser', 'dreamerdream', 'dreamerdreamer', 'dreamererase', 'dreamereraser', 'erasedream', 'erasedreamer', 'eraseerase', 'eraseeraser', 'eraserdream', 'eraserdreamer', 'erasererase', 'erasereraser']

try:
    t_list.index(s)
    print('YES')
except:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

t_list = ['dreamdream', 'dreamdreamer', 'dreamerase', 'dreameraser', 'dreamerdream', 'dreamerdreamer', 'dreamererase', 'dreamereraser', 'erasedream', 'erasedreamer', 'eraseerase', 'eraseeraser', 'eraserdream', 'eraserdreamer', 'erasererase', 'erasereraser']

if s in t_list:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
s_reverse = ''.join(list(reversed(s)))
t = ''

while True:
    n = len(t)
    print(n)
    print(len(s))
    if s_reverse == t:
        print('YES')
        break
    if len(s) <= n:
        print('NO')
        break
    if s_reverse[n] == 'm':
        t += ''.join(list(reversed('dream')))
    elif s_reverse[n] == 'e':
        t += ''.join(list(reversed('erase')))
    elif s_reverse[n:n+3] == 'rem':
        t += ''.join(list(reversed('dreamer')))
    elif s_reverse[n:n+3] == 'res':
        t += ''.join(list(reversed('eraser')))
    else:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
s = input()
s_reverse = ''.join(list(reversed(s)))
t = ''

while True:
    n = len(t)
    if s_reverse == t:
        print('YES')
        break
    if len(s) > n:
        print('NO')
        break
    if s_reverse[n] == 'm':
        t += ''.join(list(reversed('dream')))
    elif s_reverse[n] == 'e':
        t += ''.join(list(reversed('erase')))
    elif s_reverse[n:n+3] == 'rem':
        t += ''.join(list(reversed('dreamer')))
    elif s_reverse[n:n+3] == 'res':
        t += ''.join(list(reversed('eraser')))
    else:
        print('NO')
        break

Submission status: Wrong Answer

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

lt = [w[::-1] for w in lt]
s = s[::-1]
cond = True
i = 0
while i < len(s):
    for t in lt:
        if s[i:].startswith(t):
            i += len(t)
            break
    else:
        cond = False
        break

print("Yes" if cond else "No")

Submission status: Wrong Answer

Solution code:
s = input()
s_reverse = ''.join(list(reversed(s)))
t = ''

while True:
    if s_reverse == t:
        print('YES')
        break
        
    n = len(t)
    if s_reverse[n] == 'm':
        t += ''.join(list(reversed('dream')))
    elif s_reverse[n] == 'e':
        t += ''.join(list(reversed('erase')))
    elif s_reverse[n:3] == 'rem':
        t += ''.join(list(reversed('dreamer')))
    elif s_reverse[n:3] == 'res':
        t += ''.join(list(reversed('eraser')))
    else:
        print('NO')
        break

Submission status: Wrong Answer

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

index=0
words=["maerd","remaerd","esare","resare"]
while index<N:
    word1=S[index:index+5]
    word2=S[index:index+7]
    if word1 in words:
        index+=5
    elif word2 in words:
        index+=7
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

import re

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


while len(list(S)) > 8: 
    if S[0] == 'd':
        if S[0:5] == 'dream':
            if S[5:10] == 'erase':
                S = S[5:]
            elif S[5:10] == 'dream':
                S = S[5:]
            elif S[5:7] == 'er':
                if S[7:12] == 'dream':
                    S = S[7:]
                elif S[7:12] == 'erase':
                    S = S[7:]
            else:break

    else:
        if S[0:6] == 'eraser':
            S = S[6:]
        elif S[0:5] == 'erase':
            if S[5:10] == 'erase':
                S = S[5:]
            elif S[5:10] == 'dream':
                S = S[5:]
        else:break
k = 0 
for l in li:
    if S == l:k = 1
if k == 0:print('No')
else:print('Yes')

Submission status: Wrong Answer

Solution code:
words = {"eraser" , "erase" , "dreamer" , "dream",""}
s = input()
n = len(s)
now=""
f=0
for i in range(0 ,n):
	now = now+s[i]
	if now =="dreamer":
		now = ""
	elif now =="eraser":
		now = ""
if now in words:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
words = {"eraser" , "erase" , "dreamer" , "dream"}
s = input()
n = len(s)
now=""
for i in range(0 ,n):
	now = now+s[i]
	if now in words:
		now=""
if now in words or now =="":
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import resource
sys.setrecursionlimit(100000)

def hantei(S):
  if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser':
    return 1
  if S[:5] == 'dream' or S[:5] == 'erase':
    if S[:7] == 'dreamer' or S[:7] == 'eraser':
      return hantei(S[5:]) | hantei(S[7:])
    else:
      return hantei(S[5:])
  else:
    return 0

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

Submission status: Wrong Answer

Solution code:
def hantei(S):
  if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser':
    return 1
  if S[:5] == 'dream' or S[:5] == 'erase':
    if S[:7] == 'dreamer' or S[:7] == 'eraser':
      return hantei(S[5:]) | hantei(S[7:])
    else:
      return hantei(S[5:])
  else:
    return 0

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

Submission status: Wrong Answer

Solution code:
def hantei(S):
  if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser':
    return 1
  if S[:5] == 'dream':
    return hantei(S[5:]) | hantei(S[7:])
  if S[:7] == 'dreamer':
    return hantei(S[5:]) | hantei(S[7:])
  if S[:5] == 'erase':
    return hantei(S[5:]) | hantei(S[7:])
  if S[:7] == 'eraser':
    return hantei(S[5:]) | hantei(S[7:])
  else:
    return 0

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

Submission status: Wrong Answer

Solution code:
def hantei(S):
  if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser':
    return True
  if S[:5] == 'dream':
    return hantei(S[5:])
  if S[:7] == 'dreamer':
    return hantei(S[7:])
  if S[:5] == 'erase':
    return hantei(S[5:])
  if S[:7] == 'eraser':
    return hantei(S[7:])
  else:
    return False

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

Submission status: Wrong Answer

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

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

idx = 0
ans='YES'
while idx < len(S):
    if S[idx] == 'm':
        if S[idx:idx+5] == s[0]:
            idx=idx+5
        else:
            ans='NO'
            break
        
    elif S[idx] == 'e':
        if S[idx:idx+5] == s[2]:
            idx=idx+5
        else:
            ans='NO'
            break
        
    elif S[idx] == 'r':
        if S[idx:idx+6] == s[1]:
            idx=idx+6
        elif S[idx:idx+6] == s[3]:
            idx=idx+6
        else:
            ans='NO'
            break
        
    else:
        ans='NO'
        break
        
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
dp=[False]*(n+1)
dp[1]=True
c=["dream","dreamer","erase","eraser"]
for i in range(n+1):
    if dp[i]:
        l=""
        if i+5<=n:
            for idx in range(5):
                l+=s[i+idx-1]
            if l in c:
                dp[i+5]=True
        if i+6<=n:
            l+=s[i+4]
            if l in c:
                dp[i+6]=True
        if i+7<=n:
            l+=s[i+5]
            if l in c:
                dp[i+7]=True
#print(dp)
if dp[n]:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
N = list(input())


N_rev = N[::-1]
#print(N_rev)

while len(N_rev) > 0:
  if N_rev[0] == "m":
    if N_rev[1] == "a" and N_rev[2] == "e" and N_rev[3] == "r" and N_rev[4] == "d":
      N_rev = N_rev[5:]
      print("subscript[dream]",N_rev)
    else:
      print("NO")
      sys.exit()
  elif N_rev[0] == "r":
    if N_rev[1] == "e" and N_rev[2] == "m" and N_rev[3] == "a" and N_rev[4] == "e" and N_rev[5] == "r" and N_rev[6] == "d":
      N_rev = N_rev[7:]
      print("subscript[dreamer]",N_rev)
    elif N_rev[1] == "e" and N_rev[2] == "s" and N_rev[3] == "a" and N_rev[4] == "r" and N_rev[5] == "e":
      N_rev = N_rev[6:]
      print("subscript[eraser]",N_rev)
    else:
      print("NO")
      sys.exit()
  elif N_rev[0] == "e":
    if N_rev[1] == "s" and N_rev[2] == "a" and N_rev[3] == "r" and N_rev[4] == "e":
      N_rev = N_rev[5:]
      print("subscript[erase]",N_rev)
    else:
      print("NO")
      sys.exit()
  else:
    print("NO")
    sys.exit()

if len(N_rev) == 0:
  print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
C = ["maerd","remaerd","esare","resare"]
ans = ""
a = "YES"
x = len(S)
for i in range(x):
    ans = ans + S[x - 1 -i]
    if ans == C[0]:
        ans = ""
    elif ans == C[1]:
        ans = ""
    elif ans == C[2]:
        ans = ""
    elif ans == C[3]:
        ans = ""
if len(ans) != 0:
    a = "No"
print(a)

Submission status: Wrong Answer

Solution code:
st = input()
S = st[::-1]
words ={"remaerd","resare","maerd","esare"}

lenT = 0
flag = 0
ans = "NO"

while flag < 5:
  for i in range(5, 8):
    if S[0:i] in words:
      S = S[i:]
      
    elif S == "":
      flag = 5
      ans = "YES"
      break
    else:
      flag += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]
lis = ['dream', 'dreamer', 'erase', 'eraser']
nlis = []
for i in lis:
    nlis.append(i[::-1])

for j in nlis:
    s = s.replace(j, '')


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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]
lis = ['dream', 'dreamer', 'erase', 'eraser']
nlis = []
for i in lis:
    nlis.append(i[::-1])

flag = 0
for _ in range(10**5+1):
    for j in nlis:
        if s.startswith(j):
            s = s.replace(j, '')


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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]
lis = ['dream', 'dreamer', 'erase', 'eraser']
nlis = []
for i in lis:
    nlis.append(i[::-1])

flag = 0
for _ in range(10**5+1):
    for j in nlis:
        if s.startswith(j):
            s = s.replace(j, '')
        else:
            break
    
    if s == '':
        flag = 1
        break


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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]
lis = ['dream', 'dreamer', 'erase', 'eraser']
nlis = []
for i in lis:
    nlis.append(i[::-1])

flag = 0
for _ in range(10**5+1):
    for j in nlis:
        if s.startswith(j):
            s = s.replace(j, '')
    
    if s == '':
        flag = 1
        break


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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]
lis = ['dream', 'dreamer', 'erase', 'eraser']
nlis = []
for i in lis:
    nlis.append(i[::-1])

flag = 0
ans = ''
for _ in range(10):
    for j in nlis:
        if s.startswith(j):
            ans += j
            s = s.replace(j, '')
            
    
    if ans == s:
        flag = 1
        break

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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]
lis = ['dream', 'dreamer', 'erase', 'eraser']
nlis = []
for i in lis:
    nlis.append(i[::-1])

flag = 0
ans = ''
for _ in range(10):
    for j in nlis:
        if s.startswith(j):
            s = s.replace(j, '')
            
    
    if ans == s:
        flag = 1
        break



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

Submission status: Wrong Answer

Solution code:
s = str(input())
a = ['dream', 'dreamer', 'erase', 'eraser']

f = True
while f:
    os = s
    for i in a:
        if s.endswith(i):
            s = s[:-len(i)]
            if len(s) == 0:
                print("YES")
                f = False
    if len(os) == len(s):
        print("No")
        f = False

Submission status: Wrong Answer

Solution code:
st = input()
S = st[::-1]
words ={"remaerd","resare","maerd","esare"}

lenT = 0
flag = 0
ans = "NO"

while flag < 5:
  for i in range(5, 8):
    if S[0:i] in words:
      S = S[i:]
      
    elif S == "":
      flag = 5
      ans = "YES"
      break
    else:
      flag += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
input_str = input()

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

Submission status: Wrong Answer

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