def fill_matrix(matrix: list[list[int]]):
    """
    Return a new list of lists (matrix) where inner lists all have the same
    length. Inner lists that are short elements have the element 0 added.
    """
    result = []
    lengths = [len(row) for row in matrix]
    maxlen = max(lengths)
    for (i, row) in enumerate(matrix):
        if lengths[i] < maxlen:
            pad = [0] * (maxlen - lengths[i])
        else:
            pad = []
        result.append(row + pad)
    return result