Problem:


Score : 300 points

Problem Statement

You are given a string S consisting of lowercase English letters.
Another string T is initially empty.
Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:

Append one of the following at the end of T: dream, dreamer, erase and eraser.

Constraints

1≦|S|≦10^5

S consists of lowercase English letters.

Input

The input is given from Standard Input in the following format:

S

Output

If it is possible to obtain S = T, print YES. Otherwise, print NO.

Sample Input 1

erasedream

Sample Output 1

YES

Append erase and dream at the end of T in this order, to obtain S = T.

Sample Input 2

dreameraser

Sample Output 2

YES

Append dream and eraser at the end of T in this order, to obtain S = T.

Sample Input 3

dreamerer

Sample Output 3

NO



Sample input:
erasedream


Sample output:
YES

Submission status: Wrong Answer

Solution code:

s = input()

s_length = len(s)


def judge_dream(word):
  if word[:5] == "dream":
    return True
  else:
    return False

def judge_dreamer(word):
  if word[:7] == "dreamer":
    return True
  else:
    return False

def judge_erase(word):
  if word[:5] == "erase":
    return True
  else:
    return False

def judge_eraser(word):
  if word[:6] == "eraser":
    return True
  else:
    return False

def cut_dream(word):
  return word[5:]

def cut_dreamer(word):
  return word[7:]

def cut_erase(word):
  return word[5:]

def cut_eraser(word):
  return word[6:]

def judge_word_included(word):
  if judge_dreamer(word) == True or judge_dream(word) == True or judge_eraser(word) == True or judge_erase(word) == True:
    return True
  else:
    return False

# 解析結果
is_completed = False

# dreamerチェック済み
is_dreamer_checked = False

# eraserチェック済み
is_eraser_checked = False


while(True):
  s_length = len(s)
  if s_length <= 0:
    is_completed = True
  else:
    if judge_dreamer(s) == True and is_dreamer_checked == False:
      buf_s = cut_dreamer(s)

      if judge_word_included(buf_s) == True:
        s = cut_dreamer(s)
      else:
        if s_length == 7:
          is_completed = True
          break
        else:
          is_dreamer_checked = True
          continue

    elif judge_dream(s) == True:
      buf_s = cut_dream(s)

      if judge_word_included(buf_s) == True:
        s = cut_dreamer(s)
        is_dreamer_checked = False
      else:
        if s_length == 5:
          is_completed = True
          break
        else:
          break

    elif judge_eraser(s) == True and is_eraser_checked == False:
      buf_s = cut_eraser(s)

      if judge_word_included(buf_s) == True:
        s = cut_eraser(s)
      else:
        if s_length == 6:
          is_completed = True
          break
        else:
          is_eraser_checked = True  
          continue

    elif judge_erase(s) == True:
      buf_s = cut_erase(s)

      if judge_word_included(buf_s) == True:
        s = cut_erase(s)
        is_easer_checked = False
      else:
        if s_length == 5:
          is_completed = True
          break
        else:
          break
    else:
      break
  
if is_completed == True:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

S = input()
ls = len(S)
S += "      "
dp = [False for i in range(len(S)+10)]
dp[0]=True
for i in range(len(S)+1):
    if S[i:i+5]=='dream' or S[i:i+5]=='erase':
        dp[i+5]=dp[i]
    elif S[i:i+7]=='dreamer':
        dp[i+7]=dp[i]
    elif S[i:i+6]=='eraser' :
        dp[i+6]=dp[i]
