





"""simple docstring"""




from urllib.error import HTTPError

from bsa import BeautifulSoup
from requests import exceptions, get

lowerCamelCase_					:						Dict      = 'https://www.wellrx.com/prescriptions/{0}/{1}/?freshSearch=true'





def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  try:
    # Has user provided both inputs?
    if not drug_name or not zip_code:
      return None

    A_  :	Tuple    						=  BASE_URL.format(_UpperCAmelCase			, _UpperCAmelCase )
    A_  :	Any    						=  get(_UpperCAmelCase )

    # Is the response ok?
    response.raise_for_status()

    # Scrape the data using bs4
    A_  :	Optional[int]    						=  BeautifulSoup(response.text			, 'html.parser' )

    # This list will store the name and price.
    A_  :	List[str]    						=  []

    # Fetch all the grids that contains the items.
    A_  :	Dict    						=  soup.find_all('div'			, {'class': 'grid-x pharmCard'} )
    if grid_list and len(_UpperCAmelCase ) > 0:
      for grid in grid_list:
        # Get the pharmacy price.
        A_  :	Optional[int]    						=  grid.find('p'			, {'class': 'list-title'} ).text

        # Get price of the drug.
        A_  :	Any    						=  grid.find('span'			, {'p', 'price price-large'} ).text

        pharmacy_price_list.append(
            {
                'pharmacy_name': pharmacy_name,
                'price': price,
            } )

    return pharmacy_price_list

  except (HTTPError, exceptions.RequestException, ValueError):
    return None


if __name__ == "__main__":
   # Enter a drug name and a zip code
   lowerCamelCase_					:						Any      = input('Enter drug name: ').strip()
   lowerCamelCase_					:						Union[str, Any]      = input('Enter zip code: ').strip()

   lowerCamelCase_					:						list | None      = fetch_pharmacy_and_price_list(
       drug_name, zip_code
   )

   if pharmacy_price_list:
      print(F"\nSearch results for {drug_name} at location {zip_code}:")
      for pharmacy_price in pharmacy_price_list:
         lowerCamelCase_					:						Optional[Any]      = pharmacy_price['pharmacy_name']
         lowerCamelCase_					:						List[Any]      = pharmacy_price['price']

         print(F"Pharmacy: {name} Price: {price}")
   else:
      print(F"No results found for {drug_name}")






"""simple docstring"""




def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  A_  :	Any    						=  len(_UpperCAmelCase )
  # Create a stack and push index of fist element to it
  A_  :	List[Any]    						=  []
  st.append(0 )

  # Span value of first element is always 1
  A_  :	List[str]    						=  1

  # Calculate span values for rest of the elements
  for i in range(1			, _UpperCAmelCase ):
    # Pop elements from stack while stack is not
    # empty and top of stack is smaller than price[i]
    while len(_UpperCAmelCase ) > 0 and price[st[0]] <= price[i]:
      st.pop()

    # If stack becomes empty, then price[i] is greater
    # than all elements on left of it, i.e. price[0],
    # price[1], ..price[i-1]. Else the price[i]  is
    # greater than elements after top of stack
    A_  :	Union[str, Any]    						=  i + 1 if len(_UpperCAmelCase ) <= 0 else (i - st[0])

    # Push this element to stack
    st.append(_UpperCAmelCase )





def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  for i in range(0			, _UpperCAmelCase ):
    print(arr[i]			, end=' ' )


# Driver program to test above function
lowerCamelCase_					:						List[Any]      = [10, 4, 5, 90, 1_20, 80]
lowerCamelCase_					:						Optional[Any]      = [0 for i in range(len(price) + 1)]

# Fill the span values in array S[]
calculation_span(price, S)





print_array(S, len(price))