ZhenlongDai/ACPR huggingface dataset:
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



__author__ = 'bugttle <bugttle@gmail.com>'

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


def check(S):
    T = ''
    while True:
        for word in WORDS:
            if S.endswith(word):
                T += word
                S = S[:S.rfind(word)]
                if S == '':
                    return 'YES'
                continue
        return 'NO'


def main():
    S = input()
    answer = check(S)
    print(answer)


if __name__ == '__main__':
    main()


Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):



__author__ = 'bugttle <bugttle@gmail.com>'

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


def match_word(S):
    for word in WORDS:
        if S.endswith(word):
            return word
    return None


def check(S):
    while True:
        word = match_word(S)
        if word is None:
            return 'NO'
        S = S[:S.rfind(word)]
        if S == '':
            return 'YES'


def main():
    S = input()
    print(check(S))


if __name__ == '__main__':
    main()

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
ans = 'NO'
while len(S)!=0:
    if(''.join(S[-5:])=='dream' or ''.join(S[-5:])=='erase'):
        del S[-5:]
    elif(''.join(S[-6:])==(('eraser'))):
        del S[-6:]
    elif(''.join(S[-7:])==(('dreamer'))):
        del S[-7:]
    else:
        print('else')
        break

if len(S)==0:
    ans = 'YES'

print(ans)


Failing test case input:
arr`egqccrl

Expected output:
NO


Actual output:
else
NO


Fixed submission (verdict: Accepted):
S = list(input())
ans = 'NO'
while len(S)!=0:
    if(''.join(S[-5:])=='dream' or ''.join(S[-5:])=='erase'):
        del S[-5:]
    elif(''.join(S[-6:])==(('eraser'))):
        del S[-6:]
    elif(''.join(S[-7:])==(('dreamer'))):
        del S[-7:]
    else:
        break

if len(S)==0:
    ans = 'YES'

print(ans)

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

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

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

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
S = input()[::-1]

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

for i in m:
    S = S.replace(i[::-1],"")


print("YES" if S == "" else "NO")
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = input()
x = x[::-1]

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

Failing test case input:
nqbfrtead

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
x = input()
x = x[::-1]

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

Problem: p03854
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
ans="Yes"
while True:
    if len(s)==i:
        break
    if s[i:i+5]==A[0]:
        i+=5
    elif s[i:i+7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        ans="No"
        break
print(ans)


Failing test case input:
maerdesare

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
s = input()
s=s[::-1]
i=0
ans="YES"
while True:
    if len(s)==i:
        break
    elif s[i:i+5]=="maerd":
        i+=5
    elif s[i:i+7]=="remaerd":
        i+=7
    elif s[i:i+5]=='esare':
        i+=5
    elif s[i:i+6]=='resare':
        i+=6
    else:
        ans="NO"
        break
print(ans)

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import re;
s = input();
print("Yes" if re.fullmatch(r'^(dream|dreamer|eraser|erase)*$', s) else "NO")


Failing test case input:
dreameraser

Expected output:
YES

Actual output:
Yes


Fixed submission (verdict: Accepted):
import re;
s = input();
print("YES" if re.fullmatch(r'^(dream|dreamer|eraser|erase)*$', s) else "NO")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S0 = input()
S = S0[::-1]
cands = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
i = 0
while i < len(S):
  for word in cands:
    
    if S[i:].startswith(word):
    	i += len(word)
    	continue
  print("NO")
  exit(0)

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


Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
S0 = input()
S = S0[::-1]
cands = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
i = 0
while i < len(S):
  f = False
  for word in cands:
    
    if S[i:].startswith(word):
        f = True
        i += len(word)
        break
  if f == False:
    print("NO")
    exit(0)

if i == len(S):
  print("YES")
else:
  print("NO")
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
S = S[::-1]
_ = ["dream", "dreamer", "erase", "eraser"]
_ = [_[i][::-1] for i in range(4)]
i = 0
while i < len(S):
    can = False
    for k in _:
        if S[i:i + len(k)] == k:
            can = True
            i += len(k)
    if not can:
        print("No")
        exit()
print("Yes")

Failing test case input:
taepdp`eem

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
S = input()
S = S[::-1]
_ = ["dream", "dreamer", "erase", "eraser"]
_ = [_[i][::-1] for i in range(4)]
i = 0
while i < len(S):
    can = False
    for k in _:
        if S[i:i + len(k)] == k:
            can = True
            i += len(k)
    if not can:
        print("NO")
        exit()
print("YES")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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()

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
7 12
11
YES


Fixed submission (verdict: Accepted):
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":
                    if s[l:r + 2] == "remaerd":
                        l += 7
                        r += 7
                    else:
                        raise EndLoop
                elif s[l:r] == "resar":
                    if s[l:r + 1] == "resare":
                        l += 6
                        r += 6
                    else:
                        raise EndLoop
                else:
                    raise EndLoop

            print("YES")
            break
        except:
            print("NO")
            break


