func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1000100;   const int INF = 1e9 + 10;   int c, n;   int a[maxn], b[maxn];   int cnt[maxn];   bool check(int anow, int &now) {     int bnow = b[now] - anow;     if (bnow <= 0) {       if (now <= n && anow + 1 > a[now]) now++;       return 0;     }     int tmp = bnow;     for (int i = now - 1; i >= 1; i--) {       tmp -= min(tmp / a[i], cnt[i]) * a[i];       if (tmp == 0) {         if (now <= n && anow + 1 > a[now]) now++;         return 0;       }     }     return 1;   }   int main() {     while (cin >> c >> n) {       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       sort(a + 1, a + n + 1);       memset(cnt, 0, sizeof(cnt));       int m = 1;       cnt[1] = 1;       for (int i = 2; i <= n; i++) {         if (a[i] != a[i - 1])           a[++m] = a[i], cnt[m] = 1;         else           cnt[m]++;       }       n = m;       int tmp = c;       b[n + 1] = tmp;       for (int i = n; i >= 1; i--) {         tmp -= min(tmp / a[i], cnt[i]) * a[i];         b[i] = tmp;       }       if (tmp) {         puts( 0 );         continue;       }       int res = 0;       int now = 1;       for (int i = 1; i <= c; i++) {         if (check(i, now)) {           res = i;           break;         }       }       if (res)         printf( %d n , res);       else         puts( Greed is good );     }     return 0;   }   