Buggy python submission (verdict: Runtime Error):
def check(string):
  l = len(string)

  if l == 0:
    return True
  
  if l < 5:
    return False

  if string[-5:] == 'dream':
    return check(string[:-5])
  if l >= 7 and string[-7:] == 'dreamer':
    return check(string[:-7])
  if string[-5:] == 'erase':
    return check(string[:-5])
  if l >= 6 and string[-6:] == 'eraser':
    return check(string[:-6])
      
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")

Fixed submission:
# dream = list(reversed('dream'))
# dreamer = list(reversed('dreamer'))
# erase = list(reversed('erase'))
# eraser = list(reversed('eraser'))

# def check(string):
#   l = len(string)

#   if l == 0:
#     return True
  
#   if l < 5:
#     return False

#   if string[0:5] == dream:
#     return check(string[5:])
#   if l >= 7 and string[0:7] == dreamer:
#     return check(string[7:])
#   if string[0:5] == erase:
#     return check(string[5:])
#   if l >= 6 and string[0:6] == eraser:
#     return check(string[6:])
      
#   return False

# S = input()
# S = list(reversed(S))
# if check(S):
#   print("YES")
# else:
#   print("NO")

s = input()
 
while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break
 
print('NO' if len(s) > 0 else 'YES')

Buggy python submission (verdict: Runtime Error):
def check(string):
  l = len(string)

  if l == 0:
    return True
  
  if l < 5:
    return False

  if string[0:5] == 'dream':
    if check(string[5:]):
      return True
    if l >= 7 and string[0:7] == 'dreamer':
      if check(string[7:]):
        return True
  elif string[0:5] == 'erase':
    if check(string[5:]):
      return True
    if l >= 6 and string[0:6] == 'eraser':
      if check(string[6:]):
        return True
  
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")


Fixed submission:
# dream = list(reversed('dream'))
# dreamer = list(reversed('dreamer'))
# erase = list(reversed('erase'))
# eraser = list(reversed('eraser'))

# def check(string):
#   l = len(string)

#   if l == 0:
#     return True
  
#   if l < 5:
#     return False

#   if string[0:5] == dream:
#     return check(string[5:])
#   if l >= 7 and string[0:7] == dreamer:
#     return check(string[7:])
#   if string[0:5] == erase:
#     return check(string[5:])
#   if l >= 6 and string[0:6] == eraser:
#     return check(string[6:])
      
#   return False

# S = input()
# S = list(reversed(S))
# if check(S):
#   print("YES")
# else:
#   print("NO")

s = input()
 
while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break
 
print('NO' if len(s) > 0 else 'YES')

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

def check(string):
  l = len(string)

  if l == 0:
    return True
  
  if l < 5:
    return False

  if string[0:5] == 'dream':
    if check(string[5:]):
      return True
    if l >= 7 and check(string[7:]):
      return True
  elif string[0:5] == 'erase':
    if check(string[5:]):
      return True
    if l >= 6 and check(string[6:]):
      return True
  else:
    return False
  
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")


Fixed submission:
# dream = list(reversed('dream'))
# dreamer = list(reversed('dreamer'))
# erase = list(reversed('erase'))
# eraser = list(reversed('eraser'))

# def check(string):
#   l = len(string)

#   if l == 0:
#     return True
  
#   if l < 5:
#     return False

#   if string[0:5] == dream:
#     return check(string[5:])
#   if l >= 7 and string[0:7] == dreamer:
#     return check(string[7:])
#   if string[0:5] == erase:
#     return check(string[5:])
#   if l >= 6 and string[0:6] == eraser:
#     return check(string[6:])
      
#   return False

# S = input()
# S = list(reversed(S))
# if check(S):
#   print("YES")
# else:
#   print("NO")

s = input()
 
while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break
 
print('NO' if len(s) > 0 else 'YES')

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

def check(string):
  if len(string) == 0:
    return True
  if string[0:5] == 'dream':
    if check(string[5:]):
      return True
    if check(string[7:]):
      return True
  elif string[0:5] == 'erase':
    if check(string[5:]):
      return True
    if check(string[6:]):
      return True
  else:
    return False
  
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")


Fixed submission:
# dream = list(reversed('dream'))
# dreamer = list(reversed('dreamer'))
# erase = list(reversed('erase'))
# eraser = list(reversed('eraser'))

# def check(string):
#   l = len(string)

#   if l == 0:
#     return True
  
#   if l < 5:
#     return False

#   if string[0:5] == dream:
#     return check(string[5:])
#   if l >= 7 and string[0:7] == dreamer:
#     return check(string[7:])
#   if string[0:5] == erase:
#     return check(string[5:])
#   if l >= 6 and string[0:6] == eraser:
#     return check(string[6:])
      
#   return False

# S = input()
# S = list(reversed(S))
# if check(S):
#   print("YES")
# else:
#   print("NO")

s = input()
 
while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break
 
print('NO' if len(s) > 0 else 'YES')