print('YES' if dp[ls]==True else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

S = input()
ls = len(S)
S += "      "
dp = [False for i in range(len(S)+10)]
dp[0]=True
for i in range(len(S)+1):
    if S[i:i+5]=='dream' or S[i:i+5]=='erase':
        dp[i+5]=dp[i]
    elif S[i:i+7]=='dreamer':
        dp[i+7]=dp[i]
    elif S[i:i+6]=='eraser' :
        dp[i+6]=dp[i]
print('Yes' if dp[ls]==True else 'No')

Submission status: Wrong Answer

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

S = input()
ls = len(S)
S += "      "
dp = [False for i in range(len(S)+10)]
dp[0]=True
for i in range(len(S)+1):
    if S[i:i+5]=='dream' or S[i:i+5]=='erase':
        dp[i+5]=dp[i]
    elif S[i:i+7]=='dreamer':
        dp[i+7]=dp[i]
    elif S[i:i+6]=='eraser' :
        dp[i+6]=dp[i]
print(dp[ls])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


s_2=s[::-1]
a_2=(a[0][::-1],a[1][::-1],a[2][::-1],a[3][::-1])

#print(s_2)
#print(a_2)

while len(s_2) > 0:
    judge = [s_2.startswith(i) for i in a_2]
    #print(judge)
    if any(judge)==True:
        target=a[judge.index(True)]
        s_2=s_2[len(target):]
        if len(s_2)==0:
            print('Yes')
            break
    else:
        print('NO')
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


s_2=s[::-1]
a_2=(a[0][::-1],a[1][::-1],a[2][::-1],a[3][::-1])

#print(s_2)
#print(a_2)

while len(s_2) > 0:
    judge = [s_2.startswith(i) for i in a_2]
    #print(judge)
    if any(judge)==True:
        target=a[judge.index(True)]
        s_2=s_2[len(target):]
        if len(s_2)==0:
            print('Yes')
    else:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i
str = str.replace("resare","")
str = str.replace("remaerd","")
str = str.replace("maerd","")
str = str.replace("esare","")
if str == "":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i

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

while True:
    flag=0
    for l in str_list:
        if str.startswith(l):
            #print("str:{},l:{}".format(str,l))
            str=str.lstrip(l)
            #print("str:{},l:{}".format(str,l))
            flag+=1
    if flag==0:
        break


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

Submission status: Wrong Answer

Solution code:
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i

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

while True:
    flag=0
    for l in str_list:
        if str.startswith(l):
            print("str:{},l:{}".format(str,l))
            str=str.lstrip(l)
            print("str:{},l:{}".format(str,l))
            flag+=1
    if flag==0:
        break


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

Submission status: Wrong Answer

Solution code:
s = input()

dic = ['dreameraser', 'dreamerrase', 'dreamer', 'dream', 'eraser', 'erase']

def check():
    i = 0
    while i < len(s):
        found = False
        for k in dic:
            if s[i:i+len(k)] == k:
                found = True
                break
        if not found:
            return False
        i += len(k)
    return True


print('YES' if check() else 'NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(input())

dream = list("dream")
dreamer = list("dreamer")
erase = list("erase")
eraser = list("eraser")

s.reverse()
dream.reverse()
dreamer.reverse()
erase.reverse()
eraser.reverse()

while s != []:
    if s[0:7] == dreamer:
        del s[0:]
    elif s[0:6] == eraser:
        del s[0:]
    elif s[0:5] == dream:
        del s[0:]
    elif s[0:5] == erase:
        del s[0:]
    else:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    dream = 0
    erase = 1
    work = []
    temp1 = 0
    temp2 = 0
    kind = -1
    append = work.append
    for c in s:
        if c == 'd':
            if kind != -1:
                append([kind, temp2-temp1])
            kind = dream
            temp1 = temp2
        elif c == 's':
            if kind != -1:
                append([kind, temp2-temp1-3])
            kind = erase
            temp1 = temp2-3
        temp2 += 1
    append([kind, len(s)-temp1])
    result = []
    append = result.append
    for i, j in work:
        if i == dream:
            if j <= 5:
                append("dream")
            else:
                append("dreamer")
        else:
            if j <= 5:
                append("erase")
            else:
                append("eraser")
    result = "Yes" if "".join(result)==s else "No"
    print(result)
main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

S_list = list(input())

def f(S_list):
  if S_list == []:
    print("Yes")
    exit()
  elif "".join(S_list[0:11]) == "dreameraser":
    del S_list[0:11]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:10]) == "dreamerase":
    del S_list[0:10]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:7]) == "dreamer":
    del S_list[0:7]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:6]) == "eraser":
    del S_list[0:6]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:5]) == "dream" or "".join(S_list[0:5]) == "erase":
    del S_list[0:5]
#    print(S_list)
    f(S_list)
  else:
    print("No")
    exit()

f(S_list)

Submission status: Wrong Answer

Solution code:
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query[:-len(frag)]
                break
        else:
            print("NO", query)
            break
        if not query:
            print("YES")
            break



solve(s)

Submission status: Wrong Answer

Solution code:
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query[:-len(frag)]
                print("cut", frag)
                break
        else:
            print("NO", query)
            break
        if not query:
            print("YES")
            break



solve(s)

Submission status: Wrong Answer

Solution code:
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query.rstrip(frag)
                break
        else:
            print("NO")
            break
        if not query:
            print("YES")
            break



solve(s)

Submission status: Wrong Answer

Solution code:
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query.rstrip("frag")
                break
        else:
            print("NO")
            break
        if not query:
            print("YES")
            break



