'''simple docstring'''




from manim import *




class        a__ (  UpperCAmelCase__					):






     def   SCREAMING_SNAKE_CASE__  (					self						:						str       ):





         """simple docstring"""



         __lowerCamelCase            =    Rectangle(height=0.5    ,							width=0.5       )
         __lowerCamelCase            =    Rectangle(height=0.46    ,							width=0.46       ).set_stroke(width=0       )

         __lowerCamelCase            =    [mem.copy() for i in range(6       )]
         __lowerCamelCase            =    [mem.copy() for i in range(6       )]
         __lowerCamelCase            =    VGroup(*a       ).arrange(a    ,							buff=0       )
         __lowerCamelCase            =    VGroup(*a       ).arrange(a    ,							buff=0       )
         __lowerCamelCase            =    VGroup(a    ,							a       ).arrange(a    ,							buff=0       )
         __lowerCamelCase            =    Text('''CPU'''    ,							font_size=24       )
         __lowerCamelCase            =    Group(a    ,							a       ).arrange(a    ,							buff=0.5    ,							aligned_edge=a       )
         cpu.move_to([-2.5, -0.5, 0]       )
         self.add(a       )

         __lowerCamelCase            =    [mem.copy() for i in range(4       )]
         __lowerCamelCase            =    VGroup(*a       ).arrange(a    ,							buff=0       )
         __lowerCamelCase            =    Text('''GPU'''    ,							font_size=24       )
         __lowerCamelCase            =    Group(a    ,							a       ).arrange(a    ,							buff=0.5    ,							aligned_edge=a       )
         gpu.move_to([-1, -1, 0]       )
         self.add(a       )

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

         __lowerCamelCase            =    Text('''Model'''    ,							font_size=24       )
         __lowerCamelCase            =    Group(a    ,							a       ).arrange(a    ,							buff=0.5    ,							aligned_edge=a       )
         model.move_to([3, -1.0, 0]       )
         self.add(a       )

         __lowerCamelCase            =    []
         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)

             __lowerCamelCase            =    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       )

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

         __lowerCamelCase            =    Text('''Loaded Checkpoint'''    ,							font_size=24       )
         __lowerCamelCase            =    Group(a    ,							a       ).arrange(a    ,							aligned_edge=a    ,							buff=0.4       )
         checkpoint.move_to([3, 0.5, 0]       )

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

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

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

         self.add(a    ,							a       )

         __lowerCamelCase            =    MarkupText(
             f"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""    ,							font_size=18    ,							)

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

         __lowerCamelCase            =    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=24    ,							)
         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       )       )

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

             __lowerCamelCase            =    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'''




def __lowerCAmelCase					(				UpperCamelCase__							)      ->       float:
    __lowerCamelCase            =    0
    while len(UpperCamelCase__							) > 1:
        __lowerCamelCase            =    0
        # Consider two files with minimum cost to be merged
        for _ in range(2							):
            __lowerCamelCase            =    files.index(min(UpperCamelCase__							)							)
            temp += files[min_index]
            files.pop(UpperCamelCase__							)
        files.append(UpperCamelCase__							)
        optimal_merge_cost += temp
    return optimal_merge_cost


if __name__ == "__main__":
  import doctest

  doctest.testmod()
