"""simple docstring"""





from __future__ import annotations





def        a_  (   _lowerCAmelCase						:				list[float]     ,				_lowerCAmelCase						:				Any  ):





       '''simple docstring'''

       print(f"""Vertex\tShortest Distance from vertex {src}"""  )
       for i, d in enumerate(_lowerCAmelCase  ):
              print(f"""{i}\t\t{d}"""  )





def        a_  (   _lowerCAmelCase						:				list[dict[str, int]]     ,				_lowerCAmelCase						:				list[float]     ,				_lowerCAmelCase						:				int  ):





       '''simple docstring'''

       for j in range(_lowerCAmelCase  ):
              lowercase__					,   lowercase__					,   lowercase__    :	Optional[Any]     					=			(graph[j][k] for k in ['src', 'dst', 'weight'])
              if distance[u] != float('inf'  ) and distance[u] + w < distance[v]:
                     return True
       return False





def        a_  (   _lowerCAmelCase						:				list[dict[str, int]]     ,				_lowerCAmelCase						:				int     ,				_lowerCAmelCase						:				int     ,				_lowerCAmelCase						:				int  ):





       '''simple docstring'''

       lowercase__    :	Union[str, Any]     					=			[float('inf'  )] * vertex_count
       lowercase__    :	Optional[int]     					=			0.0

       for _ in range(vertex_count - 1  ):
              for j in range(_lowerCAmelCase  ):
                     lowercase__					,   lowercase__					,   lowercase__    :	Dict     					=			(graph[j][k] for k in ['src', 'dst', 'weight'])

                     if distance[u] != float('inf'  ) and distance[u] + w < distance[v]:
                            lowercase__    :	str     					=			distance[u] + w

       lowercase__    :	List[Any]     					=			check_negative_cycle(_lowerCAmelCase     ,				_lowerCAmelCase     ,				_lowerCAmelCase  )
       if negative_cycle_exists:
              raise Exception('Negative cycle found'  )

       return distance


if __name__ == "__main__":
       import doctest

       doctest.testmod()

       _UpperCamelCase     :		int											=					int(input("Enter number of vertices: ").strip())
       _UpperCamelCase     :		Union[str, Any]											=					int(input("Enter number of edges: ").strip())

       _UpperCamelCase     :		list[dict[str, int]]											=					[{} for _ in range(E)]

       for i in range(E):
              print("Edge ", i + 1)
              _UpperCamelCase					,   _UpperCamelCase					,   _UpperCamelCase     :		Optional[int]											=					(
                  int(x)
                  for x in input("Enter source, destination, weight: ").strip().split(" ")
              )
              _UpperCamelCase     :		List[Any]											=					{"src": src, "dst": dest, "weight": weight}

       _UpperCamelCase     :		Tuple											=					int(input("\nEnter shortest path source:").strip())
       _UpperCamelCase     :		str											=					bellman_ford(graph, V, E, source)
       print_distance(shortest_distance, 0)


"""simple docstring"""





def        a_  (   _lowerCAmelCase						:				str  ):





       '''simple docstring'''

       lowercase__    :	Any     					=			[0] * len(_lowerCAmelCase  )

       for i in range(1     ,				len(_lowerCAmelCase  )  ):
              # use last results for better performance - dynamic programming
              lowercase__    :	List[str]     					=			prefix_result[i - 1]
              while j > 0 and input_string[i] != input_string[j]:
                     lowercase__    :	Dict     					=			prefix_result[j - 1]

              if input_string[i] == input_string[j]:
                     j += 1
              lowercase__    :	Union[str, Any]     					=			j

       return prefix_result





def        a_  (   _lowerCAmelCase						:				str  ):





       '''simple docstring'''

       return max(prefix_function(_lowerCAmelCase  )  )


if __name__ == "__main__":
       import doctest

       doctest.testmod()