solve(s)

Submission status: Wrong Answer

Solution code:
import sys

t = set('dream, dreamer, erase, eraser'.split(', '))

def obtainable(s):
  while True:
    for i in range(5, 8):
      if s[-i:] in t:
        s = s[:-i]
        break
    else:
      return False
    if not s:
      return True
    
s = sys.stdin.readline().rstrip()

def main():
  print(t)
  print("YES" if obtainable(s) else "NO")

if __name__ ==  '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys

t = set('dream, dreamer, erase, eraser'.split(', '))

def obtainable(s):
  while True:
    if s[-5:] in t:
      s = s[:-5]
    elif s[-6:] in t:
      s = s[:-6]
    else:
      return False
    if not s:
      return True
    
s = sys.stdin.readline().rstrip()

def main():
  print("YES" if obtainable(s) else "NO")

if __name__ ==  '__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
count=0
k=0
while True:
    if s[k:k+7]=="dreamer":
        k=k+7 
    elif s[k:k+6]=="eraser":
        k=k+6
    elif s[k:k+5]=="dream":
        k=k+5
    elif s[k:k+5]=="erase":
        k=k+5
    else:
        
        break
    if 0<len(s)-k<5:
        break
    if k==len(s):
        print("Yes")
        count=1
        break
if count==0:
    k=0
    while True:
        if s[k:k+5]=="dream":
            k=k+5 
        elif s[k:k+6]=="eraser":
            k=k+6
        elif s[k:k+7]=="dreamer":
            k=k+7
        elif s[k:k+5]=="erase":
            k=k+5
        else:
            print("No")
            break
        if 0<len(s)-k<5:
            print("No")
            break
        if k==len(s):
            print("Yes")
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
k=0
t=len(S)
while k<len(S):
    if(S[-(k+5):t-k] == 'dream' or S[-(k+5):t-k] == 'erase')and k+5<len(S)+1:
        k+=5
        continue
    elif(S[-(k+6):t-k] == 'eraser')and k+6<len(S)+1:
        k+=6
        continue
    elif(S[-(k+7):t-k] == 'dreamer')and k+7<len(S)+1:
        k+=7
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    pos = 0
    l = len(S)
    while pos < l:
        found = False
        if pos + 11 <= l and S[pos:pos + 11] == 'dreameraser':
            # print('dreameraser')
            pos += 11
            found = True
        if pos + 10 <= l and S[pos:pos + 10] == 'dreamerase':
            # print('dreamerase')
            pos += 10
            found = True
        if pos + 7 <= l and S[pos:pos + 7] == 'dreamer':
            # print('dreamer')
            pos += 7
            found = True
        if pos + 6 <= l and S[pos:pos + 6] == 'eraser':
            # print('eraser')
            pos += 6
            found = True
        if pos + 5 <= l and S[pos:pos + 5] in ['dream', 'erase']:
            # print('dream or erase')
            pos += 5
            found = True
        if not found:
            print('NO')
            return
    print('YES')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1].replace("resare", "0").replace("remaerd", "0").replace("esare", "0").replace("maerd", "0")

try:
    int(S)
    print("YES")
except:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
S = S.replace("dreamer", "0").replace("eraser", "1").replace("dream", "2").replace("erase", "3")
try:
    int(S)
    print("YES")
except:
    print("NO")

Submission status: Wrong Answer

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  s = input().replace('eraser','').replace('dreamer','').replace('dream','').replace('erase','')
  print('YES' if len(s) == 0 else 'NO')
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  s = input().replace('dreamer','').replace('eraser','').replace('dream','').replace('erase','')
  print('YES' if len(s) == 0 else 'NO')
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  s = input().replace('dreamer','').replace('eracer','').replace('dream','').replace('erase','')
  print('YES' if len(s) == 0 else 'NO')
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
s = input()

s0 = s
while len(s0) > 0:
#     print(s0)
    if s0[:5] == 'dream':
        if s0[:7] == 'dreamer':
            if s0[:12] == 'dreameraase':
                s0 = s0[12:]
            elif s0[:11] == 'dreameraser':
                s0 = s0[11:]
            else:
                s0 = s0[7:]
        else:
            s0 = s0[5:]
    elif s0[:5] == 'erase':
        if s0[:7] == 'eraser':
            s0 = s0[7:]
        else:
            s0 = s0[5:]
    else:
        break
if len(s0) > 0:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
N = ['dream', 'dreamer', 'erase', 'eraser']