solve()
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
l = ['dream', 'dreamer', 'erase', 'eraser', ]

s = "".join(S[-1::-1].split(l[0][-1::-1]))

for i in range(1, 4):
    s = "".join(s.split(l[i][-1::-1]))

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


Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
S = input()
l = ['eraser', 'erase', 'dreamer','dream']

s = "".join(S[-1::-1].split(l[0][-1::-1]))

for i in range(1, 4):
    s = "".join(s.split(l[i][-1::-1]))

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

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
print("YES" if len(input().replace("dreamer", "").replace("eraser", "").replace(
    "dream", "").replace("erase", "")) == 0 else "NO")

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
print("YES" if len(input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace(
    "dream", "")) == 0 else "NO")

Problem: p03854
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
x = input()
ans = "No"
def f(s):
    if len(s)==0:
        global ans
        ans = "Yes"
    else:
        if s[0:5] == "dream":
            f(s[5:])
        if s[0:7] == "dreamer":
            f(s[7:])
        if s[0:5] == "erase":
            f(s[5:])
        if s[0:7] == "eraser":
            f(s[7:])
f(x)
print(ans)

Failing test case input:
mqeefdr_at

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10000000)
x = input()
n = len(x)
ans = "NO"

def f(i):
    if n==i:
        global ans
        ans = "YES"
    else:
        if x[i:i+5] == "dream":
            f(i+5)
        if x[i:i+7] == "dreamer":
            f(i+7)
        if x[i:i+5] == "erase":
            f(i+5)
        if x[i:i+6] == "eraser":
            f(i+6)
f(0)
print(ans)

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
s=input()
while(s):
  if(s[:7]=="dreamer"):
    s=s[7:]
  elif(s[:5]=="dream"):
    s=s[5:]
  elif(s[:6]=="eraser"):
    s=s[6:]
  elif(s[:5]=="erase"):
    s=s[5:]
  else:
    print("NO")
    sys.exit()
print("YES")

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
import sys
s=input()
while(s):
  if(s[-7:]=="dreamer"):
    s=s[:-7]
  elif(s[-5:]=="dream"):
    s=s[:-5]
  elif(s[-6:]=="eraser"):
    s=s[:-6]
  elif(s[-5:]=="erase"):
    s=s[:-5]
  else:
    print("NO")
    sys.exit()
print("YES")
Problem: p03854
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
input_str = input()

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

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
input_str = input()

while(True):
  if input_str[0:11] == "dreameraser":
    input_str = input_str[11:]
  elif input_str[0:10] == "dreamerase":
    input_str = input_str[10:]
  elif input_str[0:7] == "dreamer":
    input_str = input_str[7:]
  elif input_str[0:6] == "eraser":
    input_str = input_str[6:]
  elif input_str[0:5] == "dream" or input_str[0:5] == "erase":
    input_str = input_str[5:]
  else:
    print("NO")
    break
  
  if len(input_str) == 0:
    print("YES")
    break

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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('YES')


Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
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('YES')

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()


S = S[::-1]
print(S)

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

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







Failing test case input:
resaremaerd

Expected output:
NO


Actual output:
dreameraser
NO


Fixed submission (verdict: Accepted):
S = input()


S = S[::-1]

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

if S == "":
        print("YES")
else:
        print("NO")
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

ichi = 0
cnt = 0
l = len(s)

while True:
    s_dreamer = s.find ("dreamer",ichi,l)
    s_eraser = s.find ("eraser",ichi,l)
    s_dream = s.find ("dream",ichi,l)
    s_erase = s.find ("erase",ichi,l)


    if s_dream == ichi:
        ichi = s_dreamer + 7
        cnt += 7 

    elif s_erase == ichi:
        ichi = s_eraser + 6
        cnt += 6  

    elif s_dreamer == ichi:
        ichi = s_dream + 5
        cnt += 5  

    elif s_eraser == ichi:
        ichi = s_erase + 5
        cnt += 5

    elif cnt == l:
        print("YES")
        break

    else:
        print("NO")
        break

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
s = input()

ichi = 0
l = len(s)
cnt = l

while True:
    s_dreamer = s.rfind ("dreamer",ichi,l)
    s_eraser = s.rfind ("eraser",ichi,l)
    s_dream = s.rfind ("dream",ichi,l)
    s_erase = s.rfind ("erase",ichi,l)

    if s_dreamer == l - 7 and 0 <= l - 7:
        l = s_dreamer
        cnt -= 7 

    elif s_eraser == l - 6 and 0 <= l - 6:
        l = s_eraser
        cnt -= 6  

    elif s_dream == l - 5 and 0 <= l - 5:
        l = s_dream
        cnt -= 5  

    elif s_erase == l - 5 and 0 <= l - 5:
        l = s_erase
        cnt -= 5

    elif cnt == 0:
        print("YES")
        break

    else:
        print("NO")
        break

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = str(input())
 
