func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int MAXN = 10;   const int LCM = 840;   const int n = 8;   long long w;   long long cnt[MAXN], f[MAXN][MAXN * LCM];   int main() {     scanf( %lld , &w);     for (int i = 1; i <= n; i++) scanf( %lld , &cnt[i]);     memset(f, -1, sizeof(f));     f[0][0] = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j <= LCM * 8; j++) {         if (f[i][j] != -1) {           long long limit = min(cnt[i + 1], (long long)LCM / (i + 1));           for (int k = 0; k <= limit; k++)             f[i + 1][j + (i + 1) * k] =                 max(f[i + 1][j + (i + 1) * k],                     f[i][j] + (cnt[i + 1] - k) / (LCM / (i + 1)));         }       }     }     long long ans = 0;     for (int i = 0; i <= min((long long)LCM * 8, w); i++) {       if (f[8][i] != -1) ans = max(ans, min(f[8][i], (w - i) / LCM) * LCM + i);     }     printf( %lld n , ans);     return 0;   }   