#include using namespace std; typedef unsigned int uint; typedef long long int ll; typedef unsigned long long int ull; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout< ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<>=1,k++)s=(s<<1)|(u&1);for(;0>=1)cout<<(s&1);}} #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast(t).count()) template ostream& operator <<(ostream &o,const pair p){o<<"("< struct TrieTree{ int value; map trie; TrieTree(int v):value(v){} TrieTree():value(0){} template int& operator()(IBEGIN begin,IBACK back){ if (begin==back){ return trie[*begin].value; } return trie[*begin](begin+1,back); } }; int main(){ int i,j,k,l; TrieTree trie; string str; cin >> str; const char* strbyte = str.c_str(); for (i=0;i> n; for (i=0;i> str; sum+=trie(str.c_str(),str.c_str()+str.size()-1); } cout << sum << endl; return 0; }