'''simple docstring'''




import os

__UpperCAmelCase     							={"I": 1, "V": 5, "X": 1_0, "L": 5_0, "C": 1_0_0, "D": 5_0_0, "M": 1_0_0_0}






def __lowerCAmelCase (							UpperCamelCase__				)	->    int:
    __lowerCamelCase		=  0

    __lowerCamelCase		=  0
    while index < len(UpperCamelCase__				) - 1:
        __lowerCamelCase		=  SYMBOLS[numerals[index]]
        __lowerCamelCase		=  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 __lowerCAmelCase (							UpperCamelCase__				)	->    str:
    __lowerCamelCase		=  ''''''

    __lowerCamelCase		=  num // 10_00
    numerals += m_count * "M"
    num %= 10_00

    __lowerCamelCase		=  num // 1_00
    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 %= 1_00

    __lowerCamelCase		=  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 __lowerCAmelCase (							UpperCamelCase__ = "/p089_roman.txt"				)	->    int:
    __lowerCamelCase		=  0

    with open(os.path.dirname(UpperCamelCase__				) + roman_numerals_filename				) as filea:
        __lowerCamelCase		=  filea.readlines()

    for line in lines:
        __lowerCamelCase		=  line.strip()
        __lowerCamelCase		=  parse_roman_numerals(UpperCamelCase__				)
        __lowerCamelCase		=  generate_roman_numerals(UpperCamelCase__				)
        savings += len(UpperCamelCase__				) - len(UpperCamelCase__				)

    return savings


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





"""simple docstring"""






class        __SCREAMING_SNAKE_CASE	:


					'''simple docstring'''





					def __init__(       self							:  Dict,  lowerCamelCase							:  list     )->					None:
								lowerCamelCase__		:		Tuple			=set_counts
								lowerCamelCase__		:		Dict			=max(lowerCamelCase     )
								lowerCamelCase__		:		Union[str, Any]			=len(lowerCamelCase     )
								lowerCamelCase__		:		List[str]			=[1] * num_sets
								lowerCamelCase__		:		str			=list(range(lowerCamelCase     )     )



					def 		snake_case       (       self							:  Tuple,  lowerCamelCase							:  int,  lowerCamelCase							:  int     )->					bool:
								lowerCamelCase__		:		List[Any]			=self.get_parent(lowerCamelCase     )
								lowerCamelCase__		:		str			=self.get_parent(lowerCamelCase     )

								if src_parent == dst_parent:
											return False

								if self.ranks[dst_parent] >= self.ranks[src_parent]:
											self.set_counts[dst_parent] += self.set_counts[src_parent]
											lowerCamelCase__		:		Tuple			=0
											lowerCamelCase__		:		int			=dst_parent
											if self.ranks[dst_parent] == self.ranks[src_parent]:
														self.ranks[dst_parent] += 1
											lowerCamelCase__		:		str			=self.set_counts[dst_parent]
								else:
											self.set_counts[src_parent] += self.set_counts[dst_parent]
											lowerCamelCase__		:		List[Any]			=0
											lowerCamelCase__		:		List[str]			=src_parent
											lowerCamelCase__		:		Dict			=self.set_counts[src_parent]

								lowerCamelCase__		:		str			=max(self.max_set,  lowerCamelCase     )
								return True




					def 		snake_case       (       self							:  Union[str, Any],  lowerCamelCase							:  int     )->					int:
								if self.parents[disj_set] == disj_set:
											return disj_set
								lowerCamelCase__		:		Tuple			=self.get_parent(self.parents[disj_set]     )
								return self.parents[disj_set]




