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 = str(input())
pntr = 0
flg = 1


while pntr <= len(S) - 1:
	if S[pntr] == "d":
		if pntr + 7 <= len(S) - 1:
			if S[pntr + 7] == "a":
				if S[pntr : pntr + 5] == "dream":
					pntr += 5
				else:
					flg = 0
					break
			else:
				if S[pntr : pntr + 7] == "dreamer":
					pntr += 7
				else:
					flg = 0
					break
		elif pntr + 4 <= len(S) - 1 and S[pntr : pntr + 5] == "dream":
			pntr += 5
		else:
			flg = 0
			break
			
	elif S[pntr] == "e":
		if pntr + 5 <= len(S) - 1 and S[pntr : pntr + 6] == "eraser":
			pntr += 6
			# print("eraser")
		elif pntr + 4 <= len(S) - 1 and S[pntr : pntr + 5] == "erase":
			pntr += 5
			# print("erase")
		else:
			flg = 0
			break
	else:
		flg = 0
		break
		
if flg:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    while len(s) != 0:
        flag = False
        for w in words:
            if s[-len(w):] == w:
                s = s[:-len(w)]
                flag = True
                break
        if not flag:
            return 'NO'
    return 'YES'

Submission status: Wrong Answer

Solution code:
# Me
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    while len(s) == 0:
        flag = False
        for w in words:
            if s[-len(w):] == w:
                s = s[:-len(w)]
                flag = True
                break
        if not flag:
            return 'NO'
    return 'YES'


print(check(input()))

Submission status: Wrong Answer

Solution code:
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    while len(s) == 0:
        for w in words:
            if s[-len(w):] == w:
                s = s[:-len(w)]
                break
        return 'NO'
    return 'YES'


print(check(input()))

Submission status: Wrong Answer

Solution code:
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    while True:
        if len(s) == 0:
            return 'YES'

        for w in words:
            if s[-len(w):] == w:
                s = s[:-len(w)]
                break
            return 'NO'


print(check(input()))

Submission status: Wrong Answer

Solution code:
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    while True:
        if len(s) == 0:
            return 'YES'

        for w in words:
            if len(s) > len(w) and s[-len(w):] == w:
                s = s[:len(s)]
                break
            if len(s) == len(w) and s == w:
                s = ''
                break
            return 'NO'


print(check(input()))

Submission status: Wrong Answer

Solution code:
def check(s):
    s = s.replace('dreamer', '')
    s = s.replace('dream', '')
    s = s.replace('eraser', '')
    s = s.replace('erase', '')
    if len(s) != 0:
        return 'NO'
    return 'YES'


print(check(input()))

Submission status: Wrong Answer

Solution code:
def check(t):
    words = [
            'eraser',
            'erase',
            'dreamer',
            'dream',
            ]

    for w in words:
        if len(t) > len(w) and t[-len(w):] == w:
            return t[:len(w)], True
        if len(t) == len(w) and t == w:
            return '', True
    return '', False


s = input()
if len(s) == 0:
    print('YES')
    exit()
while True:
    s, ok = check(s)
    if not ok:
        print('NO')
        exit()
    if len(s) == 0:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
def check(s):
    words = [
            'eraser',
            'erase',
            'dreamer',
            'dream',
            ]

    for w in words:
        if len(s) > len(w) and s[-len(w):] == w:
            return s[:len(w)], True
        if len(s) == len(w) and s == w:
            return '', True
    return '', False


s = input()
if len(s) == 0:
    print('YES')
    exit()
while True:
    s, ok = check(s)
    if not ok:
        print('NO')
        exit()
    if len(s) == 0:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
def check(s):
    s = s.replace('dreamer', '')
    s = s.replace('dream', '')
    s = s.replace('eraser', '')
    s = s.replace('erase', '')
    if len(s) != 0:
        return 'NO'
    return 'YES'


s = input()
print(check(s))

Submission status: Wrong Answer

Solution code:
def check(s):
    s = s.replace('dreamer', '')
    s = s.replace('dream', '')
    s = s.replace('eraser', '')
    s = s.replace('erase', '')
    if len(s) == 0:
        return 'NO'
    return 'YES'


s = input()
print(check(s))

Submission status: Wrong Answer

