Language: C++

#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class RollingHash{
public:
  typedef long long ll;
  ll B, mod;  //B: ハッシュ基数
  Int n;
  string s;
  vector<ll> hash;
  vector<ll> k;

  RollingHash():n(-1){};
  RollingHash(string s,ll B = 1777771,ll mod = 1e9 + 7):
    B(B),mod(mod),n(s.size()),s(s),hash(n+1),k(n+1)
  {
    for(Int i=0;i<n;i++) hash[i+1] = (hash[i] * B % mod + s[i]) % mod;
    k[0] = 1;
    for(Int i=1;i<=n;i++) k[i] = (k[i-1] * B) % mod;
  }

  ll get(Int l,Int r){ //[l, r)
    assert(0<=l && r<=n && l<=r);
    return (mod + hash[r] - hash[l] * k[r-l] % mod) % mod;
  }
  
  //hash[a]とB.hash[b]からみて何文字一致してるか。
  Int count(Int a, RollingHash &B, Int b){
    Int L = 0, R = min( n - a, B.n - b ) + 1;
    while( L + 1 < R ){
      Int M = ( L + R ) / 2;
      get( a, a + M ) != B.get( b, b + M ) ? R = M : L = M;
    }
    return L;
  }
};
typedef unsigned long long ull;
RollingHash R;
Int n;
string str;

vector<vector<Int> > Div(5000);
bool can(Int l,Int r){//[l,r)
  Int len = r - l;
  if(len == 1) return 1;
  
  auto check=[&](Int i){
    ull a = R.get(l+i, r);
    ull b = R.get(l, r - i);
    return a != b;
  };
  
  for(Int i=1:Div){
    if(len%i) continue;
    if(i!=1 && check(len/i) == false) return 0;
    if(check(i) == false) return 0;
  }
  return 1;
}

Int dfs(Int idx){
    static Int used[10000]={}, mem[10000] = {};
    if(idx == n) return 0;
    if(used[idx]++) return mem[idx];
    
    Int res = INF;
    for(Int nidx = idx+1; nidx <= n; nidx++){
      if(!can(idx, nidx)) continue;
      Min(res, 1+dfs(nidx));
    }
    return mem[idx] = res;
}

Int count(Int idx){
  static Int used[10000]={}, mem[10000];
  if(idx == n) return 1;
  if(used[idx]++) return mem[idx];

  Int res = 0;
  Int mn = dfs(idx);
  for(Int nidx = idx+1; nidx <= n; nidx++){
    if(!can(idx, nidx)) continue;
    if(mn != 1 + dfs(nidx)) continue;
    res = (res + count(nidx)) % mod;
  }
  return res;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  for(Int i=1;i<=5000;i++)
    for(Int j=1;j<i;j++) if(i%j == 0) Div[i].push_back(j);

  cin>>str;
  n = str.size();
  R = RollingHash(str);
  assert(n <= 4000);
  Int len = dfs(0);
  Int cnt = count(0);
  cout<<len<<endl;
  cout<<cnt<<endl;
  return 0;
}


Compiler output:
a.cc:27:39: warning: use of 'auto' in template argument only available with '-fconcepts-ts'
   27 | ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
      |                                       ^~~~
a.cc:28:39: warning: use of 'auto' in template argument only available with '-fconcepts-ts'
   28 | istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
      |                                       ^~~~
a.cc:29:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   29 | void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
      |            ^~~~
a.cc: In function 'bool can(Int, Int)':
a.cc:80:12: error: initializer in range-based 'for' loop
   80 |   for(Int i=1:Div){
      |            ^