CSES - Shared codeLink to this code: https://cses.fi/paste/bebd2c2cd0dac97598385d/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll n,x;cin>>n>>x;
ll c[n],dp[x+1];
for (int i = 0; i < n; ++i) {
cin>>c[i];
}
for (int i = 0; i < x + 1; ++i) {
dp[i]=0;
}
dp[0]=1;
sort(c,c+n);
for (int i = 0; i < n; ++i) {
for (int j = 0; j <= x - c[i]; ++j) {
(dp[j+c[i]]+=dp[j])%=mod;
}
}
cout<<dp[x];
return 0;
}