Problem p03854 (python)

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$",input()) else "NO")

Buggy submission (verdict: Runtime Error):
S=list(input())
yes_flag=0
in_flag=0
S=[s for s in S if s!=' ']
for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    in_flag=1
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    in_flag=1
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  
  if in_flag==0:
    break
  in_flag=0

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Buggy submission (verdict: Runtime Error):
S=list(input())
yes_flag=0
in_flag=0

for i in range(int(len(S)/2)):
  #print(S)
  if S[0:5] == list("erase"):
    in_flag=1
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    in_flag=1
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  
  if in_flag==0:
    break
  in_flag=0

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Buggy submission (verdict: Runtime Error):
S=list(input())
yes_flag=0
in_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    in_flag=1
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    in_flag=1
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  
  if in_flag==0:
    break
  in_flag=0

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Buggy submission (verdict: Runtime Error):
S=list(input())
yes_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Buggy submission (verdict: Runtime Error):
S=list(input())
no_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      break
  else:
    no_flag=1

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

Buggy submission (verdict: Runtime Error):
S=list(input())
no_flag=0

for i in range(len(S)):
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not S[2] == "a":
        del S[:2]
    if len(S) == 0:
      break
  else:
    no_flag=1

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