

"""simple docstring"""


a					:dict[tuple[int, int, int], int]    = {}




def  _lowercase					(    __lowerCAmelCase  ,					__lowerCAmelCase  ,					__lowerCAmelCase							)       ->				int:

      # if we are absent twice, or late 3 consecutive days,
      # no further prize strings are possible
      if late == 3 or absent == 2:
            return 0

      # if we have no days left, and have not failed any other rules,
      # we have a prize string
      if days == 0:
            return 1

      # No easy solution, so now we need to do the recursive calculation

      # First, check if the combination is already in the cache, and
      # if yes, return the stored value from there since we already
      # know the number of possible prize strings from this point on
      SCREAMING_SNAKE_CASE__   :      Dict      		=	(days, absent, late)
      if key in cache:
            return cache[key]

      # now we calculate the three possible ways that can unfold from
      # this point on, depending on our attendance today

      # 1) if we are late (but not absent), the "absent" counter stays as
      # it is, but the "late" counter increases by one
      SCREAMING_SNAKE_CASE__   :      Optional[Any]      		=	_calculate(days - 1  ,					__lowerCAmelCase  ,					late + 1							)

      # 2) if we are absent, the "absent" counter increases by 1, and the
      # "late" counter resets to 0
      SCREAMING_SNAKE_CASE__   :      int      		=	_calculate(days - 1  ,					absent + 1  ,					0							)

      # 3) if we are on time, this resets the "late" counter and keeps the
      # absent counter
      SCREAMING_SNAKE_CASE__   :      Any      		=	_calculate(days - 1  ,					__lowerCAmelCase  ,					0							)

      SCREAMING_SNAKE_CASE__   :      Optional[int]      		=	state_late + state_absent + state_ontime

      SCREAMING_SNAKE_CASE__   :      Dict      		=	prizestrings
      return prizestrings




def  _lowercase					(    __lowerCAmelCase = 30							)       ->				int:
      return _calculate(__lowerCAmelCase  ,					absent=0  ,					late=0							)


if __name__ == "__main__":
  print(solution())







"""simple docstring"""


import os

a					:List[str]    = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1_000}




def  _lowercase					(    __lowerCAmelCase							)       ->				int:
      SCREAMING_SNAKE_CASE__   :      Any      		=	0

      SCREAMING_SNAKE_CASE__   :      Dict      		=	0
      while index < len(__lowerCAmelCase							) - 1:
            SCREAMING_SNAKE_CASE__   :      List[Any]      		=	SYMBOLS[numerals[index]]
            SCREAMING_SNAKE_CASE__   :      Dict      		=	SYMBOLS[numerals[index + 1]]
            if current_value < next_value:
                  total_value -= current_value
            else:
                  total_value += current_value
            index += 1
      total_value += SYMBOLS[numerals[index]]

      return total_value




def  _lowercase					(    __lowerCAmelCase							)       ->				str:
      SCREAMING_SNAKE_CASE__   :      Optional[int]      		=	""""""

      SCREAMING_SNAKE_CASE__   :      int      		=	num // 1000
      numerals += m_count * "M"
      num %= 1000

      SCREAMING_SNAKE_CASE__   :      List[str]      		=	num // 100
      if c_count == 9:
            numerals += "CM"
            c_count -= 9
      elif c_count == 4:
            numerals += "CD"
            c_count -= 4
      if c_count >= 5:
            numerals += "D"
            c_count -= 5
      numerals += c_count * "C"
      num %= 100

      SCREAMING_SNAKE_CASE__   :      List[Any]      		=	num // 10
      if x_count == 9:
            numerals += "XC"
            x_count -= 9
      elif x_count == 4:
            numerals += "XL"
            x_count -= 4
      if x_count >= 5:
            numerals += "L"
            x_count -= 5
      numerals += x_count * "X"
      num %= 10

      if num == 9:
            numerals += "IX"
            num -= 9
      elif num == 4:
            numerals += "IV"
            num -= 4
      if num >= 5:
            numerals += "V"
            num -= 5
      numerals += num * "I"

      return numerals




def  _lowercase					(    __lowerCAmelCase = "/p089_roman.txt"							)       ->				int:
      SCREAMING_SNAKE_CASE__   :      int      		=	0

      with open(os.path.dirname(__lowerCAmelCase							) + roman_numerals_filename							) as filea:
            SCREAMING_SNAKE_CASE__   :      str      		=	filea.readlines()

      for line in lines:
            SCREAMING_SNAKE_CASE__   :      Union[str, Any]      		=	line.strip()
            SCREAMING_SNAKE_CASE__   :      Dict      		=	parse_roman_numerals(__lowerCAmelCase							)
            SCREAMING_SNAKE_CASE__   :      str      		=	generate_roman_numerals(__lowerCAmelCase							)
            savings += len(__lowerCAmelCase							) - len(__lowerCAmelCase							)

      return savings


if __name__ == "__main__":
  print(f'{solution() = }')




