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()
flag=0
S=S.replace("dreamer", "0")
S=S.replace("eraser", "0")
S=S.replace("dream", "0")
S=S.replace("erase", "0")
S=S.replace("0", "")
if S=="":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
flag=0
while(True):
  N=len(S)
  S=S.replace("dreamer", "")
  S=S.replace("eraser", "")
  S=S.replace("dream", "")
  S=S.replace("erase", "")
  if len(S)==N:
    break
if len(S)==0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def c_Daydream(S):
    # Sを逆にしたものから一覧にある文字列を逆にしたものを除いていき、空文字にできるか？
    s = S[::-1]
    while True:
        if len(s) >= 5 and s[0:5] == 'maerd':
            s = s[5:]
        elif len(s) >= 6 and s[0:6] == 'remaerd':
            s = s[6:]
        elif len(s) >= 5 and s[0:5] == 'esare':
            s = s[5:]
        elif len(s) >= 6 and s[0:6] == 'resare':
            s = s[6:]
        elif len(s) == 0:
            return 'YES'
        else:
            return 'NO'
S = input().strip()
print(c_Daydream(S))

Submission status: Wrong Answer

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

    WA(S)


def WA(S):
    l = len(S)
    idx = 0
    ok = True
    while idx < l:
        if S[idx:idx + 7] == "dreamer":
            idx += 7
        elif S[idx:idx + 6] == "eraser":
            idx += 6
        elif S[idx:idx + 5] == "dream" or \
                S[idx:idx + 5] == "erase":
            # 評価順番注意
            idx += 5
        else:
            ok = False
            break

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    AC(S)


def AC(S):
    l = len(S)
    idx = 0
    ok = True
    while idx < l:
        if S[idx:idx + 7] == "dreamer":
            idx += 7
        elif S[idx:idx + 6] in "eraser":
            idx += 6
        elif S[idx:idx + 5] in ("dream", "erase"):
            # 評価順番注意
            idx += 5
        else:
            ok = False
            break

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    l = len(S)
    idx = 0
    ok = True
    while idx < l:
        if S[idx:idx + 5] in ("dream", "erase"):
            idx += 5
        elif S[idx:idx + 7] == "dreamer":
            idx += 7
        elif S[idx:idx + 6] in "eraser":
            idx += 6
        else:
            ok = False
            break

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()

import re
s = re.sub('erase[r]?', '', s)
s = re.sub('dream[er]?', '', s)

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

Submission status: Wrong Answer

Solution code:
s = input()

import re
s = re.sub('dream[r]?|erase[r]?', '', s)

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

Submission status: Wrong Answer

Solution code:
def solve():
    while 1:
        try:
            s = list(input())
            s.reverse()
            s = "".join(s)
            if len(s) < 5:
                raise EndLoop
 
            l = 0
            r = 5
            while r <= len(s):
                if s[l:r] == "maerd" or s[l:r] == "esare":
                    l += 5
                    r += 5
                elif s[l:r] == "remae" or s[l:r] == "resar":
                    l += 7
                    r += 7
                else:
                    raise EndLoop
 
            print("YES")
            break
        except:
            print("NO")
            break
 
 
solve()

Submission status: Wrong Answer

Solution code:
def solve():
    while 1:
        try:
            s = list(input())
            s.reverse()
            s = "".join(s)
            if len(s) < 5:
                raise EndLoop

            l = 0
            r = 5
            while r <= len(s):
                if s[l:r] == "maerd" or s[l:r] == "esare":
                    l += 5
                    r += 5
                elif s[l:r] == "remae" or s[l:r] == "resar":
                    l += 7
                    r += 7
                else:
                    raise EndLoop

            print(l, r)
            print(len(s))
            print("YES")
            break
        except:
            print("NO")
            break


solve()

Submission status: Wrong Answer

Solution code:
s = input()

if s[0] == 'r':
    print('NO')
    exit()

a = s.replace('erase', ',').split(',')
for i in range(len(a)):
    if a[i] != '' and a[i][0] == 'r':
        a[i] = a[i].lstrip('r')

b = ','.join(a)
c = b.replace('dreamer', ',').split(',')

z = ['dream', '']

for x in c:
    if x not in z:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

a = s.replace('erase', ',').split(',')
for i in range(len(a)):
    if a[i] != '' and a[i][0] == 'r':
        a[i] = a[i].lstrip('r')

b = ','.join(a)
c = b.replace('dreamer', ',').split(',')

z = ['dream', '']

for x in z:
    if x not in a:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
W = ['dreamer', 'dream', 'eraser', 'erase']
for n in range(4):
    W[n] = W[n][::-1]
