





'''simple docstring'''




from __future__ import annotations





def 	__lowerCamelCase			(      __lowerCAmelCase       :							list      ,    __lowerCAmelCase       :							int      ,    __lowerCAmelCase       :							int      ,    __lowerCAmelCase       :							int		)		->  list:
   snake_case 						=   []
   snake_case						,    snake_case 						=   input_list[low:mid], input_list[mid : high + 1]
   while left and right:
      result.append((left if left[0] <= right[0] else right).pop(0		)		)
   snake_case 						=   result + left + right
   return input_list





def 	__lowerCamelCase			(      __lowerCAmelCase       :							list		)		->  list:
   if len(__lowerCAmelCase		) <= 1:
      return input_list
   snake_case 						=   list(__lowerCAmelCase		)

   # iteration for two-way merging
   snake_case 						=   2
   while p <= len(__lowerCAmelCase		):
      # getting low, high and middle value for merge-sort of single list
      for i in range(0      ,    len(__lowerCAmelCase		)      ,    __lowerCAmelCase		):
         snake_case 						=   i
         snake_case 						=   i + p - 1
         snake_case 						=   (low + high + 1) // 2
         snake_case 						=   merge(__lowerCAmelCase      ,    __lowerCAmelCase      ,    __lowerCAmelCase      ,    __lowerCAmelCase		)
      # final merge of last two parts
      if p * 2 >= len(__lowerCAmelCase		):
         snake_case 						=   i
         snake_case 						=   merge(__lowerCAmelCase      ,    0      ,    __lowerCAmelCase      ,    len(__lowerCAmelCase		) - 1		)
         break
      p *= 2

   return input_list


if __name__ == "__main__":
 _SCREAMING_SNAKE_CASE							     =			input("Enter numbers separated by a comma:\n").strip()
 if user_input == "":
  _SCREAMING_SNAKE_CASE							     =			[]
 else:
  _SCREAMING_SNAKE_CASE							     =			[int(item.strip()) for item in user_input.split(",")]
 print(iter_merge_sort(unsorted))








'''simple docstring'''




from __future__ import annotations

import os
from collections.abc import Mapping

_SCREAMING_SNAKE_CASE							     =			tuple[int, int]
class 			_lowerCAmelCase		:






     """simple docstring"""






     def __init__(   self							:			List[Any]   ,       __snake_case							:			set[int]   ,       __snake_case							:			Mapping[EdgeT, int]						)->	None:
        snake_case 						=   vertices
        snake_case 						=   {
            (min(__snake_case						), max(__snake_case						)): weight for edge, weight in edges.items()
        }



     def      lowerCAmelCase			(   self							:			Optional[Any]   ,       __snake_case							:			EdgeT   ,       __snake_case							:			int						)->	None:
        self.vertices.add(edge[0]						)
        self.vertices.add(edge[1]						)
        snake_case 						=   weight



     def      lowerCAmelCase			(   self							:			str						)->	Graph:
        snake_case 						=   Graph({min(self.vertices						)}   ,       {}						)
        snake_case 						=   42
        snake_case 						=   42
        snake_case 						=   42
        snake_case 						=   42

        while len(subgraph.vertices						) < len(self.vertices						):
           snake_case 						=   max(self.edges.values()						) + 1
           for edge, weight in self.edges.items():
              if (edge[0] in subgraph.vertices) ^ (edge[1] in subgraph.vertices):
                 if weight < min_weight:
                    snake_case 						=   edge
                    snake_case 						=   weight

           subgraph.add_edge(__snake_case   ,       __snake_case						)

        return subgraph





def 	__lowerCamelCase			(      __lowerCAmelCase       :							str = "p107_network.txt"		)		->  int:
   snake_case 						=   os.path.abspath(os.path.dirname(__lowerCAmelCase		)		)
   snake_case 						=   os.path.join(__lowerCAmelCase      ,    __lowerCAmelCase		)
   snake_case 						=   {}
   snake_case 						=   42
   snake_case 						=   42
   snake_case 						=   42

   with open(__lowerCAmelCase		) as f:
      snake_case 						=   f.read().strip().split("""\n"""		)

   snake_case 						=   [line.split(""","""		) for line in data]

   for edgea in range(1      ,    len(__lowerCAmelCase		)		):
      for edgea in range(__lowerCAmelCase		):
         if adjaceny_matrix[edgea][edgea] != "-":
            snake_case 						=   int(adjaceny_matrix[edgea][edgea]		)

   snake_case 						=   Graph(set(range(len(__lowerCAmelCase		)		)		)      ,    __lowerCAmelCase		)

   snake_case 						=   graph.prims_algorithm()

   snake_case 						=   sum(graph.edges.values()		)
   snake_case 						=   sum(subgraph.edges.values()		)

   return initial_total - optimal_total


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

