def compute_weights(xs: list) -> list:
    """Computes and returns the weights (as a list) used in the barycentric form
    of the Lagrange polynomial.

    This function avoids checking if the input list xs is well-formed for
    performance reasons.

    Time complexity: O(n²)."""
    n = len(xs)
    ws = [1] * n
    for i in range(n):
        for j in range(n):
            if j != i:
                ws[i] *= 1 / (xs[i] - xs[j])
    return ws