check = 0
i = 0
while i < len(S):
    check = 0
    for w in W:
        if w in S[i:i + 8]:
            i += len(w)
            check = 1
    if check is 0:
        break
if check is 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input().replace("dream","&").replace("erase","%").replace("&er","").replace("%r","").replace("&","").replace("%","")
if S:
    print("no")
else:
    print("yes")

Submission status: Wrong Answer

Solution code:
import sys

S = input()

while S:
    prefix = S[0:5]
    if prefix == 'dream':
        if S[5:7] == 'er':
            if len(S) > 8 and S[7] == 'a':
                S = S[5:]
            else:
                S = S[7:]
        else:
            S = S[5:]
    elif prefix == 'erase':
        if len(S) > 6 and S[5] == 'r':
            S = S[6:]
        else:
            S = S[5:]
    else:
        print('NO')
        sys.exit(0)
    # print(S)
print('YES')

Submission status: Wrong Answer

Solution code:
import sys

S = input()

while S:
    prefix = S[0:5]
    if prefix == 'dream':
        if S[5:7] == 'er':
            if S[7] == 'a':
                S = S[5:]
            else:
                S = S[7:]
        else:
            S = S[5:]
    elif prefix == 'erase':
        if S[5] == 'r':
            S = S[6:]
        else:
            S = S[5]
    else:
        print('NO')
        sys.exit(0)
    # print(S)
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s=0
S=str(input())
while len(S)>=0:
  if s==len(S):
    print("YES")
    sys.exit()
  if S[s:s+5]=="dream":
    if len(S)==s+5:
      print("YES")
      sys.exit()
    elif S[s+5]=="d" or S[s+5:s+8]=="era":
      s+=5
    elif S[s+5:s+8]=="erd" or S[s+5:s+8]=="ere":
      s+=7
    else: 
      print("NO")
      sys.exit()
  elif S[s:s+5]=="erase":
    if len(S)==s+5:
      print("YES")
      sys.exit()
    elif S[s+5]=="d" or S[s+5]=="e":
      s+=5
    elif S[s+5]=="r":
      s+=6
    else: 
      print("NO")
      sys.exit()
  else: 
    print("NO")
    sys.exit()

Submission status: Wrong Answer

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

s = raw_input()
t = ''

front = 0
rear = 7
while (s != t):
    if('dreamer' in s[front:rear]):
        if('eraser' in s[front:rear+4]):
            t += s[front:rear+4]
            front = rear + 4
            rear = front + 7
        else:
            t += s[front:rear]
            front = rear
            rear = front + 7
    elif('eraser' in s[front:rear]):
        t += s[front:rear-1]
        front = rear - 1
        rear = front + 7
    elif('dream' in s[front:rear]):
        t += s[front:rear-2]
        front = rear - 2
        rear = front + 7
    elif('erase' in s[front:rear]):
        t += s[front:rear-2]
        front = rear - 2
        rear = front + 7
    else:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

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

s = s[::-1]
for i in range(4):
    t[i] = t[i][::-1]

tmp = s

