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 = list(input())

ans = "YES"
while s:
    end = s.pop()
    if end == "m":
        for a in list("aerd"):
            r = s.pop()
            if r == a:
                continue
            ans = "NO"

    elif end == "e":
        for a in list("sare"):
            r = s.pop()
            if r == a:
                continue
            ans = "NO"

    elif end == "r":
        if s.pop() != "e":
            ans = "No"
            break
        rr = s.pop()
        if rr == "m":
            for a in list("aerd"):
                r = s.pop()
                if r == a:
                    continue
                ans = "NO"
        elif rr == "s":
            for a in list("are"):
                r = s.pop()
                if r == a:
                    continue
                ans = "NO"
        else:
            ans = "NO"
            break

        if ans == "NO":
            break
    else:
        ans = "NO"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())

ans = "YES"
while s:
    end = s.pop()
    if end == "m":
        for a in list("aerd"):
            r = s.pop()
            if r == a:
                continue
            ans = "NO"
            break

    elif end == "e":
        for a in list("sare"):
            r = s.pop()
            if r == a:
                continue
            ans = "NO"
            break
            
    elif end == "r":
        if s.pop() != "e":
            ans = "No"
            break
        rr = s.pop()
        if rr == "m":
            for a in list("aerd"):
                r = s.pop()
                if r == a:
                    continue
                ans = "NO"
                break
        elif rr == "s":
            for a in list("are"):
                r = s.pop()
                if r == a:
                    continue
                ans = "NO"
                break
        else:
            ans = "NO"
            break

        if ans == "NO":
            break
    else:
        ans = "NO"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
now = 0
n = len(s)
prev = ""
x = {"eraser", "dreamer", "dream", "erase"}
# 直前の単語がdreamerのとき
y = {"ase", "aser"}
ds = [7, 6, 5, 4, 3]

ans = "YES"
while s:
    end = s.pop()
    if end == "m":
        for a in list("aerd"):
            r = s.pop()
            if r == a:
                continue
            ans = "NO"
            break
    elif end == "e":
        for a in list("sare"):
            r = s.pop()
            if r == a:
                continue
            ans = "NO"
            break
    elif end == "r":
        if s.pop() != "e":
            ans = "No"
            break
        rr = s.pop()
        if rr == "m":
            for a in list("aerd"):
                r = s.pop()
                if r == a:
                    continue
                ans = "NO"
                break
        elif rr == "s":
            for a in list("are"):
                r = s.pop()
                if r == a:
                    continue
                ans = "NO"
                break
        else:
            ans = "NO"
            break

        if ans == "NO":
            break

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
now = 0
n = len(s)
prev = ""
x = {"eraser", "dreamer", "dream", "erase"}
y = {"ase", "aser"}
ds = [8, 7, 6, 5, 4]
ans = "YES"
while now < n:
    q = 1
    for i in ds:
        index = now + i
        if index > n:
            continue
        w = s[now:index]
        if w in x:
            now += i
            prev = w
            q = 0
            break
        elif prev == "dreamer" and w in y:
            now += i
            prev = w
            q = 0
            break
    if q:
        ans = "NO"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
words = {"dream", "dreamer", "erase", "eraser"}

while len(s)!=0:
    for i in words:
        l = len(i)
        print(s[0:l], i[::-1])
        if s[0:l] == i[::-1]:
            s = s[l::]
            break
    else:
        break

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

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
words = {"dream", "dreamer", "erase", "eraser"}

for i in words:
    s = s.replace(i[::-1],'')
    print(s[::-1], i)

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

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
words = {"dream", "dreamer", "erase", "eraser"}

for i in words:
    print(i[::-1])
    s = s.replace(i[::-1],'')

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

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
words = {"dream", "dreamer", "erase", "eraser"}
for i in words:
    s = s.replace(i[::-1],'')
print("NO"if len(s)else "YES")

Submission status: Wrong Answer

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


S = input()

if len(S) < 5:
    print('NO')
    exit(0)

buf = []
for c in reversed(S):
    buf.append(c)
    if len(buf) == 5:
        if ''.join(buf)  in ['esare', 'maerd']:
            buf = []
    elif len(buf) == 6:
        if ''.join(buf) in ['resare', 'remaerd']:
            buf = []
    elif len(buf) >= 7:
        print('NO')
        exit(0)
