




'''simple docstring'''


import math







class     SCREAMING_SNAKE_CASE						:






      def __init__(   self      :     Optional[int]	,	lowercase__      :     Tuple					):


           '''simple docstring'''

           a_    :       Optional[Any]    	=     len(lowercase__					)
           a_    :       Optional[int]    	=     [0] * (
               4 * self.N
           )  # approximate the overall size of segment tree with array N
           self.build(1	,	0	,	self.N - 1					)






      def        lowercase_	(   self      :     Union[str, Any]	,	lowercase__      :     List[Any]					):


           '''simple docstring'''

           return idx * 2






      def        lowercase_	(   self      :     int	,	lowercase__      :     int					):


           '''simple docstring'''

           return idx * 2 + 1






      def        lowercase_	(   self      :     Union[str, Any]	,	lowercase__      :     List[str]	,	lowercase__      :     Union[str, Any]	,	lowercase__      :     Optional[Any]					):  # noqa: E741


           '''simple docstring'''

           if l == r:
                a_    :       Tuple    	=     A[l]
           else:
                a_    :       Union[str, Any]    	=     (l + r) // 2
                self.build(self.left(lowercase__					)	,	lowercase__	,	lowercase__					)
                self.build(self.right(lowercase__					)	,	mid + 1	,	lowercase__					)
                a_    :       Tuple    	=     max(self.st[self.left(lowercase__					)]	,	self.st[self.right(lowercase__					)]					)






      def        lowercase_	(   self      :     Optional[int]	,	lowercase__      :     Optional[Any]	,	lowercase__      :     Dict	,	lowercase__      :     Optional[Any]					):


           '''simple docstring'''

           return self.update_recursive(1	,	0	,	self.N - 1	,	a - 1	,	b - 1	,	lowercase__					)






      def        lowercase_	(   self      :     int	,	lowercase__      :     Optional[int]	,	lowercase__      :     Tuple	,	lowercase__      :     Optional[int]	,	lowercase__      :     Optional[int]	,	lowercase__      :     Tuple	,	lowercase__      :     Tuple					):  # noqa: E741


           '''simple docstring'''

           if r < a or l > b:
                return True
           if l == r:
                a_    :       Optional[int]    	=     val
                return True
           a_    :       Optional[Any]    	=     (l + r) // 2
           self.update_recursive(self.left(lowercase__					)	,	lowercase__	,	lowercase__	,	lowercase__	,	lowercase__	,	lowercase__					)
           self.update_recursive(self.right(lowercase__					)	,	mid + 1	,	lowercase__	,	lowercase__	,	lowercase__	,	lowercase__					)
           a_    :       Dict    	=     max(self.st[self.left(lowercase__					)]	,	self.st[self.right(lowercase__					)]					)
           return True






      def        lowercase_	(   self      :     Optional[int]	,	lowercase__      :     List[Any]	,	lowercase__      :     Union[str, Any]					):


           '''simple docstring'''

           return self.query_recursive(1	,	0	,	self.N - 1	,	a - 1	,	b - 1					)






      def        lowercase_	(   self      :     Union[str, Any]	,	lowercase__      :     Optional[Any]	,	lowercase__      :     List[Any]	,	lowercase__      :     List[str]	,	lowercase__      :     Optional[int]	,	lowercase__      :     Tuple					):  # noqa: E741


           '''simple docstring'''

           if r < a or l > b:
                return -math.inf
           if l >= a and r <= b:
                return self.st[idx]
           a_    :       List[str]    	=     (l + r) // 2
           a_    :       str    	=     self.query_recursive(self.left(lowercase__					)	,	lowercase__	,	lowercase__	,	lowercase__	,	lowercase__					)
           a_    :       str    	=     self.query_recursive(self.right(lowercase__					)	,	mid + 1	,	lowercase__	,	lowercase__	,	lowercase__					)
           return max(lowercase__	,	lowercase__					)






      def        lowercase_	(   self      :     str					):


           '''simple docstring'''

           a_    :       Union[str, Any]    	=     []
           for i in range(1	,	N + 1					):
                show_list += [self.query(lowercase__	,	lowercase__					)]
           print(lowercase__					)


if __name__ == "__main__":
       lowerCAmelCase_			:     str							    =     [1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
       lowerCAmelCase_			:     int							    =     15
       lowerCAmelCase_			:     Union[str, Any]							    =     SegmentTree(A)
       print(segt.query(4, 6))
       print(segt.query(7, 11))
       print(segt.query(7, 12))
       segt.update(1, 3, 111)
       print(segt.query(1, 15))
       segt.update(7, 8, 235)
       segt.show_data()






'''simple docstring'''


import shutil

import requests



def    _SCREAMING_SNAKE_CASE    (			UpperCamelCase__						:				str   ,						UpperCamelCase__						:				bool = False   ,						UpperCamelCase__						:				str = "."							):




     """simple docstring"""


     a_    :       Any    	=     """https://api.nasa.gov/planetary/apod"""
     return requests.get(UpperCamelCase__   ,						params={"""api_key""": api_key}							).json()



def    _SCREAMING_SNAKE_CASE    (			UpperCamelCase__						:				str   ,						UpperCamelCase__						:				str = "."							):




     """simple docstring"""


     a_    :       Tuple    	=     get_apod_data(UpperCamelCase__							)
     a_    :       Tuple    	=     apod_data["""url"""]
     a_    :       Any    	=     img_url.split("""/"""							)[-1]
     a_    :       Tuple    	=     requests.get(UpperCamelCase__   ,						stream=UpperCamelCase__							)

     with open(F"{path}/{img_name}"   ,						"""wb+"""							) as img_file:
          shutil.copyfileobj(response.raw   ,						UpperCamelCase__							)
     del response
     return apod_data



def    _SCREAMING_SNAKE_CASE    (			UpperCamelCase__						:				str							):




     """simple docstring"""


     a_    :       str    	=     """https://images-api.nasa.gov/search"""
     return requests.get(UpperCamelCase__   ,						params={"""q""": query}							).json()


if __name__ == "__main__":
 print(save_apod('YOUR API KEY'))
 lowerCAmelCase_			:     int							    =     get_archive_data('apollo 2011')['collection']['items']
 print(apollo_aaaa_items[0]['data'][0]['description'])
