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()

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

while s:
  flg = True
  for w in a:
    if s.startswith(w):
      s = s.lstrip(w)
      flg = False
  if flg:
    break
      
      
if s == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
S = input()

# 求解処理
T = ""
t = -1
result = True
while True:
    s = S[t]
    if s == "m":
        T = "dream" + T
    elif s == "e":
        T = "erase" + T
    elif s == "r":
        s = S[t-2]
        if s == "m":
            T = "dreamer" + T
        elif s == "s":
            T = "eraser" + T
        else:
            result = False
            break

    else:
        result = False
        break

    if len(S) == len(T):
        break
    t = -len(T) - 1

# 結果出力
if result:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()

t1='maerd'
t2='remaerd'
t3='esare'
t4='resare'
t=[t1,t2,t3,t4]

s=s[::-1]

ans=0

while True:
    if s.startswith(t1):
        s=s[5::]
    
    elif s.startswith(t2):
        s=s[7::]
      
    elif s.startswith(t3):
        s=s[5::]
 
    elif s.startswith(t4):
        s=s[6::]
        
    elif len(s)==0:
        break
        
    else:
        print('NO')
        ans=1
        break
        
    
        
if ans==0:
    print('Yes')

Submission status: Wrong Answer

Solution code:
S = input()

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

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

Submission status: Wrong Answer

Solution code:
s = str(input())
i = 0
while(1):
    if len(s) - i < 5:
        break
    if s[i:i+5] == "erase" or s[i:i+5] == "dream":
        i += 5
        if s[i:i+2] == "er":
            i += 2
    else:
        print("No")
        exit()
print("YES" if i == len(s) else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
strset = {'dream': 5, 'dreamer': 7, 'erase': 5, 'eraser': 6}

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

print('YES')

Submission status: Wrong Answer

Solution code:
import copy
def deleteStr(S, text):
    if len(S) < len(text):
        return S
    for i, letter in enumerate(text):
        if letter == S[i]:
            continue
        else:
            return S
    return S[len(text):]

def checkStr(S, text):
    if len(S) < len(text):
        return False
    for i, letter in enumerate(text):
        if letter == S[i]:
            continue
        else:
            return False
    return True

def main():
    S = input()

    for i in range(len(S)):
        S_len = len(S)
        if checkStr(S, 'dreamer'):
            if checkStr(S, 'dreamerase'):
                S = deleteStr(S, 'dream')
            else:
                S = deleteStr(S, 'dreamer')
        else:
            S = deleteStr(S, 'dream')

        if checkStr(S, 'eraser'):
            S = deleteStr(S, 'eraser')
        else:
            S = deleteStr(S, 'erase')

        if S_len == len(S):
            if S_len == 0:
                print('Yes')
            else:
                print('No')
            break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S = input()
results = True
while results:
    for key_word in ("erase", "eraser", "dream", "dreamer"):
        if S.endswith(key_word):
            S = S[:-len(key_word)]
            continue
    if S == '':
        print("YES")
        results = False
        break
    else:
        print("NO")
        results = False
        break

Submission status: Wrong Answer

Solution code:
S = input()
results = True
while results:
    for key_word in ["erase", "eraser", "dream", "dreamer"]:
        if S.endswith(key_word):
            S = S[:-len(key_word)]
            continue
    if S == '':
        print("YES")
        results = False
        break
    else:
        print("NO")
        results = False
        break

Submission status: Wrong Answer

Solution code:
S = input()
results = True
while results:
    for key_word in ["erase", "eraser", "dream", "dreamer"]:
        if S.endswith(key_word):
            S = S[:-len(S)]
            continue
    if S == '':
        print("YES")
        results = False
        break
    else:
        print("NO")
        results = False
        break

Submission status: Wrong Answer

Solution code:
S = input()
results = True
while results:
    for key_word in ["erase", "eraser", "dream", "dreamer"]:
        if S.endswith(key_word):
            S = S.rstrip(key_word)
            continue
    if S == '':
        print("YES")
        results = False
        break
    else:
        print("NO")
        results = False
        break

Submission status: Wrong Answer

Solution code:
S = input()
T = ''
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(words)):
    words[i] = words[i][::-1]