if len(buf) > 0:
    if ''.join(buf) not in ['resare', 'remaerd', 'esare', 'maerd']:
        print('NO')
        exit(0)
print('YES')

Submission status: Wrong Answer

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


S = input()

if len(S) < 5:
    print('NO')
    exit(0)

buf = []
for c in reversed(S):
    buf.append(c)
    if len(buf) == 5:
        if ''.join(buf)  in ['esare', 'maerd']:
            buf = []
    elif len(buf) == 6:
        if ''.join(buf) in ['resare', 'ermaerd']:
            buf = []
    elif len(buf) >= 7:
        print('NO')
        exit(0)
if len(buf) > 0:
    if ''.join(buf) not in ['resare', 'ermaerd', 'esare', 'maerd']:
        print('NO')
        exit(0)
print('YES')

Submission status: Wrong Answer

Solution code:
def main():
    target = input()
    string = ["eraser", "dreamer", "erase", "dream"]
    for i in range(len(target)):
        for s in string:
            if target[i - len(s):] == s:
                target = target[:i - len(s)]
                break
    print("YES" if target == "" else "NO")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    target = input()[::-1]
    string = ["eraser", "dreamer", "erase", "dream"]
    for i in range(4):
        string[i] = string[i][::-1]
    for s in string:
        target = target.replace(s, "")
    print("YES" if target == "" else "NO")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()
s=s+"0000000"
c=0
check=0
while c<len(s):
    if s[c:c+5]=="dream":
        if s[c+5:c+7]=="er":
            if s[c+7]=="a":
                c+=5
            else:
                c+=7
        else:
            c+=5
    elif s[c:c+5]=="erase":
        if s[c+5]=="r":
            c+=6
        else:
            c+=5
    else:
        check+=1
        break
if check==0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
"""
s = input()
while len(s) > 4:
    if s[:5] == "dream":
        if s[:7] == "dreamer":
            if s[:10] == "dreamerase":
                s = s[5:]
            else:
                s = s[7:]
        else:
            s = s[5:]
    elif s[:5] == "erase":
        if s[:6] == "eraser":
            s = s[6:]
        else:
            s = s[5:]
    else:
        s = "*"
if s == "":
    print("YES")
else:
    print("NO")
"""
"""
s = input()
while len(s) > 4:
    if s[:5] == "dream":
        if s[5:7] == "er":
            if s[7:10] == "ase":
                s = s[5:]
            else:
                s = s[7:]
        else:
            s = s[5:]
    elif s[:5] == "erase":
        if s[5:6] == "r":
            s = s[6:]
        else:
            s = s[5:]
    else:
        break
if s == "":
    print("YES")
else:
    print("NO")
"""
s = input()
while len(s) >= 7:
    if s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-6:] == "eraser":
        s = s[:-6]
    elif s[-5:] == "dream" or "erase":
        s = s[:-5]
    else:
        break
if len(s) == 6:
    if s[-6:] == "eraser":
        s = s[:-6]
    elif s[-5:] == "dream" or "erase":
        s = s[:-5]
if len(s) == 5:
    if s[-5:] == "dream" or "erase":
        s = s[:-5]
if s == "":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re

s = input()
s = re.sub("eraser","",s)
s = re.sub("erase","",s)
s = re.sub("dreamer","",s)
s = re.sub("dream","",s)

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

Submission status: Wrong Answer

Solution code:
import re

