"""simple docstring"""





from manim import *


class      UpperCAmelCase_	(    _a):


      def 		_UpperCAmelCase       (   self							)       ->					int:
             lowercase__			:		str       =	Rectangle(height=0.5		,			width=0.5							)
             lowercase__			:		str       =	Rectangle(height=0.46		,			width=0.46							).set_stroke(width=0							)

             lowercase__			:		List[str]       =	[mem.copy() for i in range(6							)]
             lowercase__			:		int       =	[mem.copy() for i in range(6							)]
             lowercase__			:		int       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		Optional[int]       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		List[str]       =	VGroup(a		,			a							).arrange(a		,			buff=0							)
             lowercase__			:		Union[str, Any]       =	Text('CPU'		,			font_size=2_4							)
             lowercase__			:		Union[str, Any]       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             cpu.move_to([-2.5, -0.5, 0]							)
             self.add(a							)

             lowercase__			:		Union[str, Any]       =	[mem.copy() for i in range(4							)]
             lowercase__			:		List[Any]       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		Tuple       =	Text('GPU'		,			font_size=2_4							)
             lowercase__			:		Optional[int]       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             gpu.move_to([-1, -1, 0]							)
             self.add(a							)

             lowercase__			:		int       =	[mem.copy() for i in range(6							)]
             lowercase__			:		List[str]       =	VGroup(*a							).arrange(a		,			buff=0							)

             lowercase__			:		int       =	Text('Model'		,			font_size=2_4							)
             lowercase__			:		Optional[Any]       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             model.move_to([3, -1.0, 0]							)
             self.add(a							)

             lowercase__			:		Dict       =	[]
             for i, rect in enumerate(a							):
                    rect.set_stroke(a							)
                    # target = fill.copy().set_fill(YELLOW, opacity=0.7)
                    # target.move_to(rect)
                    # self.add(target)

                    lowercase__			:		Dict       =	Rectangle(height=0.46 / 4		,			width=0.46 / 3							).set_stroke(width=0.0							).set_fill(a		,			opacity=0.7							)

                    if i == 0:
                           cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT							)		,			buff=0.02		,			direction=a							)
                           cpu_target.set_x(cpu_target.get_x() + 0.1							)
                    elif i == 3:
                           cpu_target.next_to(cpu_targs[0]		,			direction=a		,			buff=0.0							)
                    else:
                           cpu_target.next_to(cpu_targs[i - 1]		,			direction=a		,			buff=0.0							)
                    self.add(a							)
                    cpu_targs.append(a							)

             lowercase__			:		Any       =	[mem.copy() for i in range(6							)]
             lowercase__			:		Optional[Any]       =	VGroup(*a							).arrange(a		,			buff=0							)

             lowercase__			:		Optional[int]       =	Text('Loaded Checkpoint'		,			font_size=2_4							)
             lowercase__			:		Dict       =	Group(a		,			a							).arrange(a		,			aligned_edge=a		,			buff=0.4							)
             checkpoint.move_to([3, 0.5, 0]							)

             lowercase__			:		str       =	Square(side_length=2.2							)
             key.move_to([-5, 2, 0]							)

             lowercase__			:		Any       =	MarkupText(
                 f"""<b>Key:</b>\n\n<span fgcolor='{YELLOW}'>●</span> Empty Model"""		,			font_size=1_8		,			)

             key_text.move_to([-5, 2.4, 0]							)

             self.add(a		,			a							)

             lowercase__			:		List[Any]       =	MarkupText(
                 f"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""		,			font_size=1_8		,			)

             blue_text.next_to(a		,			DOWN * 2.4		,			aligned_edge=key_text.get_left()							)

             lowercase__			:		List[str]       =	MarkupText(
                 f"""Next, a <i><span fgcolor=\"{BLUE}\">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor=\"{BLUE}\">single shard</span>."""		,			font_size=2_4		,			)
             step_a.move_to([2, 2, 0]							)
             self.play(Write(a							)		,			Write(a							)							)

             self.play(Write(a		,			run_time=1							)		,			Create(a		,			run_time=1							)							)

             lowercase__			:		str       =	[]
             lowercase__			:		Any       =	[]
             for i, rect in enumerate(a							):
                    lowercase__			:		Optional[int]       =	fill.copy().set_fill(a		,			opacity=0.7							)
                    target.move_to(a							)
                    first_animations.append(GrowFromCenter(a		,			run_time=1							)							)

                    lowercase__			:		Optional[Any]       =	target.copy()
                    cpu_target.generate_target()
                    if i < 5:
                           cpu_target.target.move_to(cpu_left_col_base[i + 1]							)
                    else:
                           cpu_target.target.move_to(cpu_right_col_base[i - 5]							)
                    second_animations.append(MoveToTarget(a		,			run_time=1.5							)							)

             self.play(*a							)
             self.play(*a							)
             self.wait()



"""simple docstring"""





import os

_a		       =							{'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1_000}







def 	__a     (		__lowerCamelCase  ):
   UpperCAmelCase_					:					Union[str, Any]			     =    0

   UpperCAmelCase_					:					List[str]			     =    0
   while index < len(__lowerCamelCase  ) - 1:
      UpperCAmelCase_					:					Tuple			     =    SYMBOLS[numerals[index]]
      UpperCAmelCase_					:					List[str]			     =    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 	__a     (		__lowerCamelCase  ):
   UpperCAmelCase_					:					List[str]			     =    ""

   UpperCAmelCase_					:					Any			     =    num // 1000
   numerals += m_count * "M"
   num %= 1000

   UpperCAmelCase_					:					Any			     =    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

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

   with open(os.path.dirname(__lowerCamelCase  ) + roman_numerals_filename  ) as filea:
      UpperCAmelCase_					:					Optional[Any]			     =    filea.readlines()

   for line in lines:
      UpperCAmelCase_					:					Tuple			     =    line.strip()
      UpperCAmelCase_					:					Optional[Any]			     =    parse_roman_numerals(__lowerCamelCase  )
      UpperCAmelCase_					:					Tuple			     =    generate_roman_numerals(__lowerCamelCase  )
      savings += len(__lowerCamelCase  ) - len(__lowerCamelCase  )

   return savings


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


