"""simple docstring"""






import sys
from collections import defaultdict

class lowerCamelCase		:






					'''simple docstring'''


					def __init__(						self			:				Tuple		)							->       List[str]:
									SCREAMING_SNAKE_CASE__		  =				[]



					def 			lowerCAmelCase_					(						self			:				Any   , _snake_case			:				Any		)							->       Tuple:
									return self.node_position[vertex]



					def 			lowerCAmelCase_					(						self			:				Union[str, Any]   , _snake_case			:				Tuple   , _snake_case			:				List[Any]		)							->       Optional[int]:
									SCREAMING_SNAKE_CASE__		  =				pos



					def 			lowerCAmelCase_					(						self			:				Any   , _snake_case			:				Tuple   , _snake_case			:				int   , _snake_case			:				Optional[int]   , _snake_case			:				Dict		)							->       Optional[int]:
									if start > size // 2 - 1:
													return
									else:
													if 2 * start + 2 >= size:
																	SCREAMING_SNAKE_CASE__		  =				2 * start + 1
													else:
																	if heap[2 * start + 1] < heap[2 * start + 2]:
																					SCREAMING_SNAKE_CASE__		  =				2 * start + 1
																	else:
																					SCREAMING_SNAKE_CASE__		  =				2 * start + 2
													if heap[smallest_child] < heap[start]:
																	SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				heap[smallest_child], positions[smallest_child]
																	SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				(
																	    heap[start],
																	    positions[start],
																	)
																	SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				temp, tempa

																	SCREAMING_SNAKE_CASE__		  =				self.get_position(positions[smallest_child]		)
																	self.set_position(
																	    positions[smallest_child]   , self.get_position(positions[start]		)		)
																	self.set_position(positions[start]   , _snake_case		)

																	self.top_to_bottom(_snake_case   , _snake_case   , _snake_case   , _snake_case		)



					def 			lowerCAmelCase_					(						self			:				int   , _snake_case			:				Tuple   , _snake_case			:				Any   , _snake_case			:				List[str]   , _snake_case			:				List[Any]		)							->       Union[str, Any]:
									SCREAMING_SNAKE_CASE__		  =				position[index]

									while index != 0:
													SCREAMING_SNAKE_CASE__		  =				int((index - 2) / 2		) if index % 2 == 0 else int((index - 1) / 2		)

													if val < heap[parent]:
																	SCREAMING_SNAKE_CASE__		  =				heap[parent]
																	SCREAMING_SNAKE_CASE__		  =				position[parent]
																	self.set_position(position[parent]   , _snake_case		)
													else:
																	SCREAMING_SNAKE_CASE__		  =				val
																	SCREAMING_SNAKE_CASE__		  =				temp
																	self.set_position(_snake_case   , _snake_case		)
																	break
													SCREAMING_SNAKE_CASE__		  =				parent
									else:
													SCREAMING_SNAKE_CASE__		  =				val
													SCREAMING_SNAKE_CASE__		  =				temp
													self.set_position(_snake_case   , 0		)



					def 			lowerCAmelCase_					(						self			:				int   , _snake_case			:				Optional[int]   , _snake_case			:				str		)							->       Optional[int]:
									SCREAMING_SNAKE_CASE__		  =				len(_snake_case		) // 2 - 1
									for i in range(_snake_case   , -1   , -1		):
													self.top_to_bottom(_snake_case   , _snake_case   , len(_snake_case		)   , _snake_case		)



					def 			lowerCAmelCase_					(						self			:				Optional[Any]   , _snake_case			:				Any   , _snake_case			:				Tuple		)							->       int:
									SCREAMING_SNAKE_CASE__		  =				positions[0]
									SCREAMING_SNAKE_CASE__		  =				sys.maxsize
									self.top_to_bottom(_snake_case   , 0   , len(_snake_case		)   , _snake_case		)
									return temp




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   Any:
				SCREAMING_SNAKE_CASE__		  =				Heap()

				SCREAMING_SNAKE_CASE__		  =				[0] * len(__UpperCAmelCase       )
				SCREAMING_SNAKE_CASE__		  =				[-1] * len(__UpperCAmelCase       )  # Neighboring Tree Vertex of selected vertex
				# Minimum Distance of explored vertex with neighboring vertex of partial tree
				# formed in graph
				SCREAMING_SNAKE_CASE__		  =				[]  # Heap of Distance of vertices from their neighboring vertex
				SCREAMING_SNAKE_CASE__		  =				[]

				for vertex in range(len(__UpperCAmelCase       )       ):
								distance_tv.append(sys.maxsize       )
								positions.append(__UpperCAmelCase       )
								heap.node_position.append(__UpperCAmelCase       )

				SCREAMING_SNAKE_CASE__		  =				[]
				SCREAMING_SNAKE_CASE__		  =				1
				SCREAMING_SNAKE_CASE__		  =				sys.maxsize
				for neighbor, distance in adjacency_list[0]:
								SCREAMING_SNAKE_CASE__		  =				0
								SCREAMING_SNAKE_CASE__		  =				distance
				heap.heapify(__UpperCAmelCase  ,					__UpperCAmelCase       )

				for _ in range(1  ,					len(__UpperCAmelCase       )       ):
								SCREAMING_SNAKE_CASE__		  =				heap.delete_minimum(__UpperCAmelCase  ,					__UpperCAmelCase       )
								if visited[vertex] == 0:
												tree_edges.append((nbr_tv[vertex], vertex)       )
												SCREAMING_SNAKE_CASE__		  =				1
												for neighbor, distance in adjacency_list[vertex]:
																if (
																    visited[neighbor] == 0
																    and distance < distance_tv[heap.get_position(__UpperCAmelCase       )]
																):
																				SCREAMING_SNAKE_CASE__		  =				distance
																				heap.bottom_to_top(
																				    __UpperCAmelCase  ,					heap.get_position(__UpperCAmelCase       )  ,					__UpperCAmelCase  ,					__UpperCAmelCase       )
																				SCREAMING_SNAKE_CASE__		  =				vertex
				return tree_edges