for i in S[::-1]:
    T += i
    for q in words:
        if T == q:
            T = ''
if T == '':
    print('YES')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
words = ['maerd', 'remaerd', 'esare', 'resare']
S = input()
T = ''
for a in S[::-1]:
  T += a
  for s in words:
    if T == s:
      T = ''
if T == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()
T = ''
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(words)):
    words[i] = words[i][::-1]
for i in S[::-1]:
    T += i
    for q in words:
        if T == q:
            T = ''
if T == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:

S = input()
T = ''
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(words)):
    words[i] = words[i][::-1]
for i in S[::-1]:
    T += i
    for q in words:
        if T == q:
            T = ''
if T == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import re;
s = input();
print("Yes" if re.fullmatch(r'^(dream|dreamer|eraser|erase)*$', s) else "NO")

Submission status: Wrong Answer

Solution code:
import re;
s = input();
print("Yes" if re.match(r'^(dream|dreamer|eraser|erase)*$', s) else "NO")

Submission status: Wrong Answer

Solution code:
import re;
s = input();
print("Yes" if re.match(r'^(dream|dreamer|eraser|erase)+$', s) else "NO")

Submission status: Wrong Answer

Solution code:
def extract_6(x):
	strtemp=' '
	if(len(x)>=6):
		temp=[0]*6
		for i in range(6):
			temp[i]=x[len(x)-6+i]
	else:
		temp='false'
	strtemp=''.join(temp)
	print(strtemp)
	return(strtemp)

def extract_5(x):
	strtemp=' '
	if(len(x)>=5):
		temp=[0]*5
		for i in range(5):
			temp[i]=x[len(x)-5+i]
	else:
		temp='false'
	strtemp=''.join(temp)
	print(strtemp)
	return(strtemp)

S=input()
flag=1
while(flag==1):
	if(extract_6(S)=='dreamer'):
		S=S.rstrip('dreamer')
	elif(extract_6(S)=='eraser'):
		S=S.rstrip('eraser')
	elif(extract_5(S)=='dream'):
		S=S.rstrip('dream')
	elif(extract_5(S)=='erase'):
		S=S.rstrip('erase')
	else:
		flag=0
if len(S)!=0:
	print('NO')
else:
	print('YES')
print(S)

Submission status: Wrong Answer

Solution code:
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



s = input()
n = len(s)
s += "zzzzzzzzzzzzzzzzzzz"
t = ""
while(True):
    if(n - len(t) <= 4):
        break
    if(s[len(t)+2]=='a' and s[len(t)+5]=='r'):
        t+="eraser"
        continue
    elif(s[len(t)+2]=='a'):
        t+="erase"
    elif(s[len(t)+7]=='a' or s[len(t)+5]=='z'):
        t+="dream"
    else:
        t+="dreamer"
        
if(s[0:n]==t):
    print("YES")
else:
    print("NO")
#print(s[0:n],t)

Submission status: Wrong Answer

Solution code:


s = input()
n = len(s)
s += "zzzzzzzzzzzzzzzzzzz"
t = ""
while(True):
    if(n - len(t) <= 4):
        break
    if(s[len(t)+2]=='a' and s[len(t)+5]=='r'):
        t+="eraser"
        continue
    elif(s[len(t)+2]=='a'):
        t+="erase"
    elif(s[len(t)+7]=='a' or s[len(t)+5]=='z'):
        t+="dream"
    else:
        t+="dreamer"
        
if(s[0:n]==t):
    print("YES")
#print(s[0:n],t)

Submission status: Wrong Answer

Solution code:
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0

