from typing import Sequence
from typing import List
from typing import Deque
import collections


def cumulative_partial_sums(nums: Sequence[int], limit: int) -> Sequence[int]:
    """Finds the partial cumulative sums of a sequence of integers.

    Args:
        nums: An arbitrary integer sequence.
        limit: The maximum number of terms to include in each partial sum.

    Returns:
        An integer sequence with length ``len(nums)``, where each term is the
        sum of up to the previous ``limit`` terms in ``nums``, including the
        term at the current index.
    """

    sums: List[int] = []
    terms: Deque[int] = collections.deque()

    total = 0
    for num in nums:
        total += num
        terms.append(num)

        if len(terms) > limit:
            total -= terms.popleft()

        sums.append(total)

    return sums