inputs = inputs.replace("eraser", "").replace("erase", "")
inputs = inputs.replace("dreamer", "").replace("dream", "")

print(inputs)

if len(list(inputs)) > 0:
  print("NO")
else:
  print("YES")

Failing test case input:
brr`lgdrccq

Expected output:
NO


Actual output:
brr`lgdrccq
NO


Fixed submission (verdict: Accepted):
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = str(input())
 
inputs = inputs.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")

if len(list(inputs)) > 0:
  print("NO")
else:
  print("YES")
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
word=input()

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



while 1:
  if word[len(word)-5:]==wordList[0]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[1]:
    word=word[:len(word)-7]
  elif word[len(word)-5:]==wordList[2]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[3]:
    word=word[:len(word)-7]
  else:
    print("NO")
    break
  if word=="":
    print("YES")
    break

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
word=input()

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



while 1:
  if word[len(word)-5:]==wordList[0]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[1]:
    word=word[:len(word)-7]
  elif word[len(word)-5:]==wordList[2]:
    word=word[:len(word)-5]
  elif word[len(word)-6:]==wordList[3]:
    word=word[:len(word)-6]
  else:
    print("NO")
    break
  if word=="":
    print("YES")
    break

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
n_s = len(s)
S = ''
for i in range(n_s):
    S += s[-i-1]
words = ["maerd", "remaerd", "esare", "resare"]
cnt = 0
result = 'Yes'
while True:
    
    if S[cnt:cnt+5] == 'maerd':
        cnt += 5
    elif S[cnt:cnt+5] == 'esare':
        cnt += 5
    elif S[cnt:cnt+6] == 'resare':
        cnt += 6
    elif S[cnt:cnt+7] == 'remaerd':
        cnt += 7
    else:
        result = 'No'
        break
    if cnt == n_s:
        break
print(result)

Failing test case input:
meeepdp`at

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
s = input()
n_s = len(s)
S = ''
for i in range(n_s):
    S += s[-i-1]
words = ["maerd", "remaerd", "esare", "resare"]
cnt = 0
result = 'YES'
while True:
    if S[cnt:cnt+5] == 'maerd':
        cnt += 5
    elif S[cnt:cnt+5] == 'esare':
        cnt += 5
    elif S[cnt:cnt+6] == 'resare':
        cnt += 6
    elif S[cnt:cnt+7] == 'remaerd':
        cnt += 7
    else:
        result = 'NO'
        break
    if cnt == n_s:
        break
print(result)
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
while s:
    if ''.join(s[:5]) == 'erase':
        for i in range(5):
            s.pop(0)
        if len(s) >= 1:
            if s[0] == 'r':
                s.pop(0)
    elif ''.join(s[:5]) == 'dream':
        for i in range(5):
            s.pop(0)          
        if len(s) >= 2:
            if ''.join(s[:2]) == 'er':
                for i in range(2):
                    s.pop(0)
    else:
        print('NO')
        exit()
    
    if len(s) == 0:
        print('YES')
        exit()

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
s = list(input())
while s:
    if ''.join(s[-5:]) == 'erase' or ''.join(s[-5:]) == 'dream':
        for i in range(5):
            s.pop()
    elif ''.join(s[-6:]) == 'eraser':
        for i in range(6):
            s.pop()
    elif ''.join(s[-7:]) == 'dreamer':
        for i in range(7):
            s.pop()
    else:
        print('NO')
        exit()
    
    if len(s) == 0:
        print('YES')
        exit()

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
strings = input()

word_list = ["dream", "erase", "dreamer", "eraser"]
rev_list = ["maerd", "esare", "remaerd", "resare"]

match = ""

for s in reversed(strings):  
  match += s
  
  if match in rev_list:
    match = ""

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

Failing test case input:
dreamerer

Expected output:
NO

Actual output:
No


Fixed submission (verdict: Accepted):
strings = input()

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

match = ""

for s in reversed(strings):  
  match += s
  
  if match in rev_list:
    match = ""

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

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

L = ["eraser", "dreamer", "erase", "dream"]
i = 0
f = 0
while i < len(s):
    if s[i:i+6] == "eraser":
        i += 6
        break
    elif s[i:i+7] == "dreamer" and (len(s) == i+7 or s[i+7:i+9] != "as"):
        i += 7
        break
    if s[i:i+5] == "erase" or s[i:i+5] == "dream":
        i += 5
        break
    else:
        f = 1
        break

if f == 0:
    print("YES")
else:
    print("NO")


Failing test case input:
dreamerer

Expected output:
NO

Actual output:
YES


Fixed submission (verdict: Accepted):
s = input()

L = ["eraser", "dreamer", "erase", "dream"]
i = 0
f = 0
while i < len(s):
    if s[i:i+6] == "eraser" and (len(s) == i+6 or s[i+6:i+8] != "as"):
        i += 6
    elif s[i:i+7] == "dreamer" and (len(s) == i+7 or s[i+7:i+9] != "as"):
        i += 7
    elif s[i:i+5] == "erase" or s[i:i+5] == "dream":
        i += 5
    else:
        f = 1
        break

if f == 0:
    print("YES")
else:
    print("NO")
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input().replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')
if s:
    print('NO')
else:
    print('YES')

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = ''
while s:
    a = ''
    for i in ['dream', 'erase', 'dreamer', 'eraser']:
        if s.startswith(i) : a = i
    if a == '' : print('NO');exit()
    s = s[len(a):]
print('YES')

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
s = input()
t = ''
while s:
    a = ''
    for i in ['eraser', 'erase', 'dreamer', 'dream']:
        if s.endswith(i) : a = i; break
    if a == '' : print('NO');exit()
    s = s[:-len(a)]
print('YES')

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):


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

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
while s != '':
    tmp = s
    s = s[-5:].replace('dream', '')
    s = s[-7:].replace('dreamer', '')
    s = s[-5:].replace('erase', '')
    s = s[-6:].replace('eraser', '')
    if s == '':
        print('YES')
    if tmp == s:
        print('NO')
        break

Failing test case input:
eq_tfdream

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
s = input()
while s != '':
    tmp = s
    s = s.replace('eraser', '')
    s = s.replace('erase', '')
    s = s.replace('dreamer', '')
    s = s.replace('dream', '')
    if s == '':
        print('YES')
    if tmp == s:
        print('NO')
        break

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

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

damm = True

T = ''

while damm:
    damm = False
    for test in words:
        if S.endswith(test+T):
            T = test + T
            damm = True
            break
    if S == T:
        damm = True
        break

if damm:
    print('Yes')
else:
    print('No')


Failing test case input:
arrerfl`drc

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
S = input()

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