while tmp != '':
    d = tmp[0:4] == t[0]
    dr = tmp[0:6] == t[1]
    e = tmp[0:4] == t[2]
    er = tmp[0:5] == t[3]

    if dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    elif d or e:
        tmp = tmp[5:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

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

tmp = s

while tmp != '':
    d = tmp[0:4] == t[0]
    dr = tmp[0:6] == t[1]
    e = tmp[0:4] == t[2]
    er = tmp[0:5] == t[3]

    if dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    elif d or e:
        tmp = tmp[5:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')

Submission status: Wrong Answer

Solution code:
s = str(input())

DREAM   = "dream"
DREAMER = "dreamer"
ERASE   = "erase"
ERASER  = "eraser"

for i in range(0, len(s)):
    dr_pos = s.find(DREAMER)
    d_pos = s.find(DREAM)
    e_pos = s.find(ERASE)
    if d_pos != -1:
        if dr_pos != -1 and d_pos == dr_pos:
            if dr_pos < e_pos and dr_pos + len(DREAMER) > e_pos:
                s = s.replace(DREAM, "", 1)
            else:
                s = s.replace(DREAMER, "", 1)
        else:
            s = s.replace(DREAM, "", 1)
    e_pos = s.find(ERASE)
    er_pos = s.find(ERASER)
    ere_pos = s.find(ERASE + ERASE)
#    print("e_pos:" + str(e_pos) + ", er_pos:" + str(er_pos) + ", ere_pos:" + str(ere_pos))
    if e_pos != -1:
        if er_pos != -1 and er_pos == e_pos and er_pos != ere_pos:
            s = s.replace(ERASER, "", 1)
        else:
            s = s.replace(ERASE, "", 1)
    if len(s) == 0:
        print("YES")
        quit()
if len(s) != 0:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = raw_input()
S = S.strip("dream")
S = S.strip("dreamer")
S = S.strip("erase")
S = S.strip("eraser")

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

Submission status: Wrong Answer

Solution code:
S = raw_input()
S = S.replace("dream", "")
S = S.replace("dreamer", "")
S = S.replace("erase", "")
S = S.replace("eraser", "")

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

Submission status: Wrong Answer

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

s = input()

while not s:
    match = False
    for w in words:
        if s.endwith(w):
            s = s[:-len(w)]
            match = True
            break
    if match is False:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

s = input()

while not s:
    match = False
    for w in words:
        if s.endwith(w):
            s = s[:-len(w)]
            match = True
            break
    if match is False:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

s = input()

while not s:
    match = False
    for w in words:
        if s.endwith(w):
            s = s[:-len(w)]
            match = True
            break
    if match is False:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
import sys

s = input()

while len(s) != 0:
    if s.endswith('dream') or s.endswith('erase'):
        s = s[:-5]
    elif s.endswith('dreamer') or s.endswith('eraser'):
        s = s[:-7]
    else:
        print('NO')
        sys.exit()

print('YES')

Submission status: Wrong Answer

Solution code:
class DayDream:

    def is_possible(self, S):

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

        if S in cand:
            return "YES"

        if len(S) < 5:
            return "NO"

        
        idx = 0
        while True:

            flag = 0

           
            if S[idx:idx+7] == "dreamer" or S[idx:idx+7] == "eraser":

                if len(S) <= idx+5 or len(S) <= idx+7:
                    return "YES"

                if S[idx+7:idx+12] in cand or S[idx+7:idx+14] in cand:
                    flag = 1
                    idx += 7

            if S[idx:idx+5] == "dream" or S[idx:idx+5] == "erase":
                flag = 1
                idx += 5

            if len(S) <= idx:
                return "YES"

            if not flag:
                return "NO"

if __name__ == "__main__":

    S = raw_input()

    abc = DayDream()
    print abc.is_possible(S)

Submission status: Wrong Answer

Solution code:
class DayDream:

    def is_possible(self, S):

        patterns = [["dream",5], ["dreamer",7], ["erase",5], ["eraser",7]]
        cand = ["dream", "dreamer", "erase", "eraser"]

        if S in cand:
            return "YES"

        if len(S) < 5:
            return "NO"

       
        idx = 0
        while True:

            
            current_idx = idx
            flag = 0
            for i in range(4):

                if patterns[i][0] == S[current_idx:current_idx+patterns[i][1]]:
                   
                    if S[current_idx+patterns[i][1]:] in cand:
                        return "YES"

                    if S[current_idx+patterns[i][1]:current_idx+patterns[i][1]+5] in cand:
                        flag = 1
                        idx += patterns[i][1]
                        break

                    elif S[current_idx+patterns[i][1]:current_idx+patterns[i][1]+7] in cand:
                        flag = 1
                        idx += patterns[i][1]
                        break

            if not flag:
                return "NO"


if __name__ == "__main__":

    S = raw_input()

    abc = DayDream()
    print abc.is_possible(S)

Submission status: Wrong Answer

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

class stringJudge():
    def __init__(self,string,string_list):
        self.string = string
        self.string_list = string_list
        
    def isNextMatch(self):
        for str_val in self.string_list:
            if self.string.endswith(str_val):
                self.string = self.string.split(str_val,1)[0]
                return True
        return False
               
                    
                    
           
    
instance = stringJudge(input(),str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()

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

Submission status: Wrong Answer

Solution code:
str_list = ["dream","erase","er","ase","r",]

class stringJudge():
    def __init__(self,string,string_list):
        self.string = string
        self.string_list = string_list
        
    def isNextMatch(self):
        for (i,str_val) in enumerate(str_list):
            if self.string.startswith(str_val):
                self.string = self.string.split(str_val,1)[1]
                if len(self.string) == 0:
                    return True
                if i ==0:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[2]):
                        return True
                elif i == 1:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[4]):
                        return True
                elif i == 2:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[3]):
                        return True
                elif i == 3:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[4]):
                        return True
                elif i == 4:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]):
                        return True
        return False
                    
                    
           
    
