Problem p03854 (python)

Fixed submission:
s = input()
t = ""
while len(t) < len(s):
    target_len = len(s) - len(t)

    if s[len(t)] == 'd':
        if target_len == 5:
            t += "dream"
        elif target_len == 7:
            t += "dreamer"
        elif target_len > 7:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 7 + 1] != "era":
                t += "dreamer"
            else:
                t += "dream"
        else:
            break
    else:
        if target_len == 5:
            t += "erase"
        elif target_len == 6:
            t += "eraser"
        elif target_len > 6:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 6 + 2] != "era":
                t += "eraser"
            else:
                t += "erase"
        else:
            break

    if s[0:len(t)] != t:
        break

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

Buggy submission (verdict: Runtime Error):
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])

result = True
i = 0
while i < len(s):
    can_divide = False
    for d in rev:
        if len(s_rev) - i >= len(d):
        	if s_rev[i:i + len(d)] == d:
	            can_divide = True
    	        i += len(d)
        	    break
    if not can_divide:
        result = False
        break

print("YES" if result else "NO")

Buggy submission (verdict: Runtime Error):
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])

result = True
i = 0
while i < len(s):
    can_divide = False
    for d in rev:
        print("rev:%d i:%d d:%d" % (len(s_rev), i, len(d)))
        if len(s_rev) - i > len(d) and s_rev[i:i + len(d)] == d:
            can_divide = True
            i += len(d)
            break
    if not can_divide:
        result = False
        break

print("YES" if result else "NO")

Buggy submission (verdict: Runtime Error):
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])

result = True
i = 0
while i < len(s):
    can_divide = False
    for d in rev:
        print("rev:%d i:%d d:%d" % (len(s_rev), i, len(d)))
        if len(s_rev) - i >= len(d) and s_rev[i:i + len(d)] == d:
            can_divide = True
            i += len(d)
            break
    if not can_divide:
        result = False
        break

print("YES" if result else "NO")

Buggy submission (verdict: Runtime Error):
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])

result = True
i = 0
while i < len(s):
    can_divide = False
    for d in rev:
        if len(s_rev) - i >= len(d) and s_rev[i:i + len(d)] == d:
            can_divide = True
            i += len(d)
    if not can_divide:
        result = False
        break

print("YES" if result else "NO")

Buggy submission (verdict: Runtime Error):
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])

result = True
i = 0
while i < len(s):
    print(i)
    can_divide = False
    for d in rev:
        if s_rev[i:i + len(d)] == d:
            can_divide = True
            i += len(d)
    if not can_divide:
        result = False
        break

print("YES" if result else "NO")

Buggy submission (verdict: Runtime Error):
s = input()
t = ""
while len(t) < len(s):
    target_len = len(s) - len(t)
    #print("target_len:%d s_len:%d t_len:%d" % (target_len, len(s), len(t)))

    if s[len(t)] == 'd':
        if target_len == 5:
            t += "dream"
        elif target_len == 7:
            t += "dreamer"
        elif target_len > 7:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 7 + 1] != "era":
                t += "dreamer"
            else:
                t += "dream"
        else:
            break
    else:
        if target_len == 5:
            t += "erase"
        elif target_len == 6:
            t += "eraser"
        elif target_len > 6:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 6 + 2] != "era":
                t += "eraser"
            else:
                t += "erase"
        else:
            break

    print(s, t, sep=" ")
    if s[0:len(t)] != t:
        break

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