damm = True

T = ''

while damm:
    damm = False
    for test in words:
        if S.endswith(test+T):
            T = test + T
            damm = True
            break
    if S == T:
        damm = True
        break

if damm:
    print('YES')
else:
    print('NO')
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
s = S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s == "":
    print("Yes")
else:
    print("No")

Failing test case input:
mfeeqdq`at

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
S = input()
s = S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s == "":
    print("YES")
else:
    print("NO")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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')


Failing test case input:
d_etrfcqn

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
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')

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
s = s.replace('erase','')
s = s.replace('eraser','')
s = s.replace('dreamer','')
s = s.replace('dream','')
if s:
    print('YES')
else:
    print('NO')

Failing test case input:
cte`meqeq

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
s = input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','')
if s:
    print('NO')
else:
    print('YES')

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def DFS(S):
    word_list = ["dreamer", "dream", "eraser", "erase"]
    stack = ["dream", "dreamer", "erase", "eraser"]
    while stack:
        word = stack.pop()
        if word == S[0]:
            return "YES"
        for i in word_list:
            next_word = word + i
            check = S[0][:len(word + i)]
            if next_word != check:
                continue
            if next_word == check:
                stack.append(next_word)
    return "NO"

Failing test case input:
nqcfrte_d

Expected output:
NO


Actual output:

Fixed submission (verdict: Accepted):
def DFS(S):
    word_list = ["dreamer", "dream", "eraser", "erase"]
    stack = ["dream", "dreamer", "erase", "eraser"]
    while stack:
        word = stack.pop()
        if word == S[0]:
            return "YES"
        for i in word_list:
            next_word = word + i
            check = S[0][:len(word + i)]
            if next_word != check:
                continue
            if next_word == check:
                stack.append(next_word)
    return "NO"
 
 
 
 
 
 
if __name__ == "__main__":
    S = [input()]
    print(DFS(S))
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = s.replace("dreamer", "").replace("dream", "").replace("eraser", "").replace("erase", "")
print("YES" if t == "" else "NO")

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
s = input()
t = s.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")
print("YES" if len(t) == 0 else "NO")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

ans = 1
while(len(s)>0):
    if s[-5:] == "dream" or s[-5:] == "erase":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif  s[-6:] == "eraser":
        s = s[:-6]
    else:
        s = ""
        ans = 0
if ans > 0:
    print("Yes")
else:    
    print("No")


