Buggy python submission (verdict: Runtime Error):
def func(x):

    if len(x) == 0:
        return True
    elif len(x) < 5:
        return False
    else:
        if x[-5:] == "dream":
            return func(x[:-5])
        elif x[-7:] == "dreamer":
            return func(x[:-7])
        elif x[-5:] == "erase":
            return func(x[:-5])
        elif x[-6:] == "eraser":
            return func(x[:-6])
        else:
            return False

def solve(n):

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

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


Fixed submission:
def solve(n):

    while len(n) > 4:
        if n[-5:] == "dream":
            n = n[:-5]
        elif n[-7:] == "dreamer":
            n = n[:-7]
        elif n[-5:] == "erase":
            n = n[:-5]
        elif n[-6:] == "eraser":
            n = n[:-6]
        else:
            break

    return "YES" if len(n) == 0 else "NO"

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

Buggy python submission (verdict: Runtime Error):
sys.setrecursionlimit(10000)
def func(x):

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

        if x[:7] == "dreamer" and not tmp:
            tmp = func(x[7:])

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

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

    return tmp

def solve(n):

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

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


Fixed submission:
def solve(n):

    while len(n) > 4:
        if n[-5:] == "dream":
            n = n[:-5]
        elif n[-7:] == "dreamer":
            n = n[:-7]
        elif n[-5:] == "erase":
            n = n[:-5]
        elif n[-6:] == "eraser":
            n = n[:-6]
        else:
            break

    return "YES" if len(n) == 0 else "NO"

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

Buggy python submission (verdict: Runtime Error):
def func(x):

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

        if x[:7] == "dreamer" and not tmp:
            tmp = func(x[7:])

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

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

    return tmp

def solve(n):

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

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


Fixed submission:
def solve(n):

    while len(n) > 4:
        if n[-5:] == "dream":
            n = n[:-5]
        elif n[-7:] == "dreamer":
            n = n[:-7]
        elif n[-5:] == "erase":
            n = n[:-5]
        elif n[-6:] == "eraser":
            n = n[:-6]
        else:
            break

    return "YES" if len(n) == 0 else "NO"

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

Buggy python submission (verdict: Runtime Error):
def func(x):

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

        if x[:7] == "dreamer" and not tmp:
            tmp = func(x[7:])

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

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

    return tmp

def solve(n):

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

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


Fixed submission:
def solve(n):

    while len(n) > 4:
        if n[-5:] == "dream":
            n = n[:-5]
        elif n[-7:] == "dreamer":
            n = n[:-7]
        elif n[-5:] == "erase":
            n = n[:-5]
        elif n[-6:] == "eraser":
            n = n[:-6]
        else:
            break

    return "YES" if len(n) == 0 else "NO"

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