s = input()
s = re.sub("eraser","",s)
s = re.sub("erase","",s)
s = re.sub("dreamer","",s)
s = re.sub("dream","",s)
print("Yes" if len(s) ==0 else "No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def checker(s):
    n = len(s)
    if (n<1):
        print("NO")
        return

    if (s[0] == 'd'):
        if (n > 5-1):
            if (s[0:5]=='dream'):#この時点でdreamは確定
                if (n > 8-1):
                    if (s[5:8]=='era'):
                        checker(s[5:])#s = s[5:]
                    else:
                        checker(s[7:])#s = s[7:]
                elif (n > 7-1):
                    if (s[0:7]=='dreamer'):
                        print("YES")
                    else:
                        print("NO")
                elif (n == 5):
                    print("YES")
                else:
                    print("NO")
            else:
                print("NO")
        else:
            print("NO")
    elif (s[0] == 'e'):
        if (n > 5-1):
            if (s[0:5]=='erase'):#この時点でeraseは確定
                if (n == 6):
                    if (s[0:6] == 'eraser'):
                        print("YES")
                    else:
                        print("NO")
                elif (n > 7-1):
                    if (s[0:6] == 'eraser'):
                        checker(s[6:])
                    else:
                        checker(s[5:])
                elif (n ==5):
                    print("YES")
                else:
                    print("NO")
            else:
                print("NO")
        else:
            print("NO")
    else:
        print("NO")

def main():
    s = input()
    checker(s)
main()

Submission status: Wrong Answer

Solution code:
S = input()
case =True
while(case == True):
    if len(S) <5:
        case = False
    
    elif S[0:5] == 'dream': #check 'dreamer' and 'dream'
        if len(S) > 6 and S[5] == 'e' and S[6] == 'r':
            S = S[7:]
        else:
            S = S[5:]

    elif S[0:5] == 'erase': #check 'erase' and 'eraser'
        if len(S) > 5 and S[5] == 'r':
            S = S[6:]
        else:
            S = S[5:]
    
    else:
        case =False

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

Submission status: Wrong Answer

Solution code:
S = input()
case =True
while(case == True):
    if len(S) <5:
        case = False
    
    elif S[0:5] == 'dream': #check 'dreamer' and 'dream'
        if len(S) > 6 and S[5] == 'e' and S[6] == 'r':
            S = S[6:]
        else:
            S = S[5:]

    elif S[0:5] == 'erase': #check 'erase' and 'eraser'
        if len(S) > 5 and S[5] == 'r':
            S = S[6:]
        else:
            S = S[5:]
    
    else:
        case =False

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

Submission status: Wrong Answer

Solution code:
S = input()
case =True
while(case == True):
    if len(S) <5:
        case = False
    
    elif S[0:5] == 'dream': #check 'dreamer' and 'dream'
        if len(S) > 5 and S[5] == 'r':
            S = S[6:]
        else:
            S = S[5:]

    elif S[0:5] == 'erase': #check 'erase' and 'eraser'
        if len(S) > 5 and S[5] == 'r':
            S = S[6:]
        else:
            S = S[5:]
    
    else:
        case =False

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
word = input()
def gyaku(x):
  x = list(x)
  x.reverse()
  return ''.join(x)

a = ''.join(gyaku(word).split(gyaku('eraser')))
b = ''.join(a.split(gyaku('dreamer')))
c = ''.join(b.split(gyaku('dream')))
d = ''.join(c.split(gyaku('erase')))

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

Submission status: Wrong Answer

Solution code:
word = input()
def gyaku(x):
  x = list(x)
  x.reverse()
  return ''.join(x)

a = ''.join(gyaku(word).split(gyaku('eraser')))
b = ''.join(a.split(gyaku('dreamer')))
c = ''.join(b.split(gyaku('dream')))
d = ''.join(c.split(gyaku('erase')))

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

Submission status: Wrong Answer

Solution code:
word = input()
b = word
d = word
f = word
h = word
def gyaku(x):
  x = list(x)
  x.reverse()
  return ''.join(x)
if gyaku('erase') in gyaku(h):
  c = gyaku(h).split(gyaku('erase'))
  d = ''.join(c)
  h = gyaku(d)
if gyaku('dream') in gyaku(h):
  e = gyaku(h).split(gyaku('dream'))
  f = ''.join(e)
  h = gyaku(f)

if gyaku('eraser') in gyaku(word):
  a = gyaku(word).split(gyaku('eraser'))
  b = ''.join(a)
  h = gyaku(b)
if gyaku('dreamer') in gyaku(h):
  g = gyaku(h).split(gyaku('dreamer'))
  i = ''.join(g)
  h = gyaku(i)

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

Submission status: Wrong Answer

Solution code:
S = input()

S = S[::-1]

index = 0
#possible = False

while index < len(S):
    if S[index] == 'm':
        if S[index:index+5] == 'maerd':
            index += 5
            continue
        else:
            break
    elif S[index] == 'e':
        if S[index:index+5] == 'esare':
            index += 5
            continue
        else:
            break
    elif S[index] == 'r':
        if S[index:index+6] == 'resare':
            index += 6
            continue
        elif S[index:index+7] == 'remaerd':
            index += 7
            continue
        else:
            break

if index == len(S):
    print('YES')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
word = input()
b = word
d = word
f = word
h = word
if 'eraser' in word:
  a = word.split('eraser')
  b = ''.join(a)
  h = b
if 'dreamer' in h:
  g = h.split('dreamer')
  h = ''.join(g)
if 'erase' in h:
  c = h.split('erase')
  d = ''.join(c)
  h = d
if 'dream' in h:
  e = h.split('dream')
  f = ''.join(e)
  h = f

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

Submission status: Wrong Answer

Solution code:
word = input()
b = word
d = word
f = word
h = word
if 'eraser' in word:
  a = word.split('eraser')
  b = ''.join(a)
  h = b
if 'erase' in h:
  c = h.split('erase')
  d = ''.join(c)
  h = d
if 'dream' in h:
  e = h.split('dream')
  f = ''.join(e)
  h = f
if 'dreamer' in h:
  g = h.split('dreamer')
  h = ''.join(g)
if h == (''):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S=input()

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

Submission status: Wrong Answer

Solution code:
S = input().strip()
#-----

i=0
while i <= len(S)-5:

    if S[i:(i+7)] == "dreamer":
        i=i+7
    elif S[i:(i+6)] == "eraser":
        i=i+6
    elif S[i:(i+5)] == "dream" or S[i:(i+5)] == "erase":
        i=i+5
    else:
        print("NO")
        break

print("YES")

Submission status: Wrong Answer

Solution code:
S = input().strip()
#-----

i=0
while i <= len(S)-5:

    if S[i:(i+7)] == "dreamer":
        i=i+7
    elif S[i:(i+6)] == "eraser":
        i=i+6
    elif S[i:(i+5)] == "dream" or S[i:(i+5)] == "erase":
        i=i+5
    else:
        print("NO")
        break

Submission status: Wrong Answer

Solution code:
def main(S):
    listdreamereraser = ['dreamer','eraser','dream','erase']
    while True:
        for i in listdreamereraser:
            if i in S[-len(i):]:
                S = S.replace(i,'',-1)
                break
        else:
            return False
        if len(S) == 0:
            return True

S = input()
print('YES' if main(S) else 'NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
listseer =['dreameraser', 'dreamerase', 'dreamer', 'eraser', 'dream', 'erase']
S = input()
for i in listseer:
    S = S.replace(i, '')
print('YES' if len(S) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
S = input()

# Greedyアルゴリズム
S = S[::-1]
print(S)

S = S.replace("resare","")
S = S.replace("esare","")
S = S.replace("remaerd","")
S = S.replace("maerd","")

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

s=input()

WL=['dream','dreamer','erase', 'eraser']
WLE5=['dream','eamer','erase','raser']
WD={'dream':5, 'eamer':7,'erase':5, 'raser':6}
def hantei(s):
    while True:
        if len(s)==0:
            return True
        elif len(s)<=4:
            return False
        elif len(s)<=7:
            if s in WL:
                return True
            else:
                return False
        saigo=s[-5:]
        if saigo in WLE5:
            num=WD[saigo]
            s=s[:-num]
        else:
            return False
print('YES' if hantei(s) else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

s=input()
if s=='':
    print('NO')
else:
    WL=['dream','dreamer','erase', 'eraser']
    WLE5=['dream','eamer','erase','raser']
    WD={'dream':5, 'eamer':7,'erase':5, 'raser':6}
    def hantei(s):
        while True:
            if len(s)==0:
                return True
            elif len(s)<=4:
                return False
            elif len(s)<=7:
                if s in WL:
                    return True
                else:
                    return False
            saigo=s[-5:]
            if saigo in WLE5:
                num=WD[saigo]
                s=s[:-num]
            else:
                return False
    print('YES' if hantei(s) else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

s=input()

WL=['dream','dreamer','erase', 'eraser']
WLE5=['dream','eamer','erase','raser']
WD={'dream':5, 'eamer':7,'erase':5, 'raser':6}
def hantei(s):
    while True:
        if len(s)==0:
            return True
        elif len(s)<=4:
            return False
        elif len(s)==5:
            if s in WL:
                return True
            else:
                return False
        elif len(s)==6:
            if s=='eraser':
                return True
            else:
                return False
        elif len(s)==7:
            if s=='dreamer':
                return True
            else:
                False
        saigo=s[-5:]
        if saigo in WLE5:
            num=WD[saigo]
            s=s[:-num]
        else:
            return False
print('YES' if hantei(s) else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

s=input()

WL=['dream','dreamer','erase', 'eraser']
WLE5=['dream','eamer','erase','raser']
WD={'dream':5, 'eamer':7,'erase':5, 'raser':6}
def hantei(s):
    while True:
        if len(s)==0:
            return True
        elif len(s)<=4:
            return False
        saigo=s[-5:]
        if saigo in WLE5:
            num=WD[saigo]
            s=s[:-num]
        else:
            return False
print('YES' if hantei(s) else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

s=input()

WL=['dream','dreamer','erase', 'eraser']
WLE5=['dream','eamer','erase','raser']
WD={'dream':5, 'eamer':7,'erase':5, 'raser':6}
def hantei(s):
    while True:
        if len(s)==0:
            return True
        elif len(s)<4:
            return False
        saigo=s[-5:]
        if saigo in WLE5:
            num=WD[saigo]
            s=s[:-num]
        else:
            return False
print('YES' if hantei(s) else 'NO')

Submission status: Wrong Answer

Solution code:
S=input()
T=""
N=len(S)
t=["dream","erase"]
r=[]
flag=True
check=True
if N<5:
    print("NO")
    exit()

for i in range(0,N,5):
    l=""
    l=l+S[i]
    r.append(S[i])
    if (i+1)>=N:
        check=False
        break
    l=l+S[i+1]
    r.append(S[i+1])
    if (i+2)>=N:
        check=False
        break
    l=l+S[i+2]
    r.append(S[i+2])
    if (i+3)>=N:
        check=False
        break
    l=l+S[i+3]
    r.append(S[i+3])
    if (i+4)>=N:
        check=False
        break
    l=l+S[i+4]
    r.append(S[i+4])
    print(l)
    if l not in t:
        print("NO")
        exit()
        flag=False
if check:
    print("YES")
    exit()
d=N%5
if d==0:
    pass
elif d==2:
    pass
else:
    print("NO")
    exit()

m=["er"]
a=r[-2]+r[-1]
print(a)
if a in m:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
# dream dreamer erase eraser 
while len(s)>0:
	if (s[-1]=="r") & (s[-7:]=="dreamer"):
		s.rstrip("dreamer")
	elif (s[-1]=="r") & (s[-6:]=="eraser"):
		s.rstrip("eraser")
	elif (s[-1]=="e") & (s[-5:]=="erase"):
		s.rstrip("erase")
	elif (s[-1]=="m") & (s[-5:]=="dream"):
		s.rstrip("dream")
	else:
		break
		
if len(s)>0:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
# dream dreamer erase eraser 
while len(s)>0:
	if (s[-1]=="r") & (s[-7]=="dreamer"):
		s.rstrip("dreamer")
	elif (s[-1]=="r") & (s[-6]=="eraser"):
		s.rstrip("eraser")
	elif (s[-1]=="e") & (s[-5]=="erase"):
		s.rstrip("erase")
	elif (s[-1]=="m") & (s[-5]=="dream"):
		s.rstrip("dream")
	else:
		break
		
if len(s)>0:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

T = ["dream","dreamer","erase","eraser"]
flag = True
for i in range(len(S)):
    if (flag == False) or (len(S) == 0):
        break
    if S[-5:] in T:
        S = S[:-5]
    elif S[-6:] in T:
        S = S[:-6]
    else:
        print("NO")
        flag = False
if flag == True:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = input()

s.replace('dreamer','')
s.replace('eraser','')
s.replace('dream','')
s.replace('erase','')

if len(s) > 0:
  print('NO')
else:
  print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
A = ['dream','dreamer','erase', 'eraser']
while(len(s)!=0):
    cs = s
    for i in range(len(A)):
        if (s.startswith(str(A[i]))):
            #print(A[len(A[i])+1:])
            s = s[len(A[i]):]
    if (cs == s):
        print('NO')
        sys.exit()
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

while True:
  if s == "":
    print('YES')
    break
  elif s[-5:] == 'dream' or s[-5:] == 'erase':
    s = s[:-5]
  elif s[-6:] == 'erase':
    s = s[:-6]
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  else:
    print('NO')
    break

Submission status: Wrong Answer

Solution code:
S = input()
l = ['maerd','remaerd', 'esare', 'resare']

def test(S,l):
    tmpS = S
    while len(tmpS) > 0:
        if tmpS[::-1] in l:
            print('YES')
            return
        if tmpS[-1:-6:-1] in l:
            tmpS = tmpS[:-5]
        elif tmpS[-1:-7:-1] in l:
            tmpS = tmpS[:-6]
        else:
      	    print('NO')
      	    return
    print('YES')
    return
  
test(S,l)

Submission status: Wrong Answer

Solution code:
S = input()
l = ['maerd','remaerd', 'esare', 'resare']

def test(S,l):
    tmpS = S
    while len(tmpS) > 0:
        if tmpS[::-1] in l:
            print('YES')
            return
        if tmpS[-1:-6:-1] in l:
            tmpS = tmpS[:-5]
        elif tmpS[-1:-7:-1] in l:
            tmpS = tmpS[:-6]
        else:
      	    print('NO')
      	    return
    #print('YES')
    #return
  
test(S,l)

Submission status: Wrong Answer

Solution code:
S = input()
l = ['maerd','remaerd', 'esare', 'resare']

def test(S,l):
    while len(S) > 0:
        if S[-1:-6:-1] in l:
    	    S = S[:-5]
        elif S[-1:-7:-1] in l:
    	    S = S[:-6]
        else:
      	    print('NO')
      	    return
    print('YES')
    return
  
test(S,l)

Submission status: Wrong Answer

Solution code:
s = input()

pos = len(s)
while pos >= 0:
    if s[pos-6:pos] == 'eraser':
        pos -= 6
    elif s[pos-5:pos] == 'erase':
        pos -= 5
    elif s[pos-5:pos] == 'dream':
        pos -= 5
    elif s[pos-6:pos] == 'dreamer':
        pos -= 6
    else:
        break
print('YES' if pos <= 0 else 'NO')

Submission status: Wrong Answer

Solution code:
def main(s):
    e = ["dreamer","eraser","dream","erase"]
    #キューの初期化
    t = [""]
    #キューが空でない間繰り返し
    while len(t) > 0:
        val = t.pop(0)
        for i in e:
            tar = val + i
            #一致したら終了判定→キューに追加
            if s[:len(tar)] == tar:
                if s == tar:
                    return True
                else:
                    t.append(tar)
    return False

s = input()
print("Yes" if main(s) else "No")

Submission status: Wrong Answer

Solution code:
def main(s):
    t = ""
    e = ["dream","erase","eraser","dreamer"]
    while len(t) < len(s) :
        val = ""
        c = t
        #4種類の文字を現在のtの末尾に追加し、そこまで一致するか判断
        for i in e:
            val = t + i
            if s[:len(val)] != val:
                continue
            #そこまで一致したら終了判定に
            else:
                t = val
                break
        #sと完全一致で処理終了
        if s == t:
            return True
        #tが変わってなければ終了
        if t == c:
            return False


s = input()
print("Yes" if main(s) else "No")

Submission status: Wrong Answer

Solution code:
S=input()
flag=False
while True:
    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:
        break

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

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
ans = ["maerd","remaerd","esare","resare"]
flag = 1
while len(s) != 0 and flag == 1:
    flag = 0
    if s[:5] in ans:
        s = s[5:]
        flag = 1
    elif s[:7] in ans:
        s = s[7:]
        flag = 1
        
if flag == 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
S=list(input())
yes_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  if len(S)==1 or (not S[0] == "e" or not S[0] == "d") or (S[:2]==list("ee") or S[:2]==list("dd")):
    break

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Submission status: Wrong Answer

Solution code:
S=list(input())
yes_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  if len(S)==1 or (not S[0] == "e" or S[0] == "d") or (S[:2]==list("ee") or S[:2]==list("dd")):
    break

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Submission status: Wrong Answer

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

continue_flag = True

# 文字列sにlist_poolのどれかの単語と一致する部分があるか後方からチェック
while continue_flag is True and len(s) > 0:
    continue_flag = False
    for word in list_pool:
        if s.endswith(word):
            s = s.replace(word, '')
            continue_flag = True

if continue_flag is True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

continue_flag = True

# 文字列sにlist_poolのどれかの単語と一致する部分があるか後方からチェック
while continue_flag is True and len(s) > 0:
    continue_flag = False
    for word in list_pool:
        if s.endswith(word):
            s = s.replace(word, '')
            continue_flag = True

if continue_flag is True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

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

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

Submission status: Wrong Answer

Solution code:
s = input()

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

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

Submission status: Wrong Answer

Solution code:
s = input()

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

Submission status: Wrong Answer

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