Failing test case input:
d`etqfeqm

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
s = input()

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

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
import re
if re.match("(dream|dreamer|erase|erase)*$", S):
    print("YES")
else:
    print("NO")

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
S = input()
import re
if re.match("(dream|dreamer|erase|eraser)*$", S):
    print("YES")
else:
    print("NO")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
S=S[::-1]
divide=['dream','dreamer','erase','eraser'] 
flag=False
for i in range(4):
  divide[i]=divide[i][::-1]

i=0
while i<(len(S)-1):
  flag=False
  for d in divide:
    if i+(len(d)-1)<(len(S)-1) and S[i:i+len(d)]==d:   
      flag=True
      i+=len(d)-1
      break
  break

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

Failing test case input:
eq_tfdream

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
S=input()
S=S[::-1]
divide=['dream','dreamer','erase','eraser'] 
flag=False
for i in range(4):
  divide[i]=divide[i][::-1]

i=0
while i!=len(S):
  flag=False
  for d in divide:
    if S[i:i+len(d)]==d:   
      flag=True
      i+=len(d)
      break
    
  if flag==False:
     break
      
print('YES' if flag else 'NO')
Problem: p03854
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
def solve(query):
    while 1:
        if not query:
            print("Yes")
            break

        for frag in ("erase","eraser","dream","dreamer"):
            if query.endswith(frag):
                query=query[:-len(frag)]
                break
        else:
            print("No")
            break

solve(S)

Failing test case input:
p_eedo`btm

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
S=input()
def solve(query):
    while 1:
        if not query:
            print("YES")
            break

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

solve(S)

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
L=len(s)
newstring=''.join(list(reversed(s)))

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

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

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

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

    else:
        print("NO")
        exit()

print("YES")

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
s=input()
newstring=''.join(list(reversed(s)))

while len(newstring)>0:
    if newstring[:5]=="maerd":
        newstring=newstring[5:]

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

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

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

    else:
        print("NO")
        exit()

print("YES")
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

S = str(input()) 




i = len(S) - 5
if i < 0:
    print("NO")
else:
    while i >= 0:
        end_5_char = S[i:i+5]

        print(i,end_5_char)

        if end_5_char == "eamer":
            print(i,S[i-2:i])
            if i < 2 or S[i-2:i] != "dr":
                print("NO")
                break
            else:
                i -= 2
        elif end_5_char == "raser":
            print(i,S[i-1:i])
            if i < 1 or S[i-1:i] != "e":
                print("NO")
                break
            else:
                i -= 1
        elif end_5_char != "dream" and end_5_char != "erase":
            print("NO")
            break

        i -= 5
    else:
        print("OK")

Failing test case input:
cte`meqeq

Expected output:
NO


Actual output:
4 meqeq
NO


Fixed submission (verdict: Accepted):

S = str(input()) 




i = len(S) - 5
if i < 0:
    print("NO")
else:
    while i >= 0:
        end_5_char = S[i:i+5]

        

        if end_5_char == "eamer":
            
            if i < 2 or S[i-2:i] != "dr":
                print("NO")
                break
            else:
                i -= 2
        elif end_5_char == "raser":
            
            if i < 1 or S[i-1:i] != "e":
                print("NO")
                break
            else:
                i -= 1
        elif end_5_char != "dream" and end_5_char != "erase":
            print("NO")
            break

        i -= 5
    else:
        print("YES")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

div = ['dream', 'dreamer', 'erase', 'eraser']
end = 0
ans = "Yes"

while end < len(S):
    
    isExist = False
    
    for d in div:
        if d == S[len(S) - len(d) - end: len(S) - end]:
            end += len(d)
            isExist = True

    if isExist != True:
        ans = "No"
        break

print(ans)


Failing test case input:
qeqdm`erc

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
S = input()

div = ['dream', 'dreamer', 'erase', 'eraser']
end = 0
ans = "YES"

while end < len(S):
    
    isExist = False
    
    for d in div:
        if d == S[len(S) - len(d) - end: len(S) - end]:
            end += len(d)
            isExist = True

    if isExist != True:
        ans = "NO"
        break

print(ans)
Problem: p03854
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()[::-1]
d = {'maerd', 'remaerd', 'esare', 'resare'}

cnt = 0
while cnt + 5 < len(s):
    if s[cnt:cnt + 5] in d:
        cnt = cnt + 5
    elif cnt + 6 < len(s) and s[cnt:cnt + 6] in d:
        cnt = cnt + 6
    elif cnt + 7 < len(s) and s[cnt:cnt + 7] in d:
        cnt = cnt + 7
    else:
        print('NO')
        break
else:
    print('YES')


