





import numpy as np





def    _lowercase    (  _UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase )  ->     int:
				lowerCamelCase		       =n_draws * class_counts / class_counts.sum()
				# floored means we don't overshoot n_samples, but probably undershoot
				lowerCamelCase		       =np.floor(_UpperCAmelCase )
				# we add samples according to how much "left over" probability
				# they had, until we arrive at n_samples
				lowerCamelCase		       =int(n_draws - floored.sum() )
				if need_to_add > 0:
								lowerCamelCase		       =continuous - floored
								lowerCamelCase		       =np.sort(np.unique(_UpperCAmelCase ) )[::-1]
								# add according to remainder, but break ties
								# randomly to avoid biases
								for value in values:
												((lowerCamelCase)       ,     )		       =np.where(remainder == value )
												# if we need_to_add less than what's in inds
												# we draw randomly from them.
												# if we need to add more, we add them all and
												# go to the next value
												lowerCamelCase		       =min(len(_UpperCAmelCase )	,					_UpperCAmelCase )
												lowerCamelCase		       =rng.choice(_UpperCAmelCase	,					size=_UpperCAmelCase	,					replace=_UpperCAmelCase )
												floored[inds] += 1
												need_to_add -= add_now
												if need_to_add == 0:
																break
				return floored.astype(np.intaa )





def    _lowercase    (  _UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase=10 )  ->     Dict:
				lowerCamelCase       ,     lowerCamelCase		       =np.unique(_UpperCAmelCase	,					return_inverse=_UpperCAmelCase )
				lowerCamelCase		       =classes.shape[0]
				lowerCamelCase		       =np.bincount(_UpperCAmelCase )
				if np.min(_UpperCAmelCase ) < 2:
								raise ValueError("""Minimum class count error""" )
				if n_train < n_classes:
								raise ValueError(
								    """The train_size = %d should be greater or """ """equal to the number of classes = %d""" % (n_train, n_classes) )
				if n_test < n_classes:
								raise ValueError(
								    """The test_size = %d should be greater or """ """equal to the number of classes = %d""" % (n_test, n_classes) )
				lowerCamelCase		       =np.split(np.argsort(_UpperCAmelCase	,					kind="""mergesort""" )	,					np.cumsum(_UpperCAmelCase )[:-1] )
				for _ in range(_UpperCAmelCase ):
								lowerCamelCase		       =approximate_mode(_UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase )
								lowerCamelCase		       =class_counts - n_i
								lowerCamelCase		       =approximate_mode(_UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase )

								lowerCamelCase		       =[]
								lowerCamelCase		       =[]

								for i in range(_UpperCAmelCase ):
												lowerCamelCase		       =rng.permutation(class_counts[i] )
												lowerCamelCase		       =class_indices[i].take(_UpperCAmelCase	,					mode="""clip""" )
												train.extend(perm_indices_class_i[: n_i[i]] )
												test.extend(perm_indices_class_i[n_i[i] : n_i[i] + t_i[i]] )
								lowerCamelCase		       =rng.permutation(_UpperCAmelCase )
								lowerCamelCase		       =rng.permutation(_UpperCAmelCase )

								yield train, test












def    _lowercase    (  _UpperCAmelCase	,					_UpperCAmelCase )  ->     int:
				print("""\nVertex Distance""" )
				for i in range(_UpperCAmelCase ):
								if dist[i] != float("""inf""" ):
												print(_UpperCAmelCase	,					"""\t"""	,					int(dist[i] )	,					end="""\t""" )
								else:
												print(_UpperCAmelCase	,					"""\t"""	,					"""INF"""	,					end="""\t""" )
								print()





def    _lowercase    (  _UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase )  ->     Dict:
				lowerCamelCase		       =float("""inf""" )
				lowerCamelCase		       =-1
				for i in range(_UpperCAmelCase ):
								if (not vset[i]) and mdist[i] < min_val:
												lowerCamelCase		       =i
												lowerCamelCase		       =mdist[i]
				return min_ind





def    _lowercase    (  _UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase )  ->     Optional[int]:
				lowerCamelCase		       =[float("""inf""" ) for _ in range(_UpperCAmelCase )]
				lowerCamelCase		       =[False for _ in range(_UpperCAmelCase )]
				lowerCamelCase		       =0.0

				for _ in range(v - 1 ):
								lowerCamelCase		       =min_dist(_UpperCAmelCase	,					_UpperCAmelCase	,					_UpperCAmelCase )
								lowerCamelCase		       =True

								for i in range(_UpperCAmelCase ):
												if (
												    (not vset[i])
												    and graph[u][i] != float("""inf""" )
												    and mdist[u] + graph[u][i] < mdist[i]
												):
																lowerCamelCase		       =mdist[u] + graph[u][i]

				print_dist(_UpperCAmelCase	,					_UpperCAmelCase )


if __name__ == "__main__":
							UpperCAmelCase__  :	Tuple     =int(input('''Enter number of vertices: ''').strip())
							UpperCAmelCase__  :	str     =int(input('''Enter number of edges: ''').strip())

							UpperCAmelCase__  :	str     =[[float('''inf''') for i in range(V)] for j in range(V)]

							for i in range(V):
														UpperCAmelCase__  :	Dict     =0.0

							for i in range(E):
														print('''\nEdge ''', i + 1)
														UpperCAmelCase__  :	int     =int(input('''Enter source:''').strip())
														UpperCAmelCase__  :	str     =int(input('''Enter destination:''').strip())
														UpperCAmelCase__  :	List[Any]     =float(input('''Enter weight:''').strip())
														UpperCAmelCase__  :	str     =weight

							UpperCAmelCase__  :	Tuple     =int(input('''\nEnter shortest path source:''').strip())
							dijkstra(graph, V, gsrc)