instance = stringJudge(input(),str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()

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

Submission status: Wrong Answer

Solution code:
str_list = ["dream","eraser","er","ase","r",]

class stringJudge():
    def __init__(self,string,string_list):
        self.string = string
        self.string_list = string_list
        
    def isNextMatch(self):
        for (i,str_val) in enumerate(str_list):
            if self.string.startswith(str_val):
                self.string = self.string.split(str_val,1)[1]
                if len(self.string) == 0:
                    return True
                if i ==0:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[2]):
                        return True
                elif i == 1:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[4]):
                        return True
                elif i == 2:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[3]):
                        return True
                elif i == 3:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[4]):
                        return True
                elif i == 4:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]):
                        return True
        return False
                    
                    
           
    
instance = stringJudge(input(),str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()

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

Submission status: Wrong Answer

Solution code:
str_list = ["dream","er","ase","r",]

class stringJudge():
    def __init__(self,string,string_list):
        self.string = string
        self.string_list = string_list
        
    def isNextMatch(self):
        for (i,str_val) in enumerate(str_list):
            if self.string.startswith(str_val):
                self.string = self.string.split(str_val,1)[1]
                if len(self.string) == 0:
                    return True
                if i ==0:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]):
                        return True
                elif i == 1:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[2]):
                        return True
                elif i == 2:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[3]):
                        return True
                elif i == 3:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith("erase"):
                        return True
        return False
                    
                    
           
    
instance = stringJudge(input(),str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()

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

Submission status: Wrong Answer

Solution code:
str_list = ["dream","er","ase","r"]

class stringJudge():
    def __init__(self,string,string_list):
        self.string = string
        self.string_list = string_list
        
    def isNextMatch(self):
        for (i,str_val) in enumerate(str_list):
            if self.string.startswith(str_val):
                self.string = self.string.split(str_val,1)[1]
                if len(self.string) == 0:
                    return True
                if i ==0:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]):
                        return True
                elif i == 1:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[2]):
                        return True
                elif i == 2:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[3]):
                        return True
                elif i == 3:
                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]):
                        return True
        return False
                    
                    
           
    
