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:
import sys

S = input()

while len(S) > 0:
    if len(S) < 5:
        print('NO')
        sys.exit(0)
    third = S[-3]
    if third == 'e':
        if len(S) < 5 or S[-5:] != 'dream':
            print('NO')
            sys.exit(0)
        S = S[:-5]
    if third == 'a':
        if len(S) < 5 or S[-5:] != 'erase':
            print('NO')
            sys.exit(0)
        S = S[:-5]
    if third == 'm':
        if len(S) < 7 or S[-7:] != 'dreamer':
            print('NO')
            sys.exit(0)
        S = S[:-7]
    if third == 's':
        if len(S) < 6 or S[-6:] != 'eraser':
            print('NO')
            sys.exit(0)
        S = S[:-6]
    else:
        print('NO')
        sys.exit(0)

print('YES')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''

s=input().rstrip("\n")
e=len(s)
l=["dream","dreamer","erase","eraser"]
for i in range(len(s))[::-1]:
    #print(s[i:e])
    if s[i:e] in l:
        e-=i
        s=s[:i]  
        continue
    if len(s[i:e])>7:
        print("NO")
        sys.exit()
if len(s)>0 and s not in l:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''

s=input().rstrip("\n")
e=len(s)
l=["dream","dreamer","erase","eraser"]
for i in range(len(s))[::-1]:
    #print(s[i:e])
    if s[i:e] in l:
        e-=i   
        continue
    if len(s[i:e])>7:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
ans='YES'
while s!='':
  if s[:7]=='dreamer':
    s=s.lstrip('dreamer')
  elif s[:5]=='dream':
    s=s.lstrip('dream')
  elif s[:6]=='eraser':
    s=s.lstrip('eraser')
  elif s[:5]=='erase':
    s=s.lstrip('erase')
  else:
    ans='NO'
    break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(input())
index = 0
while index < len(s):
    if "".join(s[index:index+7]) == "dreamer":
        index += 7
    elif "".join(s[index:index+6]) == "eraser":
        index += 6
    elif "".join(s[index:index+5]) == "erase" or "".join(s[index:index+5]) == "dream":
        index += 5
    elif "".join(s[index:index+4]) == "aser":
        index += 4
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s = list(input())
index = 0
while index < len(s):
    if "".join(s[index:index+7]) == "dreamer":
        index += 7
    elif "".join(s[index:index+6]) == "eraser":
        index += 6
    elif "".join(s[index:index+5]) == "erase" or "".join(s[index:index+5]) == "dream":
        index += 5
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import deque

s = input()
q = deque(list(s))

while q:
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if subs == 'erase' and len(q) != 0 and q[0] == 'r':
      q.popleft()
    if subs == 'dream' and len(q) == 2 and q[0]+q[1] == 'er':
      q.popleft()
      q.popleft()
    if subs == 'dream' and len(q) >= 3 and q[0]+q[1] == 'er' and q[2] != 'a':
      q.popleft()
      q.popleft()
  else:
    print(q)
    print('NO')
    exit()
    
print('YES')

Submission status: Wrong Answer

Solution code:
from collections import deque

s = input()
q = deque(list(s))

while q:
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if subs == 'erase' and len(q) != 0 and q[0] == 'r':
      q.popleft()
    if subs == 'dream' and len(q) == 2 and q[0]+q[1] == 'er':
      q.popleft()
      q.popleft()
    if subs == 'dream' and len(q) >= 3 and q[0]+q[1] == 'er' and q[2] != 'e':
      q.popleft()
      q.popleft()
  else:
    print('NO')
    exit()
    
print('YES')

Submission status: Wrong Answer

Solution code:
from collections import deque

s = input()
q = deque(list(s))

while q:
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if subs == 'erase' and len(q) != 0 and q[0] == 'r':
      q.popleft()
  else:
    print('NO')
    exit()
    
print('YES')

Submission status: Wrong Answer

Solution code:
from collections import deque

s = input()
q = deque(list(s))

while q:
  print(q)
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if subs == 'erase' and len(q) != 0 and q[0] == 'r':
      q.popleft()
  else:
    print('NO')
    exit()
    
print('YES')

Submission status: Wrong Answer

Solution code:
from collections import deque

s = input()
q = deque(list(s))

while q:
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if len(q) != 0 and q[0] == 'r':
      q.popleft()
  else:
    print('NO')
    exit()
    
print('YES')

Submission status: Wrong Answer

Solution code:
from collections import deque

s = input()
q = deque(list(s))

