



"""simple docstring"""






from itertools import zip_longest

import requests
from bsa import BeautifulSoup
from pandas import DataFrame


def 			_lowercase				(  __snake_case = "laptop"	)						->   DataFrame:
			__lowerCAmelCase      :  str												=       F"""https://www.amazon.in/laptop/s?k={product}"""
			__lowerCAmelCase      :  Union[str, Any]												=       {
			    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36\n        (KHTML, like Gecko)Chrome/44.0.2403.157 Safari/537.36",
			    "Accept-Language": "en-US, en;q=0.5",
			}
			__lowerCAmelCase      :  List[str]												=       BeautifulSoup(requests.get(__snake_case					,headers=__snake_case	).text	)
			# Initialize a Pandas dataframe with the column titles
			__lowerCAmelCase      :  Dict												=       DataFrame(
			    columns=[
			        "Product Title",
			        "Product Link",
			        "Current Price of the product",
			        "Product Rating",
			        "MRP of the product",
			        "Discount",
			    ]	)
			# Loop through each entry and store them in the dataframe
			for item, _ in zip_longest(
			    soup.find_all(
			        "div"					,attrs={"class": "s-result-item", "data-component-type": "s-search-result"}					,)					,soup.find_all("div"					,attrs={"class": "a-row a-size-base a-color-base"}	)					,):
						try:
									__lowerCAmelCase      :  Any												=       item.ha.text
									__lowerCAmelCase      :  Union[str, Any]												=       "https://www.amazon.in/" + item.ha.a["href"]
									__lowerCAmelCase      :  Any												=       item.find("span"					,attrs={"class": "a-offscreen"}	).text
									try:
												__lowerCAmelCase      :  Union[str, Any]												=       item.find("span"					,attrs={"class": "a-icon-alt"}	).text
									except AttributeError:
												__lowerCAmelCase      :  Optional[Any]												=       "Not available"
									try:
												__lowerCAmelCase      :  Union[str, Any]												=       (
												    "₹"
												    + item.find(
												        "span"					,attrs={"class": "a-price a-text-price"}	).text.split("₹"	)[1]
												)
									except AttributeError:
												__lowerCAmelCase      :  Dict												=       ""
									try:
												__lowerCAmelCase      :  str												=       float(
												    (
												        (
												            float(product_mrp.strip("₹"	).replace(","					,""	)	)
												            - float(product_price.strip("₹"	).replace(","					,""	)	)
												        )
												        / float(product_mrp.strip("₹"	).replace(","					,""	)	)
												    )
												    * 100	)
									except ValueError:
												__lowerCAmelCase      :  List[str]												=       float("nan"	)
						except AttributeError:
									pass
						__lowerCAmelCase      :  int												=       [
						    product_title,
						    product_link,
						    product_price,
						    product_rating,
						    product_mrp,
						    discount,
						]
			__lowerCAmelCase      :  Union[str, Any]												=       " "
			__lowerCAmelCase      :  Union[str, Any]												=       " "
			data_frame.index += 1
			return data_frame


if __name__ == "__main__":
	__snake_case							:   Any      =    'headphones'
	get_amazon_product_data(product).to_csv(F"""Amazon Product Data for {product}.csv""")




"""simple docstring"""






from __future__ import annotations


def 			_lowercase				(  __snake_case					,__snake_case					,__snake_case					,__snake_case	)						->   list:
			__lowerCAmelCase      :  Dict												=       []
			__lowerCAmelCase						,	__lowerCAmelCase      :  Any												=       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	)	)
			__lowerCAmelCase      :  int												=       result + left + right
			return input_list


def 			_lowercase				(  __snake_case	)						->   list:
			if len(__snake_case	) <= 1:
						return input_list
			__lowerCAmelCase      :  int												=       list(__snake_case	)

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

			return input_list


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