Language: C++

/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    int x = 0, flag = 1;
    char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	long long x = 0, flag = 1;
	char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

const int maxn = 2e5 + 100;
const int maxS = 1e6 + 30;
int n;
string s[maxn], rev[maxn];
int go[maxS][30], cnt;
int size[maxS][30], fa[maxn];
int tag[maxn], pd[maxn], js[maxn];
inline void insert(string s, int i) {
	int pp = 0;
	for (int i = 1; i <= 26; i++) pd[i] = -1;
	for (int i = s.size(); i >= 0; i--) {
		if (pd[s[i] - 'a' + 1] == -1) {
			pd[s[i] - 'a' + 1] = i;
		}
	}
	vector<int> pos;
	for (int i = 0; i < s.size(); i++) {
		if (go[pp][s[i] - 'a' + 1] == 0) go[pp][s[i] - 'a' + 1] = ++cnt, fa[cnt] = pp;
		pp = go[pp][s[i] - 'a' + 1];
		if (pd[s[i] - 'a' + 1] == i) size[pp][s[i] - 'a' + 1] ++;
	}
	js[i] = pp;
}
void dfs(int x) {
	for (int i = 1; i <= 26; i++) {
		if (go[x][i] == 0) continue;
		dfs(go[x][i]);
		for (int p = 1; p <= 26; p++) {
			size[x][p] += size[go[x][i]][p];
		}
	}
}
int main() {
	n = ri(); 
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		rev[i] = s[i];
		reverse(rev[i].begin(), rev[i].end());
		insert(rev[i], i);
	}
	dfs(0);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int tag = js[i];
		int faa = fa[tag];
		ans += size[faa][s[i][0] - 'a' + 1] - 1;
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'void insert(std::string, int)':
a.cc:63:46: error: reference to 'size' is ambiguous
   63 |                 if (pd[s[i] - 'a' + 1] == i) size[pp][s[i] - 'a' + 1] ++;
      |                                              ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:6:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:49:5: note:                 'int size [1000030][30]'
   49 | int size[maxS][30], fa[maxn];
      |     ^~~~
a.cc: In function 'void dfs(int)':
a.cc:72:25: error: reference to 'size' is ambiguous
   72 |                         size[x][p] += size[go[x][i]][p];
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:49:5: note:                 'int size [1000030][30]'
   49 | int size[maxS][30], fa[maxn];
      |     ^~~~
a.cc:72:39: error: reference to 'size' is ambiguous
   72 |                         size[x][p] += size[go[x][i]][p];
      |                                       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:49:5: note:                 'int size [1000030][30]'
   49 | int size[maxS][30], fa[maxn];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:89:24: error: reference to 'size' is ambiguous
   89 |                 ans += size[faa][s[i][0] - 'a' + 1] - 1;
      |                        ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:49:5: note:                 'int size [1000030][30]'
   49 | int size[maxS][30], fa[maxn];
      |     ^~~~