def get_next(p: int, distribution: list):
    """Return next round distribution.

    Distribution represents the success times distribution after certain 
    round, assuming this game is independent repeated experiment.
    Given distribution in this round and the probability of success,
    return the distribution in next round.

    Args:
        p: The probability of success.
        distribution: The distribution of this round.

    Returns:
        A list contains the distribution of next round.
        res[i] represent the probability of having i+1 times success.

        [0.125, 0.375, 0.375, 0.125]

    Raises:
        AssertError: when distribution is empty, or p exceeds allowed range.
    """

    assert len(distribution) > 0, "Distribution is Empty."
    assert 0 <= p <= 1, "p is more than 1 or less than 0."

    res = []
    for i in range(len(distribution)):
        if i == 0:
            # the first
            res.append(distribution[i] * (1-p))
        else:
            res.append(distribution[i-1] * p + distribution[i] * (1-p))

        if i == len(distribution) - 1:
            res.append(distribution[i] * p)

    return res