for (size_t i=0, b=0, e=0; i<S.size(); ++i) for (b=(i && S[i] == S[i-1] ? e : 0), e=ret.size(); b<e; ++b) ...