






from __future__ import annotations





def 		A_			(		lowercase_					,       lowercase_					,       lowercase_	)							->int:







 """simple docstring"""

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





def 		A_			(		lowercase_					,       lowercase_	)							->int:







 """simple docstring"""

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





def 		A_			(		lowercase_					,       lowercase_					,       lowercase_	)							->int:







 """simple docstring"""

 SCREAMING_SNAKE_CASE							  =						invert_modulo(lowercase_					,       lowercase_	)
 SCREAMING_SNAKE_CASE							  =						(b * s) % n
 return x





def 		A_			(		lowercase_					,       lowercase_	)							->tuple[int, int, int]:







 """simple docstring"""

 assert a >= 0 and b >= 0

 if b == 0:
  SCREAMING_SNAKE_CASE  , SCREAMING_SNAKE_CASE  , SCREAMING_SNAKE_CASE							  =						a, 1, 0
 else:
  ((SCREAMING_SNAKE_CASE)  , (SCREAMING_SNAKE_CASE)  , (SCREAMING_SNAKE_CASE))							  =						extended_gcd(lowercase_					,       a % b	)
  SCREAMING_SNAKE_CASE							  =						q
  SCREAMING_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 		A_			(		lowercase_					,       lowercase_	)							->tuple[int, int]:







 """simple docstring"""

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





def 		A_			(		lowercase_					,       lowercase_	)							->int:







 """simple docstring"""

 if a < b:
  SCREAMING_SNAKE_CASE  , SCREAMING_SNAKE_CASE							  =						b, a

 while a % b != 0:
  SCREAMING_SNAKE_CASE  , SCREAMING_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)












from datetime import date

import requests

__UpperCAmelCase      				=							"https://api.carbonintensity.org.uk/intensity"





def 		A_			(		)							->str:







 """simple docstring"""

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





def 		A_			(		lowercase_					,       lowercase_	)							->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() = }')




