




'''simple docstring'''



class     lowerCAmelCase   :


       def __init__(   self  )      ->  Dict:



            '''simple docstring'''




            __snake_case    					=  [0]
            __snake_case    					=  0


       def       lowerCAmelCase      (   self    ,  __SCREAMING_SNAKE_CASE  )      ->  None:



            '''simple docstring'''




            __snake_case    					=  self.__heap[i]
            while i // 2 > 0:
                 if self.__heap[i] > self.__heap[i // 2]:
                      __snake_case    					=  self.__heap[i // 2]
                      __snake_case    					=  temporary
                 i //= 2


       def       lowerCAmelCase      (   self    ,  __SCREAMING_SNAKE_CASE  )      ->  None:



            '''simple docstring'''




            self.__heap.append(__SCREAMING_SNAKE_CASE  )
            self.__size += 1
            self.__swap_up(self.__size  )


       def       lowerCAmelCase      (   self    ,  __SCREAMING_SNAKE_CASE  )      ->  None:



            '''simple docstring'''




            while self.__size >= 2 * i:
                 if 2 * i + 1 > self.__size:
                      __snake_case    					=  2 * i
                 else:
                      if self.__heap[2 * i] > self.__heap[2 * i + 1]:
                           __snake_case    					=  2 * i
                      else:
                           __snake_case    					=  2 * i + 1
                 __snake_case    					=  self.__heap[i]
                 if self.__heap[i] < self.__heap[bigger_child]:
                      __snake_case    					=  self.__heap[bigger_child]
                      __snake_case    					=  temporary
                 __snake_case    					=  bigger_child


       def       lowerCAmelCase      (   self  )      ->  int:



            '''simple docstring'''




            __snake_case    					=  self.__heap[1]
            __snake_case    					=  self.__heap[self.__size]
            self.__size -= 1
            self.__heap.pop()
            self.__swap_down(1  )
            return max_value


       @property
       def       lowerCAmelCase      (   self  )      ->  Union[str, Any]:



            '''simple docstring'''




            return self.__heap[1:]




       def __len__(   self  )      ->  Dict:



            '''simple docstring'''




            return self.__size


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     # create an instance of BinaryHeap
     UpperCAmelCase_       :  Dict      =		BinaryHeap()
     binary_heap.insert(6)
     binary_heap.insert(1_0)
     binary_heap.insert(1_5)
     binary_heap.insert(1_2)
     # pop root(max-values because it is max heap)
     print(binary_heap.pop())  # 15
     print(binary_heap.pop())  # 12
     # get the list and size after operations
     print(binary_heap.get_list)
     print(len(binary_heap))





'''simple docstring'''



from datetime import date

import requests

UpperCAmelCase_       :  str      =		'''https://api.carbonintensity.org.uk/intensity'''







def 			_UpperCamelCase ()->   str:




     '''simple docstring'''





     __snake_case    					=  requests.get(_lowerCamelCase	).json()['''data'''][0]
     return last_half_hour["intensity"]["actual"]







def 			_UpperCamelCase (_lowerCamelCase							:     Dict   ,	_lowerCamelCase							:     List[Any]	)->   list:




     '''simple docstring'''





     return requests.get(f'''{BASE_URL}/{start}/{end}'''	).json()["data"]


if __name__ == "__main__":
     for entry in fetch_from_to(start=date(2_0_2_0, 1_0, 1), end=date(2_0_2_0, 1_0, 3)):
          print('''from {from} to {to}: {intensity[actual]}'''.format(**entry))
     print(F"""{fetch_last_half_hour() = }""")






