#include #include using namespace std; //Longest Common Prefix(s,s.substr(i)) O(|s|) #include vectorZalgo(const string&s) { vectorret(s.size()); ret[0]=s.size(); int i=1,j=0; while(i>s; dp[0]=1; long ans=0; for(int i=0;i*2<=s.size();i++) { ans+=dp[i]; if(i*2==s.size())break; string t=s.substr(i,s.size()-i*2); vectoraz=Zalgo(t); for(int j=1;2*j<=az.size();j++) { if(az[az.size()-j]>=j)(dp[i+j]+=dp[i])%=mod; } } cout<