def gcd_extended(a: int, b: int) -> list:
    """
    Calculates the greatest common divisor of a and b and gives the bezout coefficients
    :param a:
    :param b:
    :return:
    """
    # Bezout coefficients
    u_prev = v = 1
    v_prev = u = 0
    round_nb = 1

    while True:
        quotient, remains = divmod(a, b)

        if remains == 0:
            if round_nb & 1:
                return [b, -u, v]
            return [b, u, -v]

        # updating coefficients
        u_tmp = u
        v_tmp = v
        u = u * quotient + u_prev
        v = v * quotient + v_prev
        u_prev = u_tmp
        v_prev = v_tmp

        # updating remains
        a = b
        b = remains

        # Increment round number
        round_nb += 1