while q:
  try:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if len(q) != 0 and q[0] == 'r':
      q.popleft()
     
  except:
    print('NO')
    exit()
    
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = str(input())
ls = ["dream","dreamer","erase","eraser"]
while True:
    k = s[-5:]
    if k not in ls:
        t = s[-6:]
        if t not in ls:
            l = s[-7:]
            if l not in ls:
                print("NO")
                sys.exit()
            else:
                s = s[:-7]
                continue
                if s == "":
                    print("YES")
                    break
        else:
            s = s[:-6]
            continue
            if s == "":
                print("YES")
                break
    else:
        s = s[:-5]
        if s == "":
            print("YES")
            break

Submission status: Wrong Answer

Solution code:
def main():
    S = input()

    idx = 0
    for i in range(10**6):
        if idx >= len(S):
            break

        if S[idx:].startswith("dream"):
            idx += 5

        elif S[idx:].startswith("dreamer"):
            idx += 7
        
        elif S[idx:].startswith("erase"):
            idx += 5

        elif S[idx:].startswith("eraser"):
            idx += 6

        else:
            print("NO")
            exit()

    print("YES")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()

    idx = 0
    for i in range(10**6):
        if idx >= len(S):
            break

        print(S[idx:])

        if S[idx:].startswith("dream"):
            idx += 5

        elif S[idx:].startswith("dreamer"):
            idx += 7
        
        elif S[idx:].startswith("erase"):
            idx += 5

        elif S[idx:].startswith("eraser"):
            idx += 6

        else:
            print("NO")
            exit()

    print("YES")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()

    idx = 0
    for i in range(10**6):
        if idx >= len(S) - 1:
            break

        if S[idx:].startswith("dream"):
            idx += 5

        elif S[idx:].startswith("dreamer"):
            idx += 7
        
        elif S[idx:].startswith("erase"):
            idx += 5

        elif S[idx:].startswith("eraser"):
            idx += 6

        else:
            print("NO")
            exit()

    print("YES")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
S = input()
words = ("dream", "dreamer", "erase", "eraser")

while S:
    for word in words:
        if S.endswith(word):
            S = S[: -len(word)]
    else:
        break
print("NO") if S else print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
i = 0
flag = 0
while(True):
    if(s[i:i+5]) == "dream":
        if(i+5==n):
            break
        elif(s[i+5:i+10] =="dream"):
            i += 5
        elif(s[i+5:i+10] == "erase"):
            i += 5
        elif(s[i+5:i+7] == "er"):
            i += 7
            if(i==n):
                break
        else:
            flag = 1
            break

    elif(s[i:i+5]) == "erase":
        if(i+5==n):
            break
        elif(s[i+5:i+10] =="dream"):
            i += 5
        elif(s[i+5:i+10] == "erase"):
            i += 5
        elif(s[i+4:i+6] == "er"):
            i += 7
            if(i==n):
                break
        else:
            flag = 1
            break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
"""this is python work script"""

def solver(word):
    """solve this problem"""
    check_result = word.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')

    answer = 'YES'
    if check_result:
        answer = 'NO'

    return answer

def main():
    """main function"""
    input_word = input().rstrip()
    answer = solver(input_word)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()

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

Submission status: Wrong Answer

Solution code:
S = input()

s1 = S.replace('dreameraser', '').replace('dreamerase', '')
s2 = s1.replace('dreamer', '').replace('eraser', '')
s3 = s2.replace('dream', '').replace('erase', '')

