/*    ∫ ∫ ∫    ノヽ   (_  )  (_    ) (______ )  ヽ(´・ω・)ノ     |  /    UU */ #include typedef long long int64; using namespace std; using P = pair; typedef vector vi; const int MOD = (int)1e9 + 7; const int64 INF = 1LL << 62; const int inf = 1<<30; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b ostream& operator<<(ostream& os, vector &V){ int N = V.size(); REP(i,N){ os << V[i]; if (i!=N-1) os << " "; } os << "\n"; return os; } template ostream& operator<<(ostream& os, pair const&P){ os << "("; os << P.first; os << " "; os << P.second; os << ")"; return os; } template ostream& operator<<(ostream& os, set &S){ auto it=S.begin(); while(it!=S.end()){ os << *it; os << " "; it++; } os << "\n"; return os; } template ostream& operator<<(ostream& os, deque &q){ for(auto it=q.begin();it> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)}; //fixed< struct RollingHash{ const uint64_t mod = (1ull << 61) - 1; const uint64_t base = random_base; const uint64_t MASK31 = (1ull << 31) - 1; const uint64_t MASK30 = (1ull << 30) - 1; vector pows, hash; RollingHash(const T& S) : pows(S.size()+1,1), hash(S.size()+1,0) { size_t N = S.size(); for(int i=0; i>31 , ad = a & MASK31; //上位30bitと下位31bit uint64_t bu = b>>31 , bd = b & MASK31; //上位30bitと下位31bit uint64_t mid = ad*bu + au*bd, midu = mid>>30, midd = mid&MASK30; return au*bu*2 + midu + (midd<<31) + ad*bd; } uint64_t CalcMod(uint64_t val){ val = (val&mod) + (val>>61); if (val >= mod) val-=mod; return val; } uint64_t get_hash(int l, int r){ if (r> S; int N = S.size(); RollingHash RH(S); auto a = RH.get_hash(1,11); map cnt; REP(l,N){ for(int r=l+1; r<=min(N,l+11); r++){ cnt[RH.get_hash(l,r)]++; } } int M; cin >> M; int ans=0; REP(i,M){ string s; cin >> s; RollingHash rh(s); ans += cnt[rh.get_hash(0,s.size())]; } cout << ans << endl; }