CSES - Shared codeLink to this code:
https://cses.fi/paste/262b104a22044a1a22864a/
#include <iostream>
#include<climits>
#include <vector>
#include <unordered_map>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define endl "\n";
void bhaag_kutte() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
int mod = (int)1e9 + 7;
/***************************************************************************************************************/
void solve() {
int n, amount;
cin >> n >> amount;
vi coins(n);
for (int i = 0; i < n; i++)cin >> coins[i];
vi dp(amount + 1, 0);
dp[0] = 1;
for (int i = 0; i < n; i++)
for (int x = 1; x <= amount; x++) {
int c = coins[i];
if (x >= c) {
(dp[x] += dp[x - c]) %= mod;
}
}
cout << dp[amount];
}
int main() {
bhaag_kutte();
int t = 1;
// cin>>t;
while (t-- > 0)solve();
}