Solution code:
# Me
def check(s):
    words = [
            'dreamer',
            'dream',
            'eraser',
            'erase',
            ]

    for w in words:
        if len(s) > len(w) and s[-len(w):] == w:
            return s[:len(w)], True
        if len(s) == len(w) and s == w:
            return '', True
    return '', False


s = input()
if len(s) == 0:
    print('YES')
    exit()
while True:
    s, ok = check(s)
    if not ok:
        print('NO')
        exit()
    if len(s) == 0:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
def check(s):
    s = s.replace('dream', '')
    s = s.replace('dreamer', '')
    s = s.replace('erase', '')
    s = s.replace('eraser', '')
    if s != '':
        return 'NO'
    return 'YES'


s = input()
print(check(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# Me
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    for w in words:
        if len(s) > len(w) and s[-len(w):] == w:
            return s[:len(w)], True
        if len(s) == len(w) and s == w:
            return '', True
    return '', False


s = input()
if len(s) == 0:
    print('YES')
    exit()
while True:
    s, ok = check(s)
    if not ok:
        print('NO')
        exit()
    if len(s) == 0:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
# Me
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    for w in words:
        if len(s) > len(w) and s[-len(w):] == w:
            return s[:len(w)], True
        if len(s) == len(w):
            return '', True
    return '', False


s = input()
if len(s) == 0:
    print('YES')
    exit()
while True:
    s, ok = check(s)
    if not ok:
        print('NO')
        exit()
    if len(s) == 0:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    for w in words:
        if len(s) > len(w) and s[-len(w):] == w:
            return s[:len(w)], True
        if len(s) == len(w):
            return '', True
    return '', False


s = input()
while True:
    s, ok = check(s)
    if not ok:
        print('NO')
        exit()
    if len(s) == 0:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
def solve():
    S = input()
    # print(S, len(S))

    words = ("dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1])

    def recur(i):
        if i >= len(S):
            return True

        for word in words:
            if S[i:i + len(word)] == word:
                if recur(i + len(word)):
                    return True
        return False

    ans = recur(0)

    return ans


if __name__ == '__main__':
    res = solve()
    if res:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
S = str(input())
ex = ['dream','dreamer','erase','eraser']
f=0
while S!='':
    for i in range(4):
        if S[::-1][:len(ex[i])] == ex[i][::-1]:
            S=S[:-len(ex[i])]
            break
        else:
            f+=1
    if f==4:
        break
if f==4:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = str(input())
ex = ['dream','dreamer','erase','eraser']
f=0
while S!='':
    for i in range(4):
        if S[::-1][:len(ex[i])] == ex[i][::-1]:
            S=S[:-len(ex[i])]
        else:
            f+=1
    if f==4:
        break
if f==4:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
T = S

S = S.replace('eraser','')
S = S.replace('dreamer','')
S = S.replace('erase','')
S = S.replace('dream','')

T = T.replace('dreamer','')
T = T.replace('eraser','')
T = T.replace('dream','')
T = T.replace('erase','')

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

Submission status: Wrong Answer

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


def main():
    S = read().decode('utf-8')
    S = list(S.replace('\n', ''))[::-1]
    T = [
            list('dream')[::-1],
            list('dreamer')[::-1],
            list('erase')[::-1],
            list('eraser')[::-1]
        ]

    while len(S) != 0:
        if S[0:5] == T[0] or S[0:5] == T[2]:
            del S[0:5]
        elif S[0:6] == T[1]:
            del S[0:7]
        elif S[0:6] == T[3]:
            del S[0:6]
        else:
            print('NO')
            sys.exit()

    print('YES')


main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 文字列反転
def rev (s):
    _re=''.join(list(reversed(s)))
    return _re
 
name = ['dream','dreamer','eraser','erase']
S = input()
S_re = rev(S)
can = False
can2 = False
for i in range(len(S_re)):
    for div in name:
        if len(S_re[i:]) >= len(div):
            if S_re[i:i+len(div)]==rev(div) :
                i+=len(div)
                can = True
        if can :
            can2 = True
            break
    if not can2 :
        break
if can2 and i==len(S_re)-1:
    print('YES')
else :
    print('NO')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 文字列反転
def rev (s):
    _re=''.join(list(reversed(s)))
    return _re

name = ['dream','dreamer','eraser','erase']
S = input()
S_re = rev(S)
can2 = False
i= 0
while i < len(S_re):
    can = False
    for div in name:
        if len(S_re[i:]) >= len(div):
            if S_re[i:i+len(div)]==rev(div) :
                i+=len(div)
                can = True
                break
    if can :
        can2 = True
    else:
        can2 = False
        break
if can2:
    print('YES')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 文字列反転
def rev (s):
    _re=''.join(list(reversed(s)))
    return _re

name = ['dream','dreamer','eraser','erase']
S = input()
S_re = rev(S)
can = False
can2 = False
for i in range(len(S_re)):
    for div in name:
        if len(S_re[i:]) >= len(div):
            if S_re[i:i+len(div)]==rev(div) :
                i+=len(div)
                can = True
        if can :
            can2 = True
            break
    if not can2 :
        break
if can2 and i==len(S_re)-1:
    print('YES')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
def rev (s):
    _re=''.join(list(reversed(s)))
    return _re

name = ['dream','dreamer','eraser','erase']
S = input()
S_re = rev(S)
can = False
can2 = False
for i in range(len(S_re)):
    for div in name:
        if len(S_re[i:]) >= len(div):
            if S_re[i:i+len(div)]==rev(div) :
                print(S_re[i:i+len(div)])
                i+=len(div)
                can = True
        if can :
            can2 = True
            break
    if not can2 :
        break
if can2 and i==len(S_re)-1:
    print('YES')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
def rev (s):
    _re=''.join(list(reversed(s)))
    return _re

name = ['dream','dreamer','eraser','erase']
S = input()
S_re = rev(S)
can = False
can2 = False
for i in range(len(S_re)):
    for div in name:
        if len(S_re[i:]) >= len(div):
            if S_re[i:i+len(div)]==rev(div) :
                i+=len(div)
                can = True
        if can :
            can2 = True
            break
    if not can2 :
        break
if can2 :
    print('YES')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
words=["dreamer","eraser","dream","erase"]
add=0
while add!=len(s):
    cnt=0
    for i in words:
        length=len(i)
        word=s[add:add+length][::-1]
        if word==i:
            add +=length
            break
        else:cnt +=1
    if cnt==4:print("No");exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s= input()
u= s[::-1]
 
k=["resare","esare","remaerd","maerd"]
 
l=u.replace("resare","")
d=l.replace("esare","")
h=d.replace("remaerd","")
w=h.replace("maerd","")
  
    
if w:
  print("YES")
  
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s= input()
u= s[::-1]
 
k=["resare","esare","remaerd","maerd"]
 
l=u.replace("resare","")
d=l.replace("esare","")
h=d.replace("remaerd","")
w=h.replace("maerd","")
  
    
if w:
  print("Yes")
  
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s= input()
u= s[::-1]
 
k=["resare","esare","remaerd","maerd"]
 
l=u.replace("resare","")
d=l.replace("esare","")
h=d.replace("remaerd","")
w=h.replace("maerd","")
  
print(w)    
if w:
  print("Yes")
  
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s= input()
u= s[::-1]
 
k=["resare","esare","remaerd","maerd"]
 
l=u.replace("resare","")
d=l.replace("esare","")
h=d.replace("remaerd","")
w=h.replace("maerd","")
  
print(w)    
if s:
  print("Yes")
  
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s= input()
u= s[::-1]
 
k=["resare","esare","remaerd","maerd"]
 
for i in k:
  if u.find(i):
    u.replace(i,"")
    
if s:
  print("Yes")
  
else:
  print("No")

Submission status: Wrong Answer

Solution code:
S=input()
f=True
while len(S)>0:
    if S.endswith('dream') or S.endswith('erase'):
        S=S[:-5]
    elif S.endswith('dreamer') or S.endswith('eraser'):
        S=S[:-6]
    else:
        f=False
        break
print('YES' if f else 'NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()

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

Submission status: Wrong Answer

Solution code:
S=input()
f=True
while len(S)>0:
    if len(S)>=5 and S[-5:] in ['dream','erase']:
        S=S[:-5]
    elif len(S)>=6 and S[-6:] in ['dreamer','eraser']:
        S=S[:-6]
    else:
        f=False
        break
print('YES' if f else 'NO')

Submission status: Wrong Answer

Solution code:
a=input()
l=["dreamer","eraser","dream","erase"]
for i in range(len(a)//5):
    for i in l:
        if a[-7:]==i:
            a=a[:-7]
        elif a[-6:]==i:
            a=a[:-6]
        elif a[-5:]==i:
            a=a[:-5]
        else:
            pass
if len(a)==0: 
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s= input()
u= s[::-1]
 
k=["esare","resare","maerd","remaerd"]
 
for i in k:
  if u.find(i):
    u.replace(i,"")
    
if s:
  print("Yes")
  
else:
  print("No")

Submission status: Wrong Answer

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

k=["esare","resare","maerd","remaerd"]

for i in k:
  if u.find(i):
    u.replace(i,"")
    
if u==[""]:
  print("Yes")
  
else:
  print("No")

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
S = S.replace('maerd', '')
S = S.replace('esare', '')
S = S.replace('resare', '')
S = S.replace('remaerd', '')
if S == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
S = S.replace('resare', '')
S = S.replace('remaerd', '')
S = S.replace('maerd', '')
S = S.replace('esare', '')
if S == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
S = S.replace('remaerd', '')
S = S.replace('resare', '')
S = S.replace('maerd', '')
S = S.replace('esare', '')
if S == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
S = S.replace('maerd', '')
S = S.replace('remaerd', '')
S = S.replace('esare', '')
S = S.replace('resare', '')
if S == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

for i in l:
  s = s.replace(i,'')

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

Submission status: Wrong Answer

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

for i in l:
  s = s.replace(i,'')

if s == "":
  print('OK')
else:
  print('NG')

Submission status: Wrong Answer

Solution code:
import sys

#+++++
		
def main():
	s = input()
	ww=['dream','dreamer','erase','eraser']
	
	s=s[::-1]
	wwr=[w[::-1] for w in ww]
	#print(wwrs)
	while len(s)>0:
		pa(s)
		is_ok=False
		for w in wwr:
			ll=len(w)
			ss=s[:ll]
			pa((2,ss,w))
			if ss == w:
				is_ok=True
				pa((1,ss,ll))
				s=s[ll:]
		if not is_ok:
			return 'No'		
		
	print('Yes')
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

flag = 0
while(1):
  if len(s) == 0:
    flag = 1
    break
  elif s[0:7] == "dreamer":
    s = s[7:]
  elif s[0:6] == "eraser":
    s = s[6:]
  elif s[0:5] == "dream":
    s = s[5:]
  elif s[0:5] == "erase":
    s = s[5:]
  else:
    break
  print(s)

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

Submission status: Wrong Answer

Solution code:
s = input()

flag = 0
while(1):
  if len(s) == 0:
    flag = 1
    break
  elif s[0:5] == "dream":
    s = s[5:]
  elif s[0:5] == "erase":
    s = s[5:]
  elif s[0:6] == "eraser":
    s = s[6:]
  elif s[0:7] == "dreamer":
    s = s[7:]
  else:
    break

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

Submission status: Wrong Answer

Solution code:
dreamer = "dreamer"
eraser = "eraser"
dream = "dream"
erase = "erase"


def main():
    S = input()
    i = len(S)
    while 0 < i:
        pre = i
        if S[-len(dreamer):] == dreamer:
            i -= len(dreamer)
        if S[-len(eraser):] == eraser:
            i -= len(eraser)
        if S[-len(dream):] == dream:
            i -= len(dream)
        if S[-len(erase):] == erase:
            i -= len(erase)
        if pre == i:
            print("NO")
            return
    print("YES")
    return


main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
S = input()
flag = False
S = S.replace("eraser","")
S = S.replace("erase","")
S = S.replace("dreamer","")
S = S.replace("dream","")

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
S = input()
flag = False
st_match = ["erase",'dream']
while len(S)>0:
    for st in st_match:
        if(S.startswith(st)):
            S=S[len(st):]
            if(S.startswith('er') and S.startswith('era')==False):
                S=S[2:]
            elif(S.startswith('r')):
                S=S[1:]
            flag=True
            break
    if(flag):
        flag=False
        continue
    else:
        break
if(len(S)==0):
    print('Yes')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
S = input()
flag = False
st_match = ["erase",'dream']
while len(S)>0:
    for st in st_match:
        if(S.startswith(st)):
            S=S[len(st):]
            if(S.startswith('er') and S.startswith('era')==False):
                S=S[2:]
            elif(S.startswith('r')):
                S=S[2:]
            flag=True
            break
    if(flag):
        flag=False
        continue
    else:
        break
if(len(S)==0):
    print('Yes')
else:
    print('NO')

Submission status: Wrong Answer

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

while True:
  if x[:5] == "maerd":
    x = x[5:]
  elif x[:7] == "remaerd":
    x = x[7:]
  elif x[:5] == "esare":
    x = x[5:]
  elif x[:6] == "resare":
    x = x[6:]
  else:
    break
    
if len(x) == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
S = input()
reversed_S = ''.join(list(reversed(S)))  #Sを反転した文字列

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

# divideの各要素も反転
for i in range(len(divide)):
    divide[i] = ''.join(list(reversed(divide[i])))

# 全体が分けきれるか
can = 1

# divideが含まれるか
can2 = 0

for i in range(len(S)):
    for j in range(len(divide)):
        if reversed_S[i:i + len(divide[j])] == divide[j]:
            can2 = 1
            i += len(divide[j])
            break

    if can2 == 0:
        can = 0
        break

if can == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
reversed_S = ''.join(list(reversed(S)))  #Sを反転した文字列

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

# divideの各要素も反転
for i in range(len(divide)):
    divide[i] = ''.join(list(reversed(divide[i])))

# 全体が分けきれるか
can = 1

# divideが含まれるか
can2 = 0

for i in range(len(S)):
    for j in range(len(divide)):
        if reversed_S[i:len(divide[j])] == divide[j]:
            can2 = 1
            i += len(divide[j])
            break

    if can2 == 0:
        can = 0
        break

if can == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys

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

d ='maerd'
dr = 'remaerd'
e = 'esare'
er = 'resare'

i = 0
while True:
    try:
        if s[i:i+5] == d or s[i:i+5] == e:
            i += 5
            if i == len(s):
                print('YES')
                sys.exit(0)
        
        elif s[i:i+7] == dr or s[i:i+7] == er:
            i += 7
            if i == len(s):
                print('YES')
                sys.exit(0)
            
        else:
            print('NO')
            sys.exit(0)
            
    except Exception as err:
        print('NO')
        sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys

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

d ='maerd'
dr = 'remaerd'
e = 'esare'
er = 'resare'

i = 0
while True:
    try:
        if s[i:i+5] == d or s[i:i+5] == e:
            i += 5
            if i == len(s):
                print('YES')
                sys.exit(0)
        
        elif s[i:i+7] == dr or s[i:i+7]:
            i += 7
            if i == len(s):
                print('YES')
                sys.exit(0)
            
        else:
            print('NO')
            sys.exit(0)
            
    except Exception as err:
        print('NO')
        sys.exit(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
rev_s = s[::-1]
text = rev_s.replace('remaerd', '').replace('maerd', '').replace('resare', '').replace('esare', '')

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

Submission status: Wrong Answer

Solution code:
s = input()
text = s.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')

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

Submission status: Wrong Answer

Solution code:
s = input()
text = s.replace('dreamr', '').replace('dream', '').replace('eraser', '').replace('erase', '')

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

Submission status: Wrong Answer

Solution code:
s = input()
text = s.replace('dream', '').replace('dream', '').replace('eraser', '').replace('erase', '')

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

Submission status: Wrong Answer

Solution code:
s = input()

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

def func(s):
  bool = False
  for kw in kws:
    if s.startswith(kw):
      bool = bool or func(s[len(kw):])
  return bool

result = func(s)

if result:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s="".join(reversed(input()))
items=["dream","dreamer","erase","eraser"]
r_items=[]
for i in items:
  r_items.append("".join(reversed(i)))
for i in r_items:
  s=s.replace(i,"")
if s:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
s="".join(reversed(input()))
items=["dream","dreamer","erase","eraser"]
r_items=[]
for i in items:
  r_items.append("".join(reversed(i)))
for i in r_items:
  print(i)
  s=s.replace(i,"")
if s:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
s="".join(reversed(input()))
items=["dream","dreamer","erase","eraser"]
r_items=[]
for i in items:
  r_items.append("".join(reversed(i)))
for i in r_items:
  s.replace(i,"")
if s:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
s="".join(reversed(input()))
items=["dream","dreamer","erase","eraser"]
r_items=[]
for i in items:
  r_items.append("".join(reversed(i)))
for i in r_items:
  s.replace(i,"")
if s:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s="".join(reversed(input()))
items=["dream","dreamer","erase","eraser"]
r_items=[]
for i in items:
  r_items.append("".join(reversed(i)))
for i in r_items:
  s.replace(i,"")
if s=="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s="".join(reversed(input()))
items=["dream","dreamer","erase","eraser"]
r_items=[]
for i in items:
  r_items.append("".join(reversed(i)))
for i in r_items:
  s.replace("",i)
if s=="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

def reverse(string):
  return ''.join(reversed(string))

def split_and_join(string, word):
  return ''.join(string.split(word))

reversed_s = reverse(s)
ls = ["eraser", "dreamer", "erase", "dream"]

for word in ls:
  reversed_word = reverse(word)
  reversed_s = split_and_join(reversed_s, reversed_word)
  
ans = "YES" if reversed_s == '' else "NO"

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

def reverse(string):
  return ''.join(reversed(string))

def split_and_join(string, word):
  return ''.join(string.split(word))

reversed_s = reverse(s)
ls = ["eraser", "dreamer", "erase", "dream"]

for word in ls:
  reversed_word = reverse(word)
  reversed_s = split_and_join(reversed_s, reversed_word)
  
print(reversed_s)

Submission status: Wrong Answer

Solution code:
x = "".join(list(reversed(input())))

while True:
  if x.find('remaerd') == 0:
    x = x[7:]
  elif x.find('maerd') == 0:
    x = x[5:]
  elif x.find('resare') == 0:
    x = x[6:]
  elif x.find('esare') == 0:
    x = x[5:]
  else:
    print('Yes' if len(x) == 0 else 'No')
    break

Submission status: Wrong Answer

Solution code:
x = input()
y = ['dreamer', 'dream', 'eraser', 'erase']

while True:
  if x.find(y[0]) == 0:
    x = x[len(y[0]):]
  elif x.find(y[1]) == 0:
    x = x[len(y[1]):]
  elif x.find(y[2]) == 0:
    x = x[len(y[2]):]
  elif x.find(y[3]) == 0:
    x = x[len(y[3]):]
  else:
    print('Yes' if len(x) == 0 else 'No')
    break

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
l = len(s)
dict = {'mae':5, 'rem':7, 'esa':5, 'res':6 }
dict2 = {'mae':'maerd', 'rem':'remaerd', 'esa':'esare', 'res':'resare' }
p = 0
while p < l:
  key =s[p:p+3]
  if key in dict:
    p= p + dict[key]
  else:
    flag = False
    break
  if p == l:
    if s[l-dict[key]:l+1] ==dict2[key]:
      flag = True
    else:
      flag = False 
  elif p > l:
    flag = False
    
if flag:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
l = len(s)
dict = {'mae':5, 'rem':7, 'esa':5, 'res':6 }

p = 0
while p < l:
  key =s[p:p+3]
  if key in dict:
    p= p + dict[key]
  else:
    flag = False
    break
  if p == l:
    flag = True
  elif p > l:
    flag = False
    
if flag:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
l = len(s)
dict = {'mae':5, 'rem':7, 'esa':5, 'res':5 }

p = 0
while p < l:
  key =s[p:p+3]
  if key in dict:
    p= p + dict[key]
  else:
    flag = False
    break
  if p == l:
    flag = True
  elif p > l:
    flag = False
    
if flag:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
dict = {'mae':5, 'rem':7, 'esa':5, 'res':5 }
s = s[::-1]
p = 0
while p < len(s):
  key =s[p:p+3]
  if key in dict:
    p= p + dict[key]
  else:
    flag = False
    break
  if p == len(s):
    flag = True
    
if flag:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
li=['dream','erase','dreamer','eraser']
s=input()
li=li[::-1]
i=0 
n=len(s)
ans=''
#print(s[0:4])
while i<n-4: 
    if s[i:i+6]==li[0]:
        ans+=s[i:i+6]
        i+=6 
    elif s[i:i+7]==li[1]:
        #i+=5 
        ans+=s[i:i+7]
        i+=7
    elif s[i:i+5]==li[3]:
        #i+=4 
        ans+=s[i:i+5]
        i+=5
    elif s[i:i+5]==li[2]:
        #i+=4 
        ans+=s[i:i+5]
        i+=5
    else:
        break 
#print(ans)
print('YES' if ans==s else 'NO')