while ind  <len(S_r):
    if excep == 1:
        break
    flag2= 0
    for j in range(4):
        if flag2 ==0:
            case = 0
            for k in range(len(dire_r[j])):
                tmp = dire_r[j]

                if ind + k < len(S_r) and case == 0:
                    #print(j)
                    #print('S:'+S_r[ind+k])
                    #print('dire:'+tmp[k])
                    if S_r[ind+k] != tmp[k]:
                        flag = 0
                        if j == 3:
                            excep = 1
                            case = 1
                    elif k== len(dire_r[j])  -1:
                        ind = ind + len(dire_r[j])
                        flag = 1
                        case = 1
                        flag2 = 1


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

Submission status: Wrong Answer

Solution code:
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0

while ind  <len(S_r):
    if excep == 1:
        break

    for j in range(4):
        case = 0
        for k in range(len(dire_r[j])):
            tmp = dire_r[j]

            if ind + k < len(S_r) and case == 0:
                if S_r[ind+k] != tmp[k]:
                    flag = 0
                    if j == 3:
                        excep = 1
                        case = 1
                elif k== len(dire_r[j])  -1:
                    ind = ind + len(dire_r[j])
                    flag = 1
                    case = 1


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

Submission status: Wrong Answer

Solution code:
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0

while ind  <len(S_r):
    if excep == 1:
        break
    case = 0
    for j in range(4):
        if case == 0:
            for k in range(len(dire_r[j])):

                tmp = dire_r[j]

                if ind + k < len(S_r):
                    if S_r[ind+k] != tmp[k]:
                        flag = 0
                        if j == 3:
                            excep = 1
                            case=0

                    elif k== len(dire_r[j])  -1:
                        ind = ind + len(dire_r[j])
                        flag = 1
                        case = 1

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

Submission status: Wrong Answer

Solution code:
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0

while ind  <len(S_r):
    if excep == 1:
        break
    case = 0
    for j in range(4):
        if case == 0:
            for k in range(len(dire_r[j])):
        
                tmp = dire_r[j]

                if ind + k < len(S_r):
                    if S_r[ind+k] != tmp[k]:
                        flag = 0
                        if j == 3:
                            excep = 1
                        case=0

                    elif k== len(dire_r[j])  -1:
                        ind = ind + len(dire_r[j])
                        flag = 1
                        case = 1

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

Submission status: Wrong Answer

Solution code:
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0
while ind  <len(S_r):
    if excep == 1:
        break
    for j in range(4):
        for k in range(len(dire_r[j])):
            if ind + k < len(S_r):
                tmp = dire_r[j]
                if S_r[ind+k] != tmp[k]:
            #        print(S_r[ind+k])
            #        print(tmp[k])
                    flag = 0
                    if j == 3:
                        excep = 1
                    break

                elif k== len(dire_r[j])  -1:
                    ind = ind + len(dire_r[j])
                    flag = 1
                    break

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

Submission status: Wrong Answer

Solution code:
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0
while ind  <len(S_r):
    if excep == 1:
        break
    for j in range(4):
        for k in range(len(dire_r[j])):
            if ind + k < len(S_r):
                tmp = dire_r[j]
                if S_r[ind+k] != tmp[k]:
                    flag = 0
                    if j == 3:
                        excep = 1
                        break

                elif k== len(dire_r[j])  -1:
                    ind = ind + len(dire_r[j])
                    flag = 1
                    break

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

Submission status: Wrong Answer

Solution code:
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0
while ind  <len(S_r):
    if excep == 1:
        break
    for j in range(4):
        for k in range(len(dire_r[j])):
            if ind + k < len(S_r):
                tmp = dire_r[j]
                if S_r[ind+k] != tmp[k]:
                    flag = 0
                    if j == 3:
                        excep = 1
                        break

                elif k== len(dire_r[j])  -1:
                    ind = ind + len(dire_r[j])
                    print(len(dire_r[j]))
                    flag = 1
                    break

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

Submission status: Wrong Answer