if __name__ == "__main__":  # pragma: no cover
						# < --------- Prims Algorithm --------- >
						_A   					=    int(input('Enter number of edges: ').strip())
						_A   					=    defaultdict(list)
						for _ in range(edges_number):
												_A   					=    [int(x) for x in input().strip().split()]
												adjacency_list[edge[0]].append([edge[1], edge[2]])
												adjacency_list[edge[1]].append([edge[0], edge[2]])
						print(prisms_algorithm(adjacency_list))





"""simple docstring"""






# Logistic Regression from scratch

# In[62]:

# In[63]:

# importing all the required libraries

import numpy as np
from matplotlib import pyplot as plt
from sklearn import datasets




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   List[str]:
				return 1 / (1 + np.exp(-z       ))




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase  ,					__UpperCAmelCase       )							->   Dict:
				return (-y * np.log(__UpperCAmelCase       ) - (1 - y) * np.log(1 - h       )).mean()




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase  ,					__UpperCAmelCase  ,					__UpperCAmelCase       )							->   Any:
				SCREAMING_SNAKE_CASE__		  =				np.dot(__UpperCAmelCase  ,					__UpperCAmelCase       )
				return np.sum(y * scores - np.log(1 + np.exp(__UpperCAmelCase       )       )       )




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase  ,					__UpperCAmelCase  ,					__UpperCAmelCase  ,					__UpperCAmelCase=70_000       )							->   Optional[Any]:
				SCREAMING_SNAKE_CASE__		  =				np.zeros(x.shape[1]       )

				for iterations in range(__UpperCAmelCase       ):
								SCREAMING_SNAKE_CASE__		  =				np.dot(__UpperCAmelCase  ,					__UpperCAmelCase       )
								SCREAMING_SNAKE_CASE__		  =				sigmoid_function(__UpperCAmelCase       )
								SCREAMING_SNAKE_CASE__		  =				np.dot(x.T  ,					h - y       ) / y.size
								SCREAMING_SNAKE_CASE__		  =				theta - alpha * gradient  # updating the weights
								SCREAMING_SNAKE_CASE__		  =				np.dot(__UpperCAmelCase  ,					__UpperCAmelCase       )
								SCREAMING_SNAKE_CASE__		  =				sigmoid_function(__UpperCAmelCase       )
								SCREAMING_SNAKE_CASE__		  =				cost_function(__UpperCAmelCase  ,					__UpperCAmelCase       )
								if iterations % 100 == 0:
												print(F"""loss: {j} \t"""       )  # printing the loss after every 100 iterations
				return theta


# In[68]:

if __name__ == "__main__":
						_A   					=    datasets.load_iris()
						_A   					=    iris.data[:, :2]
						_A   					=    (iris.target != 0) * 1

						_A   					=    0.1
						_A   					=    logistic_reg(alpha, x, y, max_iterations=7_0_0_0_0)
						print('theta: ', theta)  # printing the theta i.e our weights vector




						def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   Union[str, Any]:
										return sigmoid_function(
										    np.dot(__UpperCAmelCase  ,					__UpperCAmelCase       )       )  # predicting the value of probability from the logistic regression algorithm

						plt.figure(figsize=(1_0, 6))
						plt.scatter(x[y == 0][:, 0], x[y == 0][:, 1], color='b', label='0')
						plt.scatter(x[y == 1][:, 0], x[y == 1][:, 1], color='r', label='1')
						((_A)					,			(_A))   					=    (x[:, 0].min(), x[:, 0].max())
						((_A)					,			(_A))   					=    (x[:, 1].min(), x[:, 1].max())
						((_A)					,			(_A))   					=    np.meshgrid(np.linspace(xa_min, xa_max), np.linspace(xa_min, xa_max))
						_A   					=    np.c_[xxa.ravel(), xxa.ravel()]
						_A   					=    predict_prob(grid).reshape(xxa.shape)
						plt.contour(xxa, xxa, probs, [0.5], linewidths=1, colors='black')

						plt.legend()

						plt.show()




