func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char c = getchar();     while (c !=  -  && c < 48) c = getchar();     if (c ==  - ) f = -1, c = getchar();     while (c > 47) x = x * 10 + (c ^ 48), c = getchar();     return f * x;   }   const int maxn = 3e3 + 7;   const int inf = 0x3f3f3f3f;   const int mod = 1e9 + 7;   int t[maxn];   inline void Max(long long &x, long long y) {     if (x < y) x = y;   }   int main() {     int n = read(), k = read();     vector<vector<long long>> a(n + 1, vector<long long>(k + 1, 0));     for (int i = 1; i <= n; ++i) {       int t = read();       ::t[i] = t;       for (int j = 1; j <= t; ++j) {         int d = read();         if (j <= k) a[i][j] = a[i][j - 1] + d;       }     }     long long ans = 0;     function<void(int, int, vector<long long> &)> solve =         [&](int l, int r, vector<long long> &dp) {           if (l == r) {             for (int i = 0, up = min(k, t[l]); i <= up; ++i) {               Max(ans, dp[k - i] + a[l][i]);             }             return;           }           int m = (l + r) / 2;           vector<long long> dp1(dp);           for (int i = m + 1; i <= r; ++i) {             for (int j = k; j >= t[i]; --j) {               Max(dp1[j], dp1[j - t[i]] + a[i][t[i]]);             }           }           solve(l, m, dp1);           for (int i = l; i <= m; ++i) {             for (int j = k; j >= t[i]; --j) {               Max(dp[j], dp[j - t[i]] + a[i][t[i]]);             }           }           solve(m + 1, r, dp);         };     vector<long long> dp(k + 1, -1e18);     dp[0] = 0;     solve(1, n, dp);     cout << ans << endl;   }   