




'''simple docstring'''



from __future__ import annotations







def 			_UpperCamelCase (_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int	)->   int:




     '''simple docstring'''





     assert n > 1 and a > 0 and greatest_common_divisor(_lowerCamelCase   ,	_lowerCamelCase	) == 1
     ((__snake_case)					,    (__snake_case)					,    (__snake_case))    					=  extended_gcd(_lowerCamelCase   ,	_lowerCamelCase	)  # Implemented below
     __snake_case    					=  (b * s) % n
     return x







def 			_UpperCamelCase (_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int	)->   int:




     '''simple docstring'''





     ((__snake_case)					,    (__snake_case))    					=  extended_euclid(_lowerCamelCase   ,	_lowerCamelCase	)  # Implemented below
     if b < 0:
          __snake_case    					=  (b % n + n) % n
     return b







def 			_UpperCamelCase (_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int	)->   int:




     '''simple docstring'''





     __snake_case    					=  invert_modulo(_lowerCamelCase   ,	_lowerCamelCase	)
     __snake_case    					=  (b * s) % n
     return x







def 			_UpperCamelCase (_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int	)->   tuple[int, int, int]:




     '''simple docstring'''





     assert a >= 0 and b >= 0

     if b == 0:
          __snake_case					,    __snake_case					,    __snake_case    					=  a, 1, 0
     else:
          ((__snake_case)					,    (__snake_case)					,    (__snake_case))    					=  extended_gcd(_lowerCamelCase   ,	a % b	)
          __snake_case    					=  q
          __snake_case    					=  p - q * (a // b)

     assert a % d == 0 and b % d == 0
     assert d == a * x + b * y

     return (d, x, y)







def 			_UpperCamelCase (_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int	)->   tuple[int, int]:




     '''simple docstring'''





     if b == 0:
          return (1, 0)
     ((__snake_case)					,    (__snake_case))    					=  extended_euclid(_lowerCamelCase   ,	a % b	)
     __snake_case    					=  a // b
     return (y, x - k * y)







def 			_UpperCamelCase (_lowerCamelCase							:     int   ,	_lowerCamelCase							:     int	)->   int:




     '''simple docstring'''





     if a < b:
          __snake_case					,    __snake_case    					=  b, a

     while a % b != 0:
          __snake_case					,    __snake_case    					=  b, a % b

     return b


if __name__ == "__main__":
     from doctest import testmod

     testmod(name='''modular_division''', verbose=True)
     testmod(name='''modular_division2''', verbose=True)
     testmod(name='''invert_modulo''', verbose=True)
     testmod(name='''extended_gcd''', verbose=True)
     testmod(name='''extended_euclid''', verbose=True)
     testmod(name='''greatest_common_divisor''', verbose=True)












'''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() = }""")