print('YES' if s3 == '' else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()

lst = ['dream', 'dreamer', 'erase', 'eraser']
while s:
  flag = 0
  for elem in lst:
    if elem in s:
      s = s.replace(elem, '')
      flag = 1
      break
  if flag == 0:
    print('NO')
    quit()
print('YES')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

S = input()[::-1]

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

s = list(input())
s.reverse()
v = []
v.append(list("dream"))
v.append(list("erase"))
v.append(list("eraser"))
v.append(list("dreamer"))
for i in range(4):
    v[i].reverse()

now = 0
while(1):
    check = False
    for i in range(4):
        if now+len(v[i]) > len(s): continue
        tmp = ''.join(s[now:now+len(v[i])])
        x = ''.join(v[i])
        if tmp == x:
            print(tmp, x)
            check = True
            now += len(v[i])
        if check: break
    if not check: break
    if now == len(s): break

if check: 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 S == "":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
L=len(s)
newstring=''.join(list(reversed(s)))

while L>0:
    if newstring[:5]=="maerd":
        newstring=newstring[5:]

    elif newstring[:7]=="remaerd":
        newstring=newstring[7:]

    elif newstring[:5]=="esare":
        newstring=newstring[5:]

    elif newstring[:6]=="resare":
        newstring=newstring[6:]

    else:
        print("NO")
        exit()

print("YES")

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")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
flag = 0
S = S[::-1]
print(S)
while True:
    if S.startswith("maerd") or S.startswith("esare"):
        S = S[5:]
    elif S.startswith("remaerd"):
        S = S[7:]
    elif S.startswith("resare"):
        S = S[6:]
    elif S == "":
        break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

Submission status: Wrong Answer

Solution code:
S = input()
flag = 0
S = S[::-1]
while True:
    if S.startswith("maerd") or S.startswith("esare"):
        S = S[5:]
    elif S.startswith("remaerd"):
        S = S[7:]
    elif S.startswith("reesare"):
        S = S[6:]
    elif S == "":
        break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

Submission status: Wrong Answer

Solution code:
S = input()
flag = 0
while True:
    if S.startswith("dream"):
        str = S[5:]
        if str.startswith("eraser"):
            S = S[5:]
            S = S[6:]
        elif str.startswith("erase"):
            S = S[5:]
            S = S[5:]
        if S.startswith("dreamer"):
            S = S[7:]
        else:
            S = S[5:]
    if S.startswith("eraser"):
        S = S[6:]
        continue
    if S.startswith("dreamer"):
        S = S[7:]
    if S.startswith("erase"):
        S = S[5:]
    elif S == "":
        break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

Submission status: Wrong Answer

Solution code:
S = input()
flag = 0
while True:
    if S.startswith("dream"):
        str = S[5:]
        if str.startswith("eraser"):
            S = S[5:]
            S = S[6:]
        if str.startswith("erase"):
            S = S[5:]
            S = S[5:]
        if S.startswith("dreamer"):
            S = S[7:]
        else:
            S = S[5:]
    if S.startswith("eraser"):
        S = S[6:]
        continue
    if S.startswith("dreamer"):
        S = S[7:]
    if S.startswith("erase"):
        S = S[5:]
    elif S == "":
        break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

Submission status: Wrong Answer

Solution code:
S = input()
flag = 0
while True:
    if S.startswith("dream"):
        str = S[5:]
        if str.startswith("eraser"):
            S = S[5:]
            S = S[6:]
        if S.startswith("erase"):
            S = S[5:]
            S = S[5:]
        else:
            S = S[7:]
    if S.startswith("eraser"):
        S = S[6:]
        continue
    if S.startswith("dreamer"):
        S = S[7:]
    if S.startswith("erase"):
        S = S[5:]
    elif S == "":
        break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
flag = 0
while True:
    if S.startswith("dream") or S.startswith("erase"):
        S = S[5:]
        if S.startswith("ase"):
            S = S[3:]
        if S.startswith("aser"):
            S = S[4:]
    if S.startswith("dreamer"):
        S = S[7:]
    if S.startswith("eraser"):
        S = S[6:]
    elif S == "":
        break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

Submission status: Wrong Answer

Solution code:
li = input()
list = ['dream','dreamer','erase','eraser']
flag = 'NO'
for x in list:
  for y in list:
    z = x + y
    if z == li:
      flag = 'YES'
      
print(flag)

Submission status: Wrong Answer

Solution code:
li = input()
list = ['dream','dreamer','erase','eraser']
flag = 'No'
for x in list:
  for y in list:
    z = x + y
    if z == li:
      flag = 'YES'
      
  
print(flag)

Submission status: Wrong Answer

Solution code:
S = input()
X = 0
while X != len(S):
    flag = X
    if S[X:X+11] == "dreameraser":
        X = X+11
    if S[X:X+10] == "dreamerase":
        X = X + 10
    if S[X:X+7] == "dreamer":
        X = X + 7
    if S[X:X+5] == "dream":
        X = X + 5
    if S[X:X+6] == "eraser":
        X = X + 6
    if S[X:X+5] == "erase":
        X = X + 5
    if flag == X:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
db = ["dream", "erase"]
offset = 0
key = True
while key:
  if offset >= len(S): key = False
  if S[offset:offset+5] == db[0]:
    if S[offset:offset+7] == db[0]+"er": offset += 7
    else: offset += 5
  elif S[offset:offset+5] == db[1]:
    if S[offset:offset+6] == db[1]+"r": offset += 6
    else: offset += 5
  else: break
print("YNEOS"[key::2])

Submission status: Wrong Answer

Solution code:
S = input()
db = ["dream", "erase"]
offset = 0
key = True
while key:
  if offset >= len(S): key = False
  if S[offset:offset+5] == db[0]:
    if S[offset:offset+2] == db[0]+"er": offset += 7
    else: offset += 5
  elif S[offset:offset+5] == db[1]:
    if S[offset:offset+6] == db[1]+"r": offset += 6
    else: offset += 5
  else: break
print("YNEOS"[key::2])

Submission status: Wrong Answer

Solution code:
from collections import deque
str_l = ["dream", "dreamer", "erase" ,"eraser"]
s = input()
n = len(s)

deque = deque()
deque.append(0)

def str_plus(i):
    s1 = s[i]
    if s1 == "d":
        if s[i:i+5] == "dream":
            if s[i+5:i+7] == "er":
                return [i+5,i+7]
            else:
                return [i+5]
        else:
            return False
    if s1 == "e":
        if s[i:i+5] == "erase":
            if s[i+5:i+7] == "er":
                return [i+5,i+7]
            else:
                return [i+5]
        else:
            return False

ans = "NO"

while deque:
    i = deque.pop()
    if i == n:
        ans = "YES"
        break
    l = str_plus(i)
    if l != False and l != None:
        deque.extend(l)

print(ans)

Submission status: Wrong Answer

Solution code:
# C - 白昼夢

S = str(input())
S = S[::-1]
l = len(S)
i = 0
ans = 'Yes'
while True:
    if S[i:i+5] == 'maerd' or S[i:i+5] == 'esare':
        i += 5
        if i == l:
            break
    elif S[i:i+6] == 'resare':
        i += 6
        if i == l:
            break
    elif S[i:i+7] == 'remaerd':
        i += 7
        if i == l:
            break
    else:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
for p in range(1000):
  if s[-5:] == 'dream':
    s = s[:-5]
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  elif s[-5:] == 'erase':
    s = s[:-5]
  elif s[-6:] == 'eraser':
    s = s[:-6]
  if s == '':
    break
if s == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

def mojicut(s, r):
    n = s.replace(r, "", 1)
    return n


while len(s_rev) > 0:
    s_len = len(s_rev)
    for i in T_list:
        if s_rev.startswith(i):
            s_rev = mojicut(s_rev, i)
            break
    if len(s_rev) == s_len:
        break

if len(s_rev) > 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
s = input()
for p in range(10):
  if s[-5:] == 'dream':
    s = s[:-5]
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  elif s[-5:] == 'erase':
    s = s[:-5]
  elif s[-6:] == 'eraser':
    s = s[:-6]
  if s == '':
    break
if s == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
# 文字の反転
s_rev = s[::-1]
T_list = ['maerd', 'remaerd', 'esare', 'resare']

def mojicut(s, r):
    n = s.replace(r, "", 1)
    return n

while len(s_rev) > 0:
    s_len = len(s_rev)
    for i in T_list:
        if s_rev.startswith(i):
            s_rev = mojicut(s_rev, i)
            break
    if len(s_rev) == s_len:
        break

if len(s_rev) > 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
s = input()

word_list = ["dreamer","dream","eraser","erase"]
for i in word_list:
    s = s.replace(i,".")

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
s = input()

word_list = ["dream","dreamer","eraser","erase"]
for i in word_list:
    s = s.replace(i,".")

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

Submission status: Wrong Answer

Solution code:
init = input()

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

def reverseWord(str):
  return str[::-1]

def elimTheWord(str):
  for word in reversed_words:
    if str.find(word) == 0:
      str = str[len(word):]
  return str

reversed_words = list(map(reverseWord, words))

# main
target = reverseWord(init)

while True:
  pivot = elimTheWord(target)
  if pivot == '':
    print('Yes')
    break
  if pivot == target:
    print('No')
    break
  target = pivot

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
while len(S) > 0:
    if S[-5::1] == 'dream' or S[-5::1] == 'erase':
        S = S[:-5:1]
    elif S[-6::1] == 'eraser':
        S = S[:-6:1]
    elif S[-7::1] == 'dreamer':
        S = S[:-7:1]
    else:
        print('No')
        break

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

Submission status: Wrong Answer

Solution code:
s = input()
i = 0

while i < len(s):
    if s[i:i+11] == "dreameraser":
        i += 11
    elif s[i:i+10] == "dreamerase":
        i += 10
    elif s[i:i+5] == "dream" or s[i:i+5] == "erase":
        i += 5
    elif s[i:i+6] =="dreamer" or s[i:i+6] == "eraser":
        i += 6
    else:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
i = 0

while i < len(s):
    print(i)
    if s[i:i+11] == "dreameraser":
        i += 11
    elif s[i:i+10] == "dreamerase":
        i += 10
    elif s[i:i+5] == "dream" or s[i:i+5] == "erase":
        i += 5
    elif s[i:i+6] =="dreamer" or s[i:i+6] == "eraser":
        i += 6
    else:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
S= input()
i=0

while True:

    #末尾判定
    if S[i:i+7] == "dreamer" and i+7 == len(S):
        i += 7
        break
    if S[i:i+6] == "eraser" and i+6 == len(S):
        i += 6
        break
    if (S[i:i+5] == "erase" or S[i:i+5] == "dream") and i+5 == len(S):
        i += 5
        break

    if S[i:i+7] == "dreamer" and (S[i+8] == "d" or S[i+8] == "e" or i+7 == len(S)):
        i += 7
        continue

    if S[i:i+6] == "eraser" and (S[i+7] == "d" or S[i+7] == "e" or i+6 == len(S)):
        i += 6
        continue

    if S[i:i+5] == "erase" or S[i:i+5] == "dream":
        i += 5
        continue
    break

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

Submission status: Wrong Answer

Solution code:
import re

s = input()

m = re.match(r"^(dream|dreamer|erase|eraser)+$", s)

print("No" if m is None else "Yes")

Submission status: Wrong Answer

Solution code:
S= input()
i=0

while True:
    flag = False
    if S[i:i+7] == "dreamer":
        i += 7
        flag = True

    if S[i:i+6] == "eraser":
        i += 6
        flag = True
    
    if S[i:i+5] == "erase" or S[i:i+5] == "dream":
        i += 5
        flag = True

    if not flag:
        break

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

Submission status: Wrong Answer

Solution code:
S= input()
i=0

while True:
    flag = False
    if S[i:i+7] == "dreamer":
        i += 7
        flag = True

    if S[i:i+6] == "eraser":
        i += 6
        flag = True
    
    if S[i:i+5] == "erase" or S[i:i+5] == "dream":
        i += 5
        flag = True

    if not flag:
        break

if i == len(S):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def solve():

    S = input()

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

    while(True):
        if(len(S) == 0):
            break
        flag = False
        for w in words:
            if(S.endswith(w)):
                S = S[0:len(S) - len(w)]
                flag = True
        
        if(not flag):
            return
            
        
    print('YES')
    
solve()

Submission status: Wrong Answer

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

S = input()

## Logic

i = 0
while i < len(S):
    if S[i:i+5] == "erase":
        if i + 6 > len(S):
            break
        elif S[i+5] == "r":
            i = i + 6
        else:
            i = i + 5
    if S[i:i+5] == "dream":
        if i + 6 > len(S):
            break
        elif S[i+5:i+11] == "eraser":
            i = i + 11
        elif S[i+5:i+10] == "erase":
            i = i + 10
        elif S[i+5:i+7] == "er":
            i = i + 7
        else:
            i = i + 5
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

S = input()

## Logic

i = 0
while i < len(S):
    if S[i:i+5] == "erase":
        if i + 6 >= len(S):
            break
        elif S[i+5] == "r":
            i = i + 6
        else:
            i = i + 5
    if S[i:i+5] == "dream":
        if i + 6 >= len(S):
            break
        elif S[i+5:i+11] == "eraser":
            i = i + 11
        elif S[i+5:i+10] == "erase":
            i = i + 10
        elif S[i+5:i+7] == "er":
            i = i + 7
        else:
            i = i + 5
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

S = input()

## Logic

i = 0
while i < len(S):
    print(i)
    if S[i:i+5] == "erase":
        if i + 6 >= len(S):
            break
        elif S[i+5] == "r":
            i = i + 6
        else:
            i = i + 5
    if S[i:i+5] == "dream":
        if i + 6 >= len(S):
            break
        elif S[i+5:i+11] == "eraser":
            i = i + 11
        elif S[i+5:i+10] == "erase":
            i = i + 10
        elif S[i+5:i+7] == "er":
            i = i + 7
        else:
            i = i + 5
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

S = input()

## Logic

i = 0
while i < len(S):
    print(i)
    if S[i:i+5] == "erase":
        if i + 5 > len(S):
            break
        elif S[i+5] == "r":
            i = i + 6
        else:
            i = i + 5
    if S[i:i+5] == "dream":
        if i + 5 > len(S):
            break
        elif S[i+5:i+11] == "eraser":
            i = i + 11
        elif S[i+5:i+10] == "erase":
            i = i + 10
        elif S[i+5:i+7] == "er":
            i = i + 7
        else:
            i = i + 5
    else:
        print("NO")
        sys.exit()
print("YES")