S = S[::-1]

t = []
i = 0
T = ''

if len(S) < 3:
    print('No')
else:
    while i<len(S):
        if S[i] == 'm' and S[i+1] == 'a' and S[i+2] == 'e':
            letter = 'dream'
            i += 4
        elif S[i] ==  'r' and S[i+1] == 'e' and S[i+2] == 'm':
            letter = 'dreamer'
            i += 6
        elif S[i] == 'e' and S[i+1] == 's' and S[i+2] == 'a':
            letter = 'erase'
            i += 4
        elif S[i] == 'r' and S[i+1] == 'e' and S[i+2] == 's':
            letter = 'eraser'
            i += 6
        else:
            break
        i += 1
        t.append(letter)

#print(t)

    for x in t[::-1]:
        T += x

#print(T)

    if S == T[::-1]:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
N = ['dream', 'dreamer', 'erase', 'eraser']

S = S[::-1]

t = []
i = 0
T = ''

if len(S) < 3:
    print('No')
else:
    while i<len(S):
        if S[i] == 'm' and S[i+1] == 'a' and S[i+2] == 'e':
            letter = 'dream'
            i += 4
        elif S[i] ==  'r' and S[i+1] == 'e' and S[i+2] == 'm':
            letter = 'dreamer'
            i += 5
        elif S[i] == 'e' and S[i+1] == 's' and S[i+2] == 'a':
            letter = 'erase'
            i += 4
        elif S[i] == 'r' and S[i+1] == 'e' and S[i+2] == 's':
            letter = 'eraser'
            i += 5
        else:
            break
        i += 1
        t.append(letter)

#print(t)

    for x in t[::-1]:
        T += x

#print(T)

    if S == T[::-1]:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
N = ['dream', 'dreamer', 'erase', 'eraser']

S = S[::-1]

t = []
i = 0
T = ''

while i<len(S):
    if S[i] == 'm' and S[i+1] == 'a' and S[i+2] == 'e':
        letter = 'dream'
        i += 4
    elif S[i] ==  'r' and S[i+1] == 'e' and S[i+2] == 'm':
        letter = 'dreamer'
        i += 5
    elif S[i] == 'e' and S[i+1] == 's' and S[i+2] == 'a':
        letter = 'erase'
        i += 4
    elif S[i] == 'r' and S[i+1] == 'e' and S[i+2] == 's':
        letter = 'eraser'
        i += 5
    else:
        break
    i += 1
    t.append(letter)

#print(t)

for x in t[::-1]:
    T += x

#print(T)

if S == T[::-1]:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
def main():
    Ss = input()
    S = list(Ss)
    now = 0
    T = ''
    while True:
        tmp5 = S[now:now+5]
        if tmp5[0] == 'd':
            tmp = S[now:now+7]
        elif tmp5[0] == 'e':
            tmp = S[now:now+6]
        else:
            print('NO')
            return
        if tmp5 == ['d','r','e','a','m'] and tmp == ['d','r','e','a','m','e','r']:
            if now+7 < len(S) and S[now+7] == 'e':
                T += 'dreamer'
                now += 7
            else:
                T += 'dream'
                now += 5
        elif tmp5 == ['e','r','a','s','e'] and tmp == ['e','r','a','s','e','r']:
            if now+6 == len(S)  or (now+6 < len(S) and S[now+6] == 'e'):
                T += 'eraser'
                now += 6
            else:
                T += 'erase'
                now += 5
        elif tmp5 == ['d','r','e','a','m']:
            T += 'dream'
            now += 5
        elif tmp5 == ['e','r','a','s','e']:
            T += 'erase'
            now += 5
        else:
            print('NO')
            return
        if now >= len(S):
            break
    if Ss == T:
        print('YES')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = list(str(input()))

s = s[::-1]
n = len(s)
#print(s)

ans = "YES"
i = 0
while i < n:
    #print(s[i:i+6])
    if i + 6 <= n and s[i:i+6] ==  ['r', 'e', 'm', 'a', 'e', 'r', 'd']:
        i += 6
    elif i + 6 <= n and s[i:i+6] == ['r', 'e', 's', 'a', 'r', 'e']:
        i += 6
    elif i + 5 <= n and s[i:i+5] == ['m', 'a', 'e', 'r', 'd']:
        i += 5
    elif i + 5 <= n and s[i:i+5] == ['e', 's', 'a', 'r', 'e']:
        i += 5
    else:
        ans = "NO"
        #print('c', i)
        break
print(ans)