Buggy python submission (verdict: Runtime Error):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

s = ''

def dfs(t):
    if t == s:
        return True
    for ss in a:
        tmpt = t + ss
        if len(tmpt)<= len(s) and tmpt == s[:len(tmpt)]:
            if(dfs(tmpt)):
                return True
    
    return False



def solve():
    global s
    s = input()
    init= ''

    if dfs(init):
        print('YES')
    else:
        print('NO')




solve()


Fixed submission:
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()
t = t[::-1]

def solve():
    s = ""
    for i in range(len(a)):
        a[i] = a[i][::-1]


    end = 0
    lent = len(t)
    while(len(s)<len(t)):
        ok = False
        for i in a:
            if len(s) + len(i) <= lent and i == t[len(s): len(s) + len(i)]:
                s += i
                ok = True

        if ok == False:
            print("NO")
            return
    
    print("YES")

solve()

Buggy python submission (verdict: Runtime Error):
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()


def dfs(somes):
    if somes == t:
        return True
    
    if len(somes) >= len(t):
        return False

    for i in a:
        if len(somes) + len(i) <= len(t)  and i == t[len(somes):len(somes) + len(i)]:
            if dfs(somes+i):
                return True
    
    return False

def solve():
    s = ""
    if dfs(s):
        print("YES")
    else:
        print("NO")

solve()


Fixed submission:
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()
t = t[::-1]

def solve():
    s = ""
    for i in range(len(a)):
        a[i] = a[i][::-1]


    end = 0
    lent = len(t)
    while(len(s)<len(t)):
        ok = False
        for i in a:
            if len(s) + len(i) <= lent and i == t[len(s): len(s) + len(i)]:
                s += i
                ok = True

        if ok == False:
            print("NO")
            return
    
    print("YES")

solve()

Buggy python submission (verdict: Runtime Error):
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()


def dfs(somes):
    if somes == t:
        return True
    
    if len(somes) >= len(t):
        return False

    for i in a:
        if i == t[len(somes):len(somes) + len(i)]:
            if dfs(somes+i):
                return True
    
    return False

def solve():
    s = ""
    if dfs(s):
        print("YES")
    else:
        print("NO")

solve()


Fixed submission:
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()
t = t[::-1]

def solve():
    s = ""
    for i in range(len(a)):
        a[i] = a[i][::-1]


    end = 0
    lent = len(t)
    while(len(s)<len(t)):
        ok = False
        for i in a:
            if len(s) + len(i) <= lent and i == t[len(s): len(s) + len(i)]:
                s += i
                ok = True

        if ok == False:
            print("NO")
            return
    
    print("YES")

solve()

Buggy python submission (verdict: Runtime Error):
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()


def dfs(somes):
    if somes == t:
        return True
    
    if len(somes)>= len(t):
        return False
    
    temp = somes

    for i in a:
        if dfs(somes+i):
            return True
    
    return False

def solve():
    s = ""
    if dfs(s):
        print("YES")
    else:
        print("NO")

solve()


Fixed submission:
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()
t = t[::-1]

def solve():
    s = ""
    for i in range(len(a)):
        a[i] = a[i][::-1]


    end = 0
    lent = len(t)
    while(len(s)<len(t)):
        ok = False
        for i in a:
            if len(s) + len(i) <= lent and i == t[len(s): len(s) + len(i)]:
                s += i
                ok = True

        if ok == False:
            print("NO")
            return
    
    print("YES")

solve()

Buggy python submission (verdict: Runtime Error):
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input()



def dfs(somes):
    if somes == t:
        return True
    
    if len(somes)>= len(t):
        return False
    
    temp = somes

    for i in a:
        if dfs(somes+i):
            return True
    
    return False

def solve():
    s = ""
    if dfs(s):
        print("YES")
    else:
        print("NO")


solve()


Fixed submission:
import sys, os

f = lambda:list(map(int,input().split()))
a = ["dream", "dreamer", "erase", "eraser"]
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

t = input().strip()
t = t[::-1]

def solve():
    s = ""
    for i in range(len(a)):
        a[i] = a[i][::-1]


    end = 0
    lent = len(t)
    while(len(s)<len(t)):
        ok = False
        for i in a:
            if len(s) + len(i) <= lent and i == t[len(s): len(s) + len(i)]:
                s += i
                ok = True

        if ok == False:
            print("NO")
            return
    
    print("YES")

solve()