#include<bits/stdc++.h> #define uint unsigned int usingnamespace std; constexprint N = 1e5 + 5;
uint n; int f[2][N]; int g[2][N]; // = max(f[ <= i][ <= j]) int rk[N]; // 开头为 x 的东西的排名
structFenwick { int C[N]; voidclear(){ fill(C + 1, C + n + 1, -1e9); } voidadd(int x, int k){ for (; x <= n; x += x & -x) C[x] = max(C[x], k); } intqmax(int x)const{ int r = -1e9; for (; x; x -= x & -x) r = max(r, C[x]); return r; } } F;
voidsolve(){ string a; cin >> a; n = a.length();
vector<int> lst; for (int i = n - 1; i >= 0; --i) lst.emplace_back(i);
memset(f, 0, sizeof f); memset(g, 0, sizeof g);
constint B = ceil(sqrt(n * 2)) + 5;
for (int j = 0; j < B; ++j) { constint len = j; vector<int> pos[10]; for (int i : lst) pos[a[i] - '0'].emplace_back(i); lst.clear(); int tot = 0; for (int k = 0; k < 10; ++k) for (constint x : pos[k]) { if (x) lst.emplace_back(x - 1); rk[x] = ++tot; }
F.clear(); for (int i = j; i < n; ++i) { f[j & 1][i] = 1;