Failing test case input:
er`sedream

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
s = input()[::-1]
d = {'maerd', 'remaerd', 'esare', 'resare'}

cnt = 0
while cnt < len(s):
    if s[cnt:cnt + 5] in d:
        cnt += 5
    elif s[cnt:cnt + 6] in d:
        cnt += 6
    elif s[cnt:cnt + 7] in d:
        cnt += 7
    else:
        print('NO')
        break
else:
    print('YES')

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()[::-1]
for i in range(10**5):
  if s[:5]=="meard":
    s=s[5:]
  elif s[:7]=="ermeard":
    s=s[7:]
  elif s[:5]=="esare":
    s=s[5:]
  elif s[:6]=="resare":
    s=s[6:]
  elif s=="":
    print("YES")
    break
  else:
    print("NO")
    break

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
s=input()[::-1]
for i in range(10**5):
  if s[:5]=="maerd":
    s=s[5:]
  elif s[:7]=="remaerd":
    s=s[7:]
  elif s[:5]=="esare":
    s=s[5:]
  elif s[:6]=="resare":
    s=s[6:]
  elif s=="":
    print("YES")
    break
  else:
    print("NO")
    break
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
st=input()
c="0"
j="0"
u="0"
for i in st:
    if i=="d" and u=="0" and c=="0":
        u="d"
        j="1"
    elif i=="r" and u=="d":
        u="r1"
    elif i=="e" and u=="r1":
        u="e1"
    elif i=="a" and u=="e1":
        u="a1"
    elif i=="m" and u=="a1":
        u="0"
        
    elif i=="e" and u=="0" and c=="0":
        u="e2"
        if j !="1":
            c="1"
    elif i=="r" and u=="e2":
        u="0"
        j="2"
    elif i=="a" and u=="0" and j=="2":
        u="a2"
    elif i=="s" and u=="a2":
        u="s"
    elif i=="e" and u=="s":
        u="0"
        c="0"
        j="3"
    elif i=="r" and u=="0" and j=="3":
        j="0"
    else:
        print("NO")
        exit(0)
if u=="0":
    print("YES")
else:
    print("NO")

Failing test case input:
dreamerer

Expected output:
NO

Actual output:
YES


Fixed submission (verdict: Accepted):
st=input()
c="0"
j="0"
u="0"
for i in st:
    if i=="d" and u=="0" and c=="0":
        u="d"
        j="1"
    elif i=="r" and u=="d":
        u="r1"
    elif i=="e" and u=="r1":
        u="e1"
    elif i=="a" and u=="e1":
        u="a1"
    elif i=="m" and u=="a1":
        u="0"
        
    elif i=="e" and u=="0" and c=="0":
        u="e2"
        if j !="1":
            c="1"
    elif i=="r" and u=="e2":
        u="0"
        j="2"
    elif i=="a" and u=="0" and j=="2":
        u="a2"
    elif i=="s" and u=="a2":
        u="s"
    elif i=="e" and u=="s":
        u="0"
        c="0"
        j="3"
    elif i=="r" and u=="0" and j=="3":
        j="0"
    else:
        print("NO")
        exit(0)
if u=="0"and c=="0":
    print("YES")
else:
    print("NO")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input().strip()


i=0
while i <= len(S)-5:

    if S[i:(i+7)] == "dreamer":
        i=i+7
    elif S[i:(i+6)] == "eraser":
        i=i+6
    elif S[i:(i+5)] == "dream" or S[i:(i+5)] == "erase":
        i=i+5
    else:
        print("NO")
        break

Failing test case input:
dreameraser

Expected output:
YES

Actual output:

Fixed submission (verdict: Accepted):
S = input().strip()


i=len(S)
while i >= 0:

    if S[(i-7):i] == "dreamer":
        i=i-7
    elif S[(i-6):i] == "eraser":
        i=i-6
    elif S[(i-5):i] == "dream" or S[(i-5):i] == "erase":
        i=i-5
    else:
        print("NO")
        break

    if i == 0:
        print("YES")
        break
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
s=input()
s=s[::-1]
l=list(["maerd","remaerd","esare","resare"])
i=0
ss=len(s)
while i < ss:
  print(i)
  ok=0
  for j in l:
    print(j)
    if s[i:len(j)] == j:
      ok=1
      i += len(j)
      break
  if ok == 0:
    print("NO")
    sys.exit()
print("YES")



Failing test case input:
rrrcafe`drl

Expected output:
NO


Actual output:
0
maerd
remaerd
esare
resare
NO


Fixed submission (verdict: Accepted):
import sys
s=input()
s=s[::-1]
l=list(["maerd","remaerd","esare","resare"])
i=0
while i < len(s):
  ok=0
  for j in l:
    if s[i:i+len(j)] == j:
      ok=1
      i += len(j)
      break
  if ok == 0:
    print("NO")
    sys.exit()
print("YES")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
S=S[::-1]
divide=['dream','dreamer','erase','eraser'] 
flag=False
for i in range(4):
  divide[i]=divide[i][::-1]

i=0
while i<(len(S)-1):
  flag=False
  for d in divide:
    if i+(len(d)-1)<=(len(S)-1) and S[i:i+len(d)]==d:   
      flag=True
      i+=len(d)-1
      break
  break

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

