malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;      typedef long long ll;         int main(){    ios_base::sync_with_stdio(0);    cin.tie(0);    cout.tie(0);        int t;    cin >> t;    while (t--){     string s;     cin >> s;     stack<char> a, b;     int ans = 0;     for (auto c: s){      if (c ==  (  || c ==  ) ){       if (c ==  ( )        a.push(c);       else {        if (!a.empty()){         ans++;         a.pop();        }       }      }      if (c ==  [  || c ==  ] ){       if (c ==  [ )        b.push(c);       else {        if (!b.empty()){         ans++;         b.pop();        }       }      }     }      cout << ans <<   n ;    }   }
#include <bits/stdc++.h>   using namespace std;   int q[123456];   vector<int> sq;   int main() {     int n, k;     int a, b;     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &a, &b);       sq.push_back(min(2 * a, b) - min(a, b));       q[i] = min(a, b);       1;     }     sort(sq.begin(), sq.end(), greater<int>());     long long sum = 0;     int flag = 1;     for (int i = 0; i < k; i++) sum += sq[i], sq[i] < 0 ? flag = 0 : 0;     for (int i = 1; i <= n; i++) sum += q[i];     printf( %lld , flag * sum);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s[n];     int a[n];     for (int x = 0; x < n; x++) {       cin >> s[x];       a[x] = s[x].length();     }     for (int x = 0; x < n; x++) {       for (int y = 0; y < n - 1; y++) {         if (a[y] > a[y + 1]) {           int t = a[y];           a[y] = a[y + 1];           a[y + 1] = t;           string temp = s[y];           s[y] = s[y + 1];           s[y + 1] = temp;         }       }     }     int f = 0;     for (int x = 0; x < n; x++) {       int i;       for (int y = x + 1; y < n; y++) {         i = s[y].find(s[x], 0);         if (i == -1) {           f = 1;           break;         }       }       if (f == 1) {         break;       }     }     if (f == 1) {       cout <<  NO ;     } else {       cout <<  YES  << endl;       for (int x = 0; x < n; x++) {         cout << s[x] << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i, j, k, m, c1 = 0, count2 = 0, m3 = 0;     cin >> n;     long long int a[n];     map<long long int, long long int> m1;     for (i = 0; i < n; i++) {       cin >> a[i];       m1[i] = -1;     }     cin >> m;     vector<long long int> v;     for (i = 0; i < m; i++) {       long long int p, q, r;       cin >> p;       if (p == 1) {         cin >> q >> r;         a[q - 1] = r;         m1[q - 1] = i;         v.push_back(0);       } else {         cin >> q;         m3 = max(m3, q);         v.push_back(q);       }     }     long long int max1[v.size() - 1];     memset(max1, 0, sizeof(max1));     long long int m_1 = 0;     for (i = (m - 1); i >= 0; i--) {       if (v[i] > m_1) {         max1[i] = max(m_1, v[i]);         m_1 = max(m_1, v[i]);       } else {         max1[i] = m_1;         m_1 = max(m_1, v[i]);       }     }     for (i = 0; i < n; i++) {       if (m1[i] >= m) {         cout << a[i] <<    ;       } else if (m1[i] != -1) {         cout << max(a[i], max1[m1[i]]) <<    ;       } else {         cout << max(a[i], m3) <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double PI = 3.14159265358979323846;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long get(long long x, long long n) {     long long l, r;     if (x > n) return 0;     long long acc = 0;     if (x % 2 == 0) {       l = x;       r = x + 1;     } else {       l = 2 * x;       r = 2 * x + 1;       acc += 1;     }     while (r <= n) {       acc += r - l + 1;       l *= 2;       r = 2 * r + 1;     }     if (l <= n) acc += (n - l + 1);     return acc;   }   int dfs(int x, vector<bool> &chk, vector<int> &val, int step,           vector<map<int, int> > &e) {     chk[x] = true;     int maxval = -1e9 - 1;     for (auto &k : e[x]) {       if (chk[k.first]) continue;       maxval = max(maxval, dfs(k.first, chk, val, step + 1, e));     }     if (step == 0)       maxval = max(maxval, val[x]);     else if (step == 1)       maxval = max(maxval, val[x] + 1);     else       maxval = max(maxval, val[x] + 2);     return maxval;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<int> a(n + 1);     int mmm = -1e9 - 1;     for (int i = 0; i < n; i++) {       cin >> a[i + 1];       mmm = max(mmm, a[i + 1]);     }     set<int> s;     for (int i = 1; i <= n; i++) {       if (a[i] == mmm) s.insert(i);     }     vector<map<int, int> > v(n + 1);     for (int i = 0; i < n - 1; i++) {       int x, y;       cin >> x >> y;       v[x][y] = 1;       v[y][x] = 1;     }     vector<bool> chk(n + 1);     if (s.size() == 1) {       int ans = dfs(*(s.begin()), chk, a, 0, v);       cout << ans << endl;     } else {       bool isok = false;       for (int i = 1; i <= n; i++) {         if (v[i].size() + 1 < s.size()) continue;         bool isok2 = true;         for (auto k : s) {           if (v[i][k] != 1 && k != i) {             isok2 = false;             break;           }         }         if (isok2) {           isok = true;           break;         }       }       if (isok) {         cout << mmm + 1 << endl;       } else {         cout << mmm + 2 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1005;   template <typename T>   void read(T &x) {     x = 0;     int f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c -  0 ;     x *= f;   }   int n;   double g[N][N];   double E[N], prod[N];   bool vis[N];   int main() {     read(n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         int x;         read(x);         g[i][j] = 1. * x / 100;       }     if (n == 1) return puts( 0 );     vis[n] = true;     for (int i = 1; i < n; i++) {       E[i] = 1;       prod[i] = 1 - g[i][n];     }     for (int i = 1; i <= n; i++) {       double low = 1e18;       int pos = 0;       for (int j = 1; j <= n; j++)         if (!vis[j] && E[j] / (1 - prod[j]) < low)           low = E[j] / (1 - prod[j]), pos = j;       if (pos == 1) return printf( %.10lf n , E[1] / (1 - prod[1])), 0;       vis[pos] = true;       for (int j = 1; j <= n; j++)         E[j] += E[pos] / (1 - prod[pos]) * g[j][pos] * prod[j],             prod[j] *= (1 - g[j][pos]);     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   void solve();   int main()   {    ios_base::sync_with_stdio(false); cin.tie(NULL);      #ifndef ONLINE_JUDGE    freopen( input1.txt ,  r , stdin);    freopen( error1.txt ,  w , stderr);    freopen( output1.txt ,  w , stdout);   #endif       int t ; cin >> t;    while (t--)    {     solve();     cout <<   n ;    }       cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs  << endl;    return 0;   }   void solve()   {    long long n, x ;    cin >> n >> x ;    long long a[n], b[n], s = 0, s1 = 0, j = 0;    for (long long i = 0; i < n; i++)     cin >> a[i];    for (long long i = 0; i < n; i++)     s += a[i];    for (long long i = 0; i < n; i++)     b[i] = a[i];    while (1) {     if (j >= n)      j = 0;     if (b[j] % x != 0)      break;     s += a[j];     b[j] /= x;     j++;    }    cout << s;   }
#include <bits/stdc++.h>   using namespace std;   char s[2005];   int n, c[2005][2005], ans = 0x3f3f3f3f, was, ot[2005];   bool chk() {     static int ar[2005];     int sum = 0;     for (int i = (1), LIM = (n); i <= LIM; i++) ar[i] = ot[i], sum += ot[i];     sort(ar + 1, ar + 1 + n);     int sm = 0;     for (int i = (1), LIM = (n - 1); i <= LIM; i++) {       sm += ar[i];       if (sm == i * (i - 1) / 2) return 0;     }     return 1;   }   void dfs(int u, int s) {     if (u == n + 1) {       if (chk()) {         if (ans > s) ans = s, was = 0;         if (ans == s) was++;       }       return;     }     dfs(u + 1, s);     for (int i = (1), LIM = (n); i <= LIM; i++)       if (c[u][i])         ot[u]--, ot[i]++;       else         ot[u]++, ot[i]--;     for (int i = (1), LIM = (n); i <= LIM; i++) swap(c[i][u], c[u][i]);     dfs(u + 1, s + 1);     for (int i = (1), LIM = (n); i <= LIM; i++)       if (c[u][i])         ot[u]--, ot[i]++;       else         ot[u]++, ot[i]--;     for (int i = (1), LIM = (n); i <= LIM; i++) swap(c[i][u], c[u][i]);   }   int main() {     scanf( %d , &n);     for (int i = (1), LIM = (n); i <= LIM; i++) {       scanf( %s , s + 1);       for (int j = (1), LIM = (n); j <= LIM; j++)         c[i][j] = (s[j] ==  1 ), ot[i] += c[i][j];     }     if (n <= 6) {       dfs(1, 0);       if (ans == 0x3f3f3f3f)         puts( -1 );       else {         for (int i = (1), LIM = (ans); i <= LIM; i++)           was = 1ll * was * i % 998244353;         printf( %d %d n , ans, was);       }       return 0;     } else {       if (chk()) {         puts( 0 1 );         return 0;       }       for (int u = (1), LIM = (n); u <= LIM; u++) {         for (int i = (1), LIM = (n); i <= LIM; i++)           if (c[u][i])             ot[u]--, ot[i]++;           else             ot[u]++, ot[i]--;         for (int i = (1), LIM = (n); i <= LIM; i++) swap(c[i][u], c[u][i]);         if (chk()) was++;         for (int i = (1), LIM = (n); i <= LIM; i++)           if (c[u][i])             ot[u]--, ot[i]++;           else             ot[u]++, ot[i]--;         for (int i = (1), LIM = (n); i <= LIM; i++) swap(c[i][u], c[u][i]);       }       printf( %d %d n , 1, was);     }   }
#include <bits/stdc++.h>   using namespace std;   long long inv[500005];   void getinv() {     inv[0] = inv[1] = 1;     for (int i = 2; i < 500005; i++)       inv[i] =           ((-1000000007 / i * inv[1000000007 % i]) % 1000000007 + 1000000007) %           1000000007;   }   long long slove(int n, int m) {     long long ans = 1;     for (int i = 1; i <= m; i++)       ans = ((ans * inv[i]) % 1000000007 * (n - i + 1)) % 1000000007;     return ans;   }   long long a[500005], n, m, c[500005];   int main() {     scanf( %I64d%I64d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %I64d , &a[i]);     }     getinv();     for (int i = 0; i <= n; i++) {       c[i] = slove(i + m - 1, i);     }     for (int i = 0; i < n; i++) {       long long ans = 0;       for (int j = 0; j <= i; j++) {         ans = (ans + a[j] * c[i - j]) % 1000000007;       }       printf( %I64d  , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 10, M = 20, mo = 1e9 + 7;   vector<vector<long long> > f, sum;   vector<long long> g;   long long a[maxn], c[maxn];   long long n, l, k, K, B, ans, i, j, z, x, y, N, r;   int main() {     scanf( %lld%lld%lld , &n, &l, &k);     g.push_back(0);     for (i = 0; i < n; i++) {       scanf( %lld , &a[i]);       c[i] = a[i];       g.push_back(0);     }     if (l <= n) {       printf( %lld n , l);       return 0;     }     sort(c, c + n);     K = min(l / n, k);     N = (l / n) % mo;     r = l % n;     f.push_back(g);     sum.push_back(g);     for (i = 1; i <= k; i++) {       f.push_back(g);       sum.push_back(g);     }     for (i = 0; i < n; i++) {       f[1][i] = 1;       sum[0][i] = 1;     }     sum[1][0] = 1;     for (i = 1; i < n; i++) sum[1][i] = (f[1][i] + sum[1][i - 1]) % mo;     for (i = 2; i <= K; i++) {       for (j = 0; j < n; j++) {         z = upper_bound(c, c + n, c[j]) - c - 1;         f[i][j] = sum[i - 1][z];       }       sum[i][0] = f[i][0];       for (j = 1; j < n; j++) sum[i][j] = (f[i][j] + sum[i][j - 1]) % mo;     }     for (i = 1; i <= K; i++) {       ans = (ans + (N - i + 1) * sum[i][n - 1]) % mo;       for (j = 0; j < r; j++) {         z = upper_bound(c, c + n, a[j]) - c - 1;         ans = (ans + sum[i - 1][z]) % mo;       }     }     if (r && K + 1 <= k) {       i = K + 1;       for (j = 0; j < r; j++) {         z = upper_bound(c, c + n, a[j]) - c - 1;         ans = (ans + sum[i - 1][z]) % mo;       }     }     ans = (ans + mo) % mo;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, flag, c, k, x, z, n, m, a[300007];   int main() {     cin >> n;     long long lst0 = 0, lst1 = 1;     for (i = 0; i < n; i++) {       cin >> a[i];       if (a[i] == 0)         lst0 = i + 1;       else         lst1 = i + 1;     }     cout << min(lst0, lst1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   template <class T>   inline bool chmin(T& a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T>   inline bool chmax(T& a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   const int MOD = 1000000007;   const int INF = 1000000001;   const ll LINF = 1000000001000000001LL;   void solve();   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout << fixed << setprecision(numeric_limits<double>::max_digits10);     solve();     return 0;   }   void solve() {     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       vector<int> a(n);       for (int i = (0); i < ((n)); i++) cin >> a[i];       vector<int> b(n, false);       int p;       for (int i = (0); i < ((m)); i++) {         cin >> p;         p--;         b[p] = true;       }       bool ok = true;       for (int i = (0); i < ((n)); i++) {         for (int j = (i); j < (n); j++) {           if (!b[j]) {             for (int k = (j + 1); k < (n); k++) {               if (a[i] > a[k]) {                 ok = false;                 break;               }             }             if (!ok) break;           }         }         if (!ok) break;         for (int j = (i - 1); j < (0); j++) {           if (!b[j]) {             for (int k = (0); k < ((j + 1)); k++) {               if (a[i] < a[k]) {                 ok = false;                 break;               }             }             if (!ok) break;           }         }         if (!ok) break;       }       cout << (ok ?  YES  :  NO ) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 400000 + 5;   vector<int> G[maxn];   int n;   int down[maxn], up[maxn], sz[maxn], par[maxn];   void dfs(int u, int fa) {     int len = G[u].size();     par[u] = fa;     sz[u] = 1;     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       dfs(v, u);       sz[u] += sz[v];     }   }   void dfs_down(int u, int fa) {     int len = G[u].size();     down[u] = (sz[u] <= n / 2) ? sz[u] : 0;     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       dfs_down(v, u);       down[u] = max(down[u], down[v]);     }   }   void dfs_up(int u, int val = 0, int fa = -1) {     if (val <= n / 2) {       up[u] = max(val, up[u]);     }     if (n - sz[u] <= n / 2) {       up[u] = max(n - sz[u], up[u]);     }     int len = G[u].size();     int m0 = 0, m1 = 0;     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       if (down[v] >= m0) {         m1 = m0;         m0 = down[v];       } else if (down[v] >= m1) {         m1 = down[v];       }     }     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       dfs_up(v, max(up[u], down[v] == m0 ? m1 : m0), u);     }   }   int ans[maxn];   int main() {     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }     dfs(1, -1);     dfs_down(1, -1);     dfs_up(1, 0, -1);     for (int u = 1; u <= n; u++) {       ans[u] = 1;       int len = G[u].size();       for (int j = 0; j < len; j++) {         int v = G[u][j];         if (v == par[u]) {           if (n - sz[u] - up[u] > n / 2) ans[u] = 0;         } else {           if (sz[v] - down[v] > n / 2) ans[u] = 0;         }       }     }     printf(  n );     for (int i = 1; i <= n; i++) {       printf( %d%c , ans[i], i == n ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int mod, h1, a1, x1, y1, h2, a2, x2, y2, c1, c2, i,         ans = 0, temp, j, m1, m2, h11, h12;     cin >> mod;     cin >> h1 >> a1;     cin >> x1 >> y1;     cin >> h2 >> a2;     cin >> x2 >> y2;     temp = h2;     ans = 0;     h11 = h1;     h12 = h2;     for (i = 1; i <= mod + 10; i++) {       ans++;       h11 = (x1 * h11 + y1) % mod;       h12 = (x2 * h12 + y2) % mod;       if (h11 == a1 && h12 == a2) {         cout << ans << endl;         return 0;       }     }     ans = 0;     for (i = 1; i <= mod + 10 && h1 != a1; i++) {       ans++;       h1 = (x1 * h1 + y1) % mod;       h2 = (x2 * h2 + y2) % mod;     }     if (h1 != a1) {       cout << -1 << endl;       return 0;     }     if (h1 == a1 && h2 == a2) {       cout << ans << endl;       return 0;     }     c1 = 0;     for (i = 1; i <= mod + 10 && temp != a2; i++) {       c1++;       temp = (x2 * temp + y2) % mod;     }     if (temp != a2) {       cout << -1 << endl;       return 0;     }     long long int p, q, r, s;     p = ans;     q = c1;     a1 = h1;     h1 = (x1 * h1 + y1) % mod;     ans = 1;     for (i = 1; i <= mod + 10 && h1 != a1; i++) {       ans++;       h1 = (x1 * h1 + y1) % mod;     }     if (h1 != a1) {       cout << -1 << endl;       return 0;     }     r = ans;     ans = 1;     a2 = temp;     h2 = temp;     h2 = (x2 * h2 + y2) % mod;     for (i = 1; i <= mod + 10 && h2 != a2; i++) {       ans++;       h2 = (x2 * h2 + y2) % mod;     }     if (h2 != a2) {       cout << -1 << endl;       return 0;     }     s = ans;     if (p + r == q + s) {       cout << p + r << endl;       return 0;     }     for (i = 1; i <= mod + 10; i++) {       j = (p - q + r * i) / s;       if (p + i * r == q + j * s) {         cout << p + i * r << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10, C = 30;   int nex[N][C], p, n, par[N], dfa[N][C];   string s, t;   vector<pair<int, char> > adj_matrix[N];   long long ans;   void dfs(int v, int p, int state) {     if (state == (int)t.size()) ans++;     for (auto pa : adj_matrix[v]) {       int u = pa.first;       char c = pa.second;       if (u == p) continue;       dfs(u, v, nex[state][c -  a ]);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     int cur = n + 1;     for (int i = 1; i < n; i++) {       cin >> p;       p--;       cin >> s;       int j = 0, lp = p;       while (j + 1 < s.size()) {         adj_matrix[lp].push_back({cur, s[j]});         lp = cur;         j++;         cur++;       }       adj_matrix[lp].push_back({i, s[j]});     }     cin >> t;     nex[0][t[0] -  a ] = 1;     int l = 0;     for (int i = 1; i <= (int)t.size(); i++) {       for (int j = 0; j < 28; j++) {         if (i < (int)t.size()) {           if (j == (t[i] -  a ))             nex[i][j] = i + 1;           else             nex[i][j] = nex[l][j];         } else           nex[i][j] = nex[l][j];       }       if (i < (int)t.size()) l = nex[l][t[i] -  a ];     }     dfs(0, 0, 0);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int bef[100050];   int main() {     string s, s1;     cin >> s;     int len = s.size();     int last_a = -1;     int now = 0;     for (int i = 0; i < len; i++) {       if (s[i] !=  a ) {         s1 += s[i];         bef[now] = i;         now++;       } else {         last_a = i;       }     }     if (now % 2 == 1)       cout <<  :(  << endl;     else {       for (int i = 0; i < now / 2; i++) {         if (s1[i] != s1[i + now / 2]) {           cout <<  :(  << endl;           return 0;         }       }       if (last_a == -1 || bef[now / 2] > last_a || now == 0) {         for (int i = 0; i < (now != 0 ? bef[now / 2] : len); i++) {           cout << s[i];         }         cout << endl;       } else {         cout <<  :(  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 3e5 + 10, oo = 1e9, M = 64;   long long const OO = 1e18;   int mod = oo + 7;   double const eps = 1e-4, PI = acos(-1);   int n, k, in[N];   int cc = 0, m = 0, cnt = 0;   vector<int> dv[N];   bool brute(int i, int h) {     if (h > k) return 0;     if (i == m + 1) return h == k;     if (h == k) return 1;     int y = 0;     for (auto v : dv[i])       if (in[v]) y++;     in[i] = 1;     cnt++;     if (brute(i + 1, h + y)) return 1;     cnt--;     in[i] = 0;     if (brute(i + 1, h)) return 1;     return 0;   }   int main() {     scanf( %d%d , &n, &k);     int all = 0;     for (int i = 1; i <= n; i++)       for (int j = i + i; j <= n; j += i) all++, dv[j].push_back(i);     if (all < k) {       puts( No );       return 0;     }     for (int i = 1; i <= n && cc < k; i++) {       cc += dv[i].size();       in[i] = 1;       cnt++;       m++;     }     if (m < 10000) {       cnt = 0;       memset(in, 0, sizeof in);       brute(1, 0);     } else       for (int i = m; cc != k; i--)         if ((int)dv[i].size() == 1) cc--, in[i] = 0, cnt--;     puts( Yes );     printf( %d n , cnt);     for (int i = 1; i <= m; i++)       if (in[i]) printf( %d  , i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   long long a[20][10][10], b[20][10][10], c[20];   int read_int() {     int a = 0;     int b = 1, c = getchar();     if (c ==  - )       b = -1;     else       a = c - 48;     while ((c = getchar()) !=     && c !=   n ) a = a * 10 + c - 48;     a *= b;     return a;   }   int findmax(long long n) {     long long temp = n;     int m = 0;     while (temp > 0) {       if (temp % 10 > m) m = temp % 10;       temp = temp / 10;     }     return m;   }   int main() {     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     long long n;     cin >> n;     long long m, total;     for (int l = 0; l < 19; l++)       for (int x = 9; x >= 0; x--)         for (int y = 0; y <= 9; y++) {           total = 0;           if (!l)             if (!x)               if (y) {                 b[l][x][y] = 1;                 a[l][x][y] = 0;               } else {                 b[l][x][y] = 0;                 a[l][x][y] = 0;               }             else if (x > y) {               a[l][x][y] = y + 10 - x;               b[l][x][y] = 1;             } else {               a[l][x][y] = 10 - x;               b[l][x][y] = 2;             }           else {             total = 0;             m = y;             for (int j = 9; j >= 0; j--) {               total += b[l - 1][x > j ? x : j][m];               m = a[l - 1][x > j ? x : j][m];             }             a[l][x][y] = m;             b[l][x][y] = total;           }         }     m = n % 10;     long long K = n / 10, res = 0;     int len = 0;     while (1) {       while (K % 10 != 9 && K) {         res += b[len][findmax(K)][m];         m = a[len][findmax(K)][m];         K--;       }       if (!K) {         res += b[len][0][m];         break;       }       K /= 10;       len++;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, ar[10];     cin >> a >> b >> c;     ar[0] = a + b + c;     ar[1] = a * b * c;     ar[2] = a + b * c;     ar[3] = a * b + c;     ar[4] = (a + b) * c;     ar[5] = a * (b + c);     sort(ar, ar + 6);     cout << ar[6 - 1];   }