Solution code:
def solve(S):
    str_list = ["dream", "dreamer", "erase", "eraser"]
    n = 0
    while n < len(S):
        for s in str_list:
            if n:
                if S[:-n].endswith(s):
                    n += len(s)
                    break
            else:
                if S.endswith(s):
                    n += len(s)
                    break
        else:
            return False
    return True


S = input()
if solve(S):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
t = ["dream","dreamer","erase","eraser"]

# 反転

t_r = []
for i in range(len(t)):
    t_r.append(t[i][::-1])
    
s = input()
s_r = s[::-1]

flag = True
for i in range(len(s_r)):
    flag2 = False
    for j in t_r:
        tmp_s = s_r[i:len(j)]       
        if(tmp_s == j):
            flag2 = True
            i += len(j)
    if flag2 == False:
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
import re

S = input()
l = len(S)
s = S.replace('dream','').replace('erase','erasee').replace('erase','')
flag = False
for a in range(int(l/5) + 1):
    for c in range(int(l/5) + 1 - a):
        for b in range(int((l-5*(a+c))/7)+1):
            d = int((l - 5*(a+c) - 7*b) / 6)
            if 5*(a+c) + 7*b + 6*d == l:
                if s == 'er' * int(len(s) / 2):
                    flag = True
                    break
        if flag:
            break
    if flag:
        break
if flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re

S = input()
l = len(S)
s = S.replace('dream','').replace('erase','erasee').replace('erase','')
flag = False
for a in range(int(l/5) + 1):
    for c in range(int(l/5) + 1 - a):
        for b in range(int((l-5*(a+c))/7)+1):
            d = int((l - 5*(a+c) - 7*b) / 6)
            if 5*(a+c) + 7*b + 6*d == l:
                
                    flag = True
                    break
        if flag:
            break
    if flag:
        break
if flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
lst = ["dreamer", "dream", "eraser", "erase"]
n = 0

while len(S) != 0:
    i = 0
    for s in lst:
        i = S.find(s, n)
        if i == 0:
            if s == lst[0] and S.find(lst[3], n) == 5:
                print(S.find(lst[3], n))
                pass
            else:
                S = S[len(s) :]
                break
    if i != 0:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

dire = ['dream','dreamer','erase','eraser ']
flag = 0
i=0
j=0
while True:

    tmp = dire[j]
    ind = i
    #print(ind + len(dire[j]))
    if ind + len(dire[j]) <=len(S)+1:
    #    print(j)
        for k in range(len(dire[j])):

            '''
            if ind == 12:
                print(S[ind])
                print(tmp[k])
            '''
            if S[ind] != tmp[k]:
                flag =0
                j += 1
                break
            else:
                ind = ind + 1
                if k==len(dire[j])-1:
                    i = i + len(dire[j])
                    flag = 1
                    old = len(dire[j])
                    old_j  = j
                    j=0

    if   j >= 4 and flag == 0 and i != 0:
        i = i - old
        j = old_j+1

    if i >= len(S)-1:
        print('YES')
        break
    elif i <= 0 and j >= 3 and flag == 0:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
S = input()
flag2= 0 # 0 sucess

dire = ['dream','dreamer','erase','eraser ']
flag = 0
i=0
while True:
    flag = 0
    for j in range(4):
        tmp = dire[j]
        ind = i
        if ind + len(dire[j]) <= len(S):
            for k in range(len(dire[j])):
                if S[ind] != tmp[k]:
                    break
                else:
                    ind = ind + 1
                if k==len(dire[j])-1:
                    i = i + len(dire[j])
                    flag = 1
                    old = len(dire[j])
        if j == 3 and  flag == 0:
            i = i - old

    if i >= len(S)-1:
        print('YES')
        break
    elif i == 0 and j == 3 and flag == 0:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
S = input()
flag2= 0 # 0 sucess

