Buggy python submission (verdict: Runtime Error):
WORDS = ['dream', 'dreamer', 'erase', 'eraser']


def main(s):
    for word in WORDS:
        if delete_word(s, word):
            print('YES')
            break
    else:
        print('NO')


def delete_word(s, word):
    if s.endswith(word):
        s = s[:-len(word)]
        if len(s) == 0:
            return True
        for w in WORDS:
            if delete_word(s, w):
                return True
    else:
        return False


if __name__ == "__main__":
    main(input())


Fixed submission:
WORDS = ['dream', 'dreamer', 'erase', 'eraser']
REVERSED_WORDS = [word[::-1] for word in WORDS]


def main(s):
    i = 0
    while i < len(s):
        for word in REVERSED_WORDS:
            if s[i:].startswith(word):
                i += len(word)
                break
        else:
            print('NO')
            break
    else:
        print('YES')


if __name__ == "__main__":
    main(input()[::-1])

Buggy python submission (verdict: Runtime Error):
def main(s):
    for word in ['dream', 'dreamer', 'erase', 'eraser']:
        if delete_word(s, word):
            print('YES')
            break
    else:
        print('NO')


def delete_word(s, word):
    if s.startswith(word):
        s = s[len(word):]
        if len(s) == 0:
            return True
        for w in ['dream', 'dreamer', 'erase', 'eraser']:
            if delete_word(s, w):
                return True
    else:
        return False


if __name__ == "__main__":
    main(input())


Fixed submission:
WORDS = ['dream', 'dreamer', 'erase', 'eraser']
REVERSED_WORDS = [word[::-1] for word in WORDS]


def main(s):
    i = 0
    while i < len(s):
        for word in REVERSED_WORDS:
            if s[i:].startswith(word):
                i += len(word)
                break
        else:
            print('NO')
            break
    else:
        print('YES')


if __name__ == "__main__":
    main(input()[::-1])

Buggy python submission (verdict: Runtime Error):
WORDS = ['dream', 'dreamer', 'erase', 'eraser']


def main(s):
    for word in WORDS:
        if delete_word(s, word):
            print('YES')
            break
    else:
        print('NO')


def delete_word(s, word):
    if s.startswith(word):
        s = s[len(word):]
        if len(s) == 0:
            return True
        for w in WORDS:
            if delete_word(s, w):
                return True
    else:
        return False


if __name__ == "__main__":
    main(input())


Fixed submission:
WORDS = ['dream', 'dreamer', 'erase', 'eraser']
REVERSED_WORDS = [word[::-1] for word in WORDS]


def main(s):
    i = 0
    while i < len(s):
        for word in REVERSED_WORDS:
            if s[i:].startswith(word):
                i += len(word)
                break
        else:
            print('NO')
            break
    else:
        print('YES')


if __name__ == "__main__":
    main(input()[::-1])

Buggy python submission (verdict: Runtime Error):
WORDS = ['dream', 'dreamer', 'erase', 'eraser']


def main(s):
    for word in WORDS:
        if delete_word(s, word):
            print('YES')
            break
    else:
        print('NO')


def delete_word(s, word):
    if s.startswith(word):
        s = s[len(word):]
        if len(s) == 0:
            return True
        for word in WORDS:
            if delete_word(s, word):
                return True
    else:
        return False


if __name__ == "__main__":
    main(input())


Fixed submission:
WORDS = ['dream', 'dreamer', 'erase', 'eraser']
REVERSED_WORDS = [word[::-1] for word in WORDS]


def main(s):
    i = 0
    while i < len(s):
        for word in REVERSED_WORDS:
            if s[i:].startswith(word):
                i += len(word)
                break
        else:
            print('NO')
            break
    else:
        print('YES')


if __name__ == "__main__":
    main(input()[::-1])