CSES - Shared codeLink to this code: https://cses.fi/paste/d40aa6fee8c71199825f90/
#include <bits/stdc++.h>
using namespace std;

int main() {
    int mod = 1e9+7;
    int n, target;
    cin >> n >> target;
    vector<int> x(n);
    for (int&v : x) cin >> v;

    vector<vector<int>> dp(n+1,vector<int>(target+1,0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= target; j++) {
            dp[i][j] = dp[i-1][j];
            int left = j-x[i-1];
            if (left >= 0) {
                (dp[i][j] += dp[i][left]) %= mod;
            }
        }
    }
    cout << dp[n][target] << endl;
}