dire = ['dream','dreamer','erase','eraser ']
flag = 0
i=0
while True:
    flag = 0
    for j in range(4):
        tmp = dire[j]
        ind = i
        for k in range(len(dire[j])):
            if ind < len(S):
                if S[ind] != tmp[k]:
                    break
                else:
                    ind = ind + 1
                if k==len(dire[j])-1:
                    i = i + len(dire[j])
                    flag = 1
                    old = len(dire[j])
        if j == 3 and  flag == 0:
            i = i - old

    if i >= len(S)-1:
        print('YES')
        break
    elif i == 0 and j == 3 and flag == 0:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
def func(x, t):

    if len(x) == 0:
        return True
    elif len(x) < 5:
        return False
    else:
        tmp = False
        if x[:5] == "dream":
            t += "dream"
            tmp = func(x[5:], t)

        if x[:6] == "dreamer" and not tmp:
            t += "dreamer"
            tmp = func(x[6:],t)

        if x[:5] == "erase" and not tmp:
            t += "erase"
            tmp = func(x[5:], t)

        if x[:6] == "eraser" and not tmp:
            t += "eraser"
            tmp = func(x[6:], t)

    return tmp

def solve(n):

    t = ""
    ans = func(n, t)
    return "YES" if ans else "NO"

if __name__ == "__main__":
    n = input()
    print(solve(n))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    S=input()
    n=len(S)
    A="dream dreamer erase eraser".split()
    #print(A)
    global cond
    cond=[]
    def dfslike_dreameraser(varS):#string->bool,resursion
        #print(varS)
        if len(varS)==0:
            cond.append(1)
            return 
        for word in A:
            if varS[:len(word)]==word:
                dfslike_dreameraser(varS[len(word):])
        return 
        
    dfslike_dreameraser(S)
    #print(cond)
    print(["NO","YES"][cond!=[]])
#%%submit!
#resolve()

Submission status: Wrong Answer

Solution code:
s = input()
# s = 'erasedream'
while True:
    # print(s)
    if s == '':
        print('YES')
        break
    if s.endswith('eraser'):
        s = s[:-6]
    elif s.endswith('dreamer'):
        s = s[:-6]
    elif s.endswith('dream'):
        s = s[:-5]
    elif s.endswith('erase'):
        s = s[:-5]
    else:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
# s = input()
s = 'erasedream'
while True:
    # print(s)
    if s == '':
        print('YES')
        break
    if s.endswith('eraser'):
        s = s.replace('eraser', '')
    elif s.endswith('dreamer'):
        s = s.replace('dreamer', '')
    elif s.endswith('dream'):
        s = s.replace('dream', '')
    elif s.endswith('erase'):
        s = s.replace('erase', '')
    else:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
s = input()
# s = 'dreamerasererase'
while True:
    if s == '':
        print('YES')
        break
    if s.endswith('eraser'):
        s = s.rstrip('eraser')
    elif s.endswith('dreamer'):
        s = s.rstrip('dreamer')
    elif s.endswith('dream'):
        s = s.rstrip('dream')
    elif s.endswith('erase'):
        s = s.rstrip('erase')
    else:
        print('NO')
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
s = s.replace("eraser", "X")
s = s.replace("dreamer", "X")
s = s.replace("erase", "X")
s = s.replace("dream", "X")
 
count = s.count("X")
if len(s) == count:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

count = s.count("X")
if len(s) == count:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
word = input()

list = ['dream','dreamer','erase','eraser']
count = 0
for i in list:
    a = i
    if a in word:
        word = word.replace(a, '')
        # print(word)
        
        
if word == "":
    print("YES")
    
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
word = input()

list = ['dream','dreamer','erase','eraser']
count = 0
for i in list:
    a = i
    if a in word:
        word = word.replace(a, '')
        # print(word)
        count += 1
        
if count >= 2:
    print("YES")
    
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(1000000)
S = input()


def start_with(i):
    if i == len(S)-1:
        print('YES')
        sys.exit(0)

    try:
        if S[i:i+5] == 'dream':
            start_with(i+5)
        if S[i:i+7] == 'dreamer':
            start_with(i+7)
        if S[i:i+5] == 'erase':
            start_with(i+5)
        if S[i:i+6] == 'eraser':
            start_with(i+6)
        return
    except IndexError:
        return