Failing test case input:
eq`sfdream

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
S=input()
S=S[::-1]
divide=['dream','dreamer','erase','eraser'] 
flag=False
for i in range(4):
  divide[i]=divide[i][::-1]

i=0
while i!=len(S):
  flag=False
  for d in divide:
    if S[i:i+len(d)]==d:   
      flag=True
      i+=len(d)
      break
    
  if flag==False:
     break
      
print('YES' if flag else 'NO')

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input().replace("dream","&").replace("erase","%").replace("&er","").replace("%r","").replace("&","").replace("%","")
if S:
    print("no")
else:
    print("yes")

Failing test case input:
reqem`erd

Expected output:
NO


Actual output:
no


Fixed submission (verdict: Accepted):
S = input().replace("dream","&").replace("erase","%").replace("&er","").replace("%r","").replace("&","").replace("%","")
if S:
    print("NO")
else:
    print("YES")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = 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")


Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
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")
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import resource
sys.setrecursionlimit(10 ** 9)

S = input()
l = []
def dfs(n):
  print(n)
  if n == len(S):
    l.append("YES")
  if n < len(S):
    if S[n:n+5] == "erase":
      dfs(n+5)    
    if S[n:n+5] == "dream":
      dfs(n+5)  
    if S[n:n+6] == "eraser":
      dfs(n+6)              
    if S[n:n+7] == "dreamer":
      dfs(n+7)
dfs(0)
if len(l) == 0:
  l.append("NO")
print(l[0])    

Failing test case input:
qeqdm`esc

Expected output:
NO


Actual output:
0
NO


Fixed submission (verdict: Accepted):
import sys
import resource
sys.setrecursionlimit(10 ** 9)

S = input()
l = []
def dfs(n):
  if n == len(S):
    l.append("YES")
  if n < len(S):
    if S[n:n+5] == "erase":
      dfs(n+5)    
    if S[n:n+5] == "dream":
      dfs(n+5)  
    if S[n:n+6] == "eraser":
      dfs(n+6)              
    if S[n:n+7] == "dreamer":
      dfs(n+7)
dfs(0)
if len(l) == 0:
  l.append("NO")
print(l[0])

Problem: p03854
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
words = {"eraser" , "erase" , "dreamer" , "dream"}
s = input()
n = len(s)
now=""
for i in range(0 ,n):
	now = now+s[i]
	if now in words:
		now=""
if now in words or now =="":
	print("YES")
else:
	print("NO")

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
words = {"resare" , "esare" , "remaerd" , "maerd",""}
s = input()
n = len(s)
now=""
f=0
s=s[::-1]
for i in range(0 ,n):
	now = now+s[i]
	if now in words:
		now = ""
if now in words:
	print("YES")
else:
	print("NO")

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import re

s = input()
ptn = re.compile(r'maerd|remaerd|sare|resare')
tmp = s[::-1]

while(True):
  res = re.match(ptn , tmp)
  if res is None:
    print(tmp)
    break
  tmp = tmp.replace(res.group(),'',1)
  print(tmp)

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

Failing test case input:
brr`lgdrccq

Expected output:
NO