instance = stringJudge(input(),str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()

while True:
    if s[-5::]=="dream":
        s=s[:-5:]
    elif s[-6::]=="dreamer":
        s=s[:-6:]
    elif s[-5::]=="erase":
        s=s[:-5:]
    elif s[-6::]=="eraser":
        s=s[:-6:]
    else:
        break

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

Submission status: Wrong Answer

Solution code:
s = raw_input()

n = s.count('dreamer')
m = s.count('eraser')
p = s.count('dream') - n
q = s.count('erase') - m

if len(s) == 5*(p+q) + 6*m + 7*n:
  print 'YES'
else:
  print 'NO'

Submission status: Wrong Answer

Solution code:
import re

s = raw_input()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
m1= re.compile(r'dreamer|dream|eraser|erase')
if ''==m1.sub('',input()):
    print('YES')
else:print('NO')

Submission status: Wrong Answer

Solution code:
import re
m1= re.compile(r'dream|dreamer|erase|eraser')
s=input()
if ''==m1.sub('',s):
    print('YES')
else:print('NO')

Submission status: Wrong Answer

Solution code:
s = raw_input(); i = 0; d = 1
# dreamerase eraser
while i < len(s):
	if s.startswith('dreamerase',i,i+len('dreamerase')):
		i += len('dreamerase')
	elif s.startswith('dreameraser',i,i+len('dreameraser')):
		i += len('dreameraser')
	elif s.startswith('dream',i,i+len('dream')):
		i += len('dream')
	elif s.startswith('dreamer',i,i+len('dreamer')):
		i += len('dreamer')
	elif s.startswith('erase',i,i+len('erase')):
		i += len('erase')
	elif s.startswith('eraser',i,i+len('eraser')):
		i += len('eraser')
	else:
		d = 0
		i += 1
if d == 1:
	print 'YES'
else:
	print 'NO'

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
 
s = s.replace('esare', '')
s = s.replace('resare', '')
s = s.replace('maerd', '')
s = s.replace('remaerd', '')
 
if s == '':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

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

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

Submission status: Wrong Answer

Solution code:
s = input()
head = 0
dreameraser = ["dream","dreamer","erase","eraser"]
for i in range(len(s)):
    for word in dreameraser:
        head = len(s) - len(word)
        cut = s[head:head+len(word)]
#        print(cut)
        if cut in dreameraser:
            s = s[0:head]
if s == "":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s =raw_input()[::-1]
t = map (lambda x:x[::-1], ["dreamer","dream","erase","eraser"])
for var in t:
    s = s.replace(var,"")
if s == "":
    print "YES"
else :
    print "NO"

Submission status: Wrong Answer

Solution code:
#cording : utf-8

def check(str):
    if str is "":
        return True

    strset = ["dream","dreamer","erase","eraser"]
    for s in strset:
        if str.startswith(s):
            if check(str.split(s,2)[1]):
                return True
    return False

print("YES" if check(input()) else "NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC049C

s=raw_input()
t=s.replace('eraser','')
u=t.replace('dreamer','')
v=u.replace('dream','')
w=v.replace('erase','')
#print w
if len(w)==0:
 print 'YES'
else:
 print 'NO'

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
voc=["dreamerase","dreameraser","dreamdreamer","eraseeraser","dream","dreamer","erase","eraser"]
S=input()
for s in voc:
    S_buff=S
    if s in S:
        S=S.replace(s,"")
        if voc.index(s)>3 and (len(S_buff.replace(s+"er",""))<len(S) or len(S_buff.replace(s+"r",""))<len(S)):
            S=S_buff.replace(s+"er","")
if S == "":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
s = input()
slist = list(s)

a = 7*(len(re.findall(r"dreamer",s)) - len(re.findall(r"dream",s)))
b = 5*(len(re.findall(r"dream",s)))
c = 6*(len(re.findall(r"eraser",s)) - len(re.findall(r"erase",s)))
d = 5*(len(re.findall(r"erase",s)))
e = len(slist)

if a == 0 and c == 0:
    e -= 1

if a < 0:
    a = 0

if c < 0:
    c = 0

if e == a+b+c+d:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
voc=["dreamerase","dreameraser","dreamdreamer","eraseeraser","dream","dreamer","erase","eraser"]
S=input()

for s in voc:
    S_buff=S
    if s in S:
        S=S.replace(s,"")
        if voc.index(s)>3 and (len(S_buff.replace(s+"er",""))<len(S) or len(S_buff.replace(s+"r",""))<len(S)):
            S=S_buff.replace(s+"er","")
        print(S)

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

Submission status: Wrong Answer

Solution code:
input_string = input()

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

input_string = input_string.replace("dream", "D")
input_string = input_string.replace("erase", "E")

input_string = input_string.replace("Der", "")
input_string = input_string.replace("Er", "")
input_string = input_string.replace("D", "")
input_string = input_string.replace("E", "")

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

Submission status: Wrong Answer

Solution code:
def search(pat, txt, q):
        
    M = len(pat)
    N = len(txt)
    i = 0
    j = 0
    p = 0
    t = 0
    h = 1
    d = 256
    ll = list()
    cnt = 0
    for i in range(M-1):
        h = (h*d)%q
    for i in range(M):
        p = (d*p + ord(pat[i]))%q
        t = (d*t + ord(txt[i]))%q
    for i in range(N-M+1):
        if p==t:
            for j in range(M):
                if txt[i+j] != pat[j]:
                    break
            j+=1
            if j==M:
            	cnt += 1
        if i < N-M:
            t = (d*(t-ord(txt[i])*h) + ord(txt[i+M]))%q
            if t < 0:
                t = t+q
    
    return cnt

s = input()

if len(s) < 5:
    print('NO')
else:
    a = search('dream',s,207941)
    b = search('dreamer',s,207941)
    c = search('erase',s,207941)
    d = search('eraser',s,207941)
    if b:
        a = a - b
    if d:
        c = c - d
    l = a * 5 + b * 6 + c * 5 + d * 6
    
    if l == len(s):
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
def search(pat, txt, q):
        
    M = len(pat)
    N = len(txt)
    i = 0
    j = 0
    p = 0
    t = 0
    h = 1
    d = 256
    ll = list()
    cnt = 0
    for i in range(M-1):
        h = (h*d)%q
    for i in range(M):
        p = (d*p + ord(pat[i]))%q
        t = (d*t + ord(txt[i]))%q
    for i in range(N-M+1):
        if p==t:
            for j in range(M):
                if txt[i+j] != pat[j]:
                    break
            j+=1
            if j==M:
            	cnt += 1
        if i < N-M:
            t = (d*(t-ord(txt[i])*h) + ord(txt[i+M]))%q
            if t < 0:
                t = t+q
    
    return cnt

s = input()

if len(s) < 5:
    print('NO')
else:
    a = search('dream',s,114913)
    b = search('dreamer',s,114913)
    c = search('erase',s,114913)
    d = search('eraser',s,114913)
    if b:
        a = a - b
    if d:
        c = c - d
    l = a * 5 + b * 6 + c * 5 + d * 6
    
    if l == len(s):
        print('YES')
    else:
        print('NO')