#include<bits/stdc++.h>usingnamespace std;constint N =10010;int n, m, s, v[N], w[N], cnt;int f[N][110];intmain(){scanf("%d%d",&n,&m);for(int i=0; i<n; i++){int a, b;scanf("%d%d%d",&a,&b,&s);while(s--){
v[++cnt]= a;
w[cnt]= b;}}for(int i=1; i<=cnt; i++){for(int j=1; j<=m; j++){
f[i][j]= f[i-1][j];if(j>=v[i]) f[i][j]=max(f[i][j], f[i-1][j-v[i]]+ w[i]);}}printf("%d", f[cnt][m]);return0;}
#include<bits/stdc++.h>usingnamespace std;constint N =110;typedef pair<int,int> PII;int n, m;
vector<PII> G;int f[N];intmain(){
cin >> n >> m;for(int i =0; i < n; i ++){int v, w, s;
cin >> v >> w >> s;for(int k =1; k <= s; k *=2){
s -= k;
G.push_back({k * v, k * w});}if(s) G.push_back({s * v, s * w});}for(int i =0; i < G.size(); i ++){int v = G[i].first, w = G[i].second;for(int j = m; j >= v; j --){
f[j]=max(f[j], f[j - v]+ w);}}
cout << f[m];return0;}
#include<bits/stdc++.h>usingnamespace std;int n;constint N =1010;int f[N], a[N];intmain(){
cin >> n;for(int i =1; i <= n; i ++) cin >> a[i];for(int i =1; i <= n; i ++){
f[i]=1;for(int j =1; j <= i; j ++){if(a[j]< a[i]) f[i]=max(f[i], f[j]+1);}}int res =0;for(int i =1; i <= n; i ++) res =max(res, f[i]);
cout << res;return0;}
#include<bits/stdc++.h>usingnamespace std;constint N =1010;int n, m;char a[N], b[N];int f[N][N];intmain(){scanf("%d %s",&n, a +1);scanf("%d %s",&m, b +1);// memset (f, 0x3f, sizeof f);for(int i =1; i <= n; i ++) f[i][0]= i;for(int i =1; i <= m; i ++) f[0][i]= i;for(int i =1; i <= n; i ++){for(int j =1; j <= m; j ++){
f[i][j]=min(f[i -1][j], f[i][j -1])+1;
f[i][j]=min(f[i][j], f[i -1][j -1]+(a[i]!= b[j]));}}
cout << f[n][m];return0;}
#include<bits/stdc++.h>usingnamespace std;constint N =310;int n;int f[N][N], s[N];intmain(){
cin >> n;for(int i =1; i <= n; i ++){
cin >> s[i];
s[i]+= s[i -1];}for(int len =2; len <= n; len ++){for(int l =1; l + len -1<= n; l ++){int r = l + len -1;
f[l][r]=2e9;for(int k = l; k < r; k ++){
f[l][r]=min(f[l][r], f[l][k]+ f[k +1][r]+ s[r]- s[l -1]);}}}
cout << f[1][n];return0;}
#include<bits/stdc++.h>usingnamespace std;constint N =1010, mod =1e9+7;int n;int f[N][N];intmain(){
cin >> n;
f[1][1]=1;for(int i =2; i <= n; i ++){for(int j =1; j <= i; j ++){
f[i][j]=(f[i -1][j -1]+ f[i - j][j])% mod;}}int res =0;for(int i =1; i <= n; i ++) res =(res + f[n][i])% mod;
cout << res;return0;}