Actual output:
qccrdgl`rrb
NO


Fixed submission (verdict: Accepted):
import re

s = input()
ptn = re.compile(r'maerd|remaerd|resare|esare')
tmp = s[::-1]

while(True):
  res = re.match(ptn , tmp)
  if res is None:
    break
  tmp = tmp.replace(res.group(),'',1)

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

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
S = S[::-1]

T = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
size = 0


while size < len(S):
	if S[size:size+5] == T[0] or S[size:size+5] == T[2]:
		size += 5
	elif S[size:size+6] == T[3]:
		size += 6
	elif S[size:size+7] == T[1]:
		size += 7
	else :
		print("No")
		exit()
print("Yes")

Failing test case input:
resaremaerd

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
S = input()[::-1]
 
T = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
size = 0

while size < len(S):
	if S[size:size+5] == T[0] or S[size:size+5] == T[2]:
		size += 5
	elif S[size:size+6] == T[3]:
		size += 6
	elif S[size:size+7] == T[1]:
		size += 7
	else :
		print('NO')
		exit()
print('YES')
Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
dr ="dream" 
dre = "dreamer" 
er ="erase" 
ere = "eraser" 
a = input()
ret = "YES"
while len(a) != 0:
    if (a.endswith(dr) or a.endswith(er)):
        a = a[:len(a)-5]
    elif(a.endswith(dre) or a.endswith(ere)):
        a = a[:len(a)-7]
    else:
        ret = "NO"
        break
        
print(ret)

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
dr ="dream" 
dre = "dreamer" 
er ="erase" 
ere = "eraser" 
a = input()
ret = "YES"
while len(a) != 0:
    if (a.endswith(dr) or a.endswith(er)):
        a = a[:len(a)-5]
    elif(a.endswith(dre)):
        a = a[:len(a)-7]
    elif(a.endswith(ere)):
        a = a[:len(a)-6]
    else:
        ret = "NO"
        break
        
print(ret)

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()[::-1]
res = "Yes"
while s:
  start = len(s)
  for t in ['maerd', 'remaerd', 'esare', 'resare']:
    if t == s[:len(t)]:
      s = s[len(t):]
  if start == len(s):
    res = "No"
    break
print(res)

Failing test case input:
t`epdp`bem

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
s = input()[::-1]
while s:
  start = len(s)
  for t in ['maerd', 'remaerd', 'esare', 'resare']:
    if t == s[:len(t)]:
      s = s[len(t):]
  if start == len(s):
    break
print("YNEOS"[len(s)>0::2])

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
S = list(S)
s = ''.join(list(reversed(S)))
def main(s):
  s = s.strip('esare' 'maerd' 'resare''remaerd')
  return s
if main(s) == '':
  print('YES')
else:
  print('NO')

Failing test case input:
ersaremadrd

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
S = input()
S = list(S)
s = ''.join(list(reversed(S)))
def main(s):
  l = ["resare", "esare","remaerd", "maerd"]
  for i in l:
    s = s.replace(i, '')
  return s
if main(s) == '':
  print('YES')
elif main(s) != '':
  print('NO')

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()[::-1]
T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[-1]]
Ans = "YES"
while len(S) > 0:
    if S[0:5] in T:
        S = S[5:]
        continue
    elif S[0:7] in T:
        S = S[7:]
        continue
    else:
        Ans = "NO"
        break
print(Ans)

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
S = input()[::-1]
T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
Ans = "YES"
while len(S) > 0:
    if S[0:5] in T:
        S = S[5:]
        continue
    elif S[0:6] in T:
        S = S[6:]
        continue
    elif S[0:7] in T:
        S = S[7:]
        continue
    else:
        Ans = "NO"
        break
print(Ans)
Problem: p03854
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
while True :
  if S[0:7] == "dreamer":
    S = S.strip("dreamer")
  elif S[0:6] == "eraser":
    S = S.strip("eraser")
  elif S[0:5] == "dream":
    S = S.strip("dream")
  elif S[0:5] == "erase":
    S = S.strip("erase")
  elif len(S) == 0:
    print("YES")
    break
  else:
    print("NO")
    break
     

Failing test case input:
dreamerer

Expected output:
NO

Actual output:
YES


Fixed submission (verdict: Accepted):
S = input()
while True :
  if S[-5:] == "dream":
    S = S[:-5]
  elif S[-6:] == "eraser":
    S = S[:-6]
  elif S[-7:] == "dreamer":
    S = S[:-7]
  elif S[-5:] == "erase":
    S = S[:-5]
  elif len(S) == 0:
    print("YES")
    break
  else:
    print("NO")
    break

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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]

    f(S_list)
  elif "".join(S_list[0:10]) == "dreamerase":
    del S_list[0:10]

    f(S_list)
  elif "".join(S_list[0:7]) == "dreamer":
    del S_list[0:7]

    f(S_list)
  elif "".join(S_list[0:6]) == "eraser":
    del S_list[0:6]

    f(S_list)
  elif "".join(S_list[0:5]) == "dream" or "".join(S_list[0:5]) == "erase":
    del S_list[0:5]

    f(S_list)
  else:
    print("No")
    exit()

f(S_list)

Failing test case input:
d`etqfeqm

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
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]

    f(S_list)
  elif "".join(S_list[0:10]) == "dreamerase":
    del S_list[0:10]

    f(S_list)
  elif "".join(S_list[0:7]) == "dreamer":
    del S_list[0:7]

    f(S_list)
  elif "".join(S_list[0:6]) == "eraser":
    del S_list[0:6]

    f(S_list)
  elif "".join(S_list[0:5]) == "dream" or "".join(S_list[0:5]) == "erase":
    del S_list[0:5]

    f(S_list)
  else:
    print("NO")
    exit()

f(S_list)

Problem: p03854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
while s:
    if s[-1] == "m":
        del(s[-5:])
    elif s[-1] == "e":
        del(s[-5:])
    elif s[-3] == "m":
        del(s[-7:])
    elif s[-3] == "s":
        del(s[-6:])
    else:
        print("NO")
        break
    
    if len(s) == 0:
        print("YES")

Failing test case input:
eq`sedream

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
s = list(input())
flag = False
while s:
    if "".join(s[-5:]) == "dream":
        del(s[-5:])
    elif "".join(s[-5:]) == "erase":
        del(s[-5:])
    elif "".join(s[-7:]) == "dreamer":
        del(s[-7:])
    elif "".join(s[-6:]) == "eraser":
        del(s[-6:])
    else:
        flag = False
        break
    
    if len(s) == 0:
       flag = True 
if flag:
   print("YES")
else:
    print("NO")