def count_subset_sum_dp(arr, total):
    """Count subsets given sum by bottom-up dynamic programming.

    Time complexity: O(nm).
    Space complexity: O(nm).
    """
    n = len(arr) - 1
    T = [[0] * (total + 1) for _ in range(n + 1)]

    for a in range(n + 1):
        T[a][0] = 1

    for a in range(n + 1):
        for t in range(1, total + 1):
            if t < arr[a]:
                T[a][t] = T[a - 1][t]
            else:
                T[a][t] = T[a - 1][t] + T[a - 1][t - arr[a]]

    return T[-1][-1]