start_with(0)
print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
m = ["dream", "dreamer", "erase", "eraser"]
t = ""
i = 0
find = False
fin = False
while fin == False:
    if s[i:i+6] == m[3]:
        t += m[3]
        i += 6
    elif s[i:i+5] == m[2]:
        t += m[2]
        i += 5
    elif s[i:i+5] == m[0]:
        if s[i+6:i+7] == "er":
            if s[i+6:i+10] == m[3]:
                t += m[0]
                i += 5
            else:
                t += m[1]
                i += 6
        else:
            t += m[0]
            i += 5
    else:
        fin = True

    if i >= len(s):
        find = True

    

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

Submission status: Wrong Answer

Solution code:
s = str(input())
l = len(s)
s = s[::-1]
i = 0
while i < l:
    if (s[i:min(l,i+7)] == "remaerd"):
        i += 7
    elif (s[i:min(l,i+6)] == "resare"):
        i += 6    
    elif (s[i:min(l,i+5)] == "maerd" or "esare"):
        i += 5   
    else:
        print('NO')
        break

else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = str(input())
l = len(s)
i = 0
while i < l:
    if s[i] == "d":
        if (s[i:min(l,i+7)] == "dreamer"):
            i += 7
        elif (s[i:min(l,i+5)] == "dream"):
            i += 5
        else:
            break
            print('NO')
    
    elif s[i] == "e":
        if (s[i:min(l,i+6)] == "eraser"):
            i += 6
        elif (s[i:min(l,i+5)] == "erase"):
            i += 5
        else:
            break
            print('NO')
    else:
        print('NO')
        break
        
    
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = str(input())
l = len(s)
i = 0
while i < l:
    if s[i] == "d":
        if (s[i:min(l,i+7)] == "dreamer"):
            i += 7
        elif (s[i:min(l,i+5)] == "dream"):
            i += 5
        else:
            break
            print('NO')
    
    elif s[i] == "e":
        if (s[i:min(l,i+6)] == "eraser"):
            i += 6
        elif (s[i:min(l,i+5)] == "erase"):
            i += 5
        else:
            break
            print('NO')
    else:
        break
        print('NO')
    
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
dividor = ['dream','dreamer','erase','eraser']
j=0
while True:
    flag = 0
    for d in dividor:
        print(S[j:j+len(d)])
        if S[j:j+len(d)]==d[::-1]:
            flag = 1
            j+=len(d)
            if j==len(S):
                print("YES")
                quit()
    if flag==0:
        print("NO")
        quit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input().replace("eracer",'').replace('erace','').replace('dreamer','').replace('dreame','')
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
judge = "NO"

while s[0] == "dream" or s[0] == "erase":
    if s.find("dreamer")==0 and any([s[7] == "d", s[7] == "e"]):
        s = s[7:]
    elif  s.find("eraser")==0:
        s = s[6:]
    elif s.find("dream")==0 or s.find("erase")==0:
        s = s[5:]

    if s == "":
        judge = "YES"
        break

print(judge)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
S = input()
n=0
flg=0
#print(s[0:K-1]+s[K-1].lower()+s[K:N])
S=S[::-1]
while(not S==""):

#    if  S[n:].startswith("dreameraser"):
#        n=n+11
        #print(S[n:])
        #flg==1
#        continue
    if S.startswith("remerd"):
        #n=n+6
        S=S.replace("remerd","",1)
        #print(S[n:])
        continue
    elif S.startswith("maerd"):
        #n=n+5
        S=S.replace("maerd","",1)
        #print(S)
        #flg==1
        continue
    elif S.startswith("resare"):
        #n=n+6
        S=S.replace("resare","",1)
        #print(S[n:])
        continue
    elif S.startswith("esare"):
        #n=n+5
        S=S.replace("esare","",1)
        #print(S)
        #flg==1
        continue
    print("NO")
    exit()

print("YES")