CSES - Shared codeLink to this code:
https://cses.fi/paste/c63f02b96710bdd1164250/
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e6 + 1;
int a[100];
int main() {
int n, x, i, j;
cin >> n >> x;
int dp[n + 1][x + 1];
for(j = 0; j < n; j++) cin >> a[j];
for(j = 0; j <= n; j++) for(i = 0; i <= x; i++) dp[j][i] = 0;
for(j = 0; j <= n; j++) dp[j][0] = 1;
for(i = 1; i <= x; i++) {
for(j = 0; j < n; j++) {
dp[j + 1][i] = dp[j][i];
if(i - a[j] >= 0) (dp[j + 1][i] += dp[j + 1][i - a[j]]) %= MOD;
}
}
cout << dp[n][x];
}