func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   const int N = 1005;   int dp[N][2][N], n, T;   struct node {     int c, t;     node(int c = 0, int t = 0) : c(c), t(t) {}     void read() { scanf( %d%d , &t, &c); }     bool operator<(const node &b) const { return t > b.t; }   } a[N];   int main() {     int cur, nxt, ans, val;     scanf( %d%d , &n, &T);     ans = 0;     for (int i = 1; i <= n; i++) {       a[i].read();       ans = max(ans, a[i].c);     }     sort(a + 1, a + n + 1);     cur = 0;     nxt = 1;     memset(dp, 0xc0, sizeof(dp));     dp[1][0][0] = 0;     for (int j = 0; j <= T; j++) {       for (int i = 0; i <= n; i++)         for (int t = 0; t <= n; t++) dp[i][nxt][t] = -INF - 5;       for (int i = n; i >= 0; i--)         for (int t = 0; t <= n; t++) {           val = dp[i][cur][t];           if (val < -INF) continue;           ans = max(ans, val);           if (t < n) dp[i][cur][t + 1] = max(dp[i][cur][t + 1], val);           if (j < T)             dp[min(n, i * 2)][nxt][t] = max(dp[min(n, i * 2)][nxt][t], val);           if (i > 0 && a[t].t + j <= T) {             dp[i - 1][cur][t + 1] = max(dp[i - 1][cur][t + 1], val + a[t].c);             ans = max(ans, val + a[t].c);           }         }       swap(cur, nxt);     }     printf( %d n , ans);     return 0;   }   