Language: C++

#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 1100000;

int n, ch[N][26], tot = 1, size[N], sum[N][26], isEnd[N];
ll ans;
char s[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

void dfs(int now) {
	size[now] = isEnd[now];
	for (R int i = 0, v; i <= 25; ++i) {
		if (!(v = ch[now][i])) continue;
		dfs(v);
		size[now] += size[v];
		for (R int j = 0; j <= 25; ++j) {
			if (i == j) continue;
			sum[now][j] += sum[v][j];
		}
		sum[now][i] += size[v];
	}
	for (R int i = 0, v; i <= 25; ++i) {
		if (!(v = ch[now][i]) || !isEnd[v]) continue;
		ans += sum[now][i] - 1;
	}
	return;
}

int main() {
	read(n);
	for (R int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		int m = strlen(s + 1), now = 1;
		reverse(s + 1, s + 1 + m);
		for (R int j = 1; j <= m; ++j) {
			if (!ch[now][s[j] - 'a'])
				ch[now][s[j] - 'a'] = ++tot;
			now = ch[now][s[j] - 'a'];
		}
		isEnd[now] = 1;
	}
	dfs(1);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:38:9: error: reference to 'size' is ambiguous
   38 |         size[now] = isEnd[now];
      |         ^~~~
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: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:10:28: note:                 'int size [1100000]'
   10 | int n, ch[N][26], tot = 1, size[N], sum[N][26], isEnd[N];
      |                            ^~~~
a.cc:39:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |         for (R int i = 0, v; i <= 25; ++i) {
      |                    ^
a.cc:39:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |         for (R int i = 0, v; i <= 25; ++i) {
      |                           ^
a.cc:42:17: error: reference to 'size' is ambiguous
   42 |                 size[now] += size[v];
      |                 ^~~~
/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:10:28: note:                 'int size [1100000]'
   10 | int n, ch[N][26], tot = 1, size[N], sum[N][26], isEnd[N];
      |                            ^~~~
a.cc:42:30: error: reference to 'size' is ambiguous
   42 |                 size[now] += size[v];
      |                              ^~~~
/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:10:28: note:                 'int size [1100000]'
   10 | int n, ch[N][26], tot = 1, size[N], sum[N][26], isEnd[N];
      |                            ^~~~
a.cc:43:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |                 for (R int j = 0; j <= 25; ++j) {
      |                            ^
a.cc:47:32: error: reference to 'size' is ambiguous
   47 |                 sum[now][i] += size[v];
      |                                ^~~~
/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:10:28: note:                 'int size [1100000]'
   10 | int n, ch[N][26], tot = 1, size[N], sum[N][26], isEnd[N];
      |                            ^~~~
a.cc:49:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   49 |         for (R int i = 0, v; i <= 25; ++i) {
      |                    ^
a.cc:49:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   49 |         for (R int i = 0, v; i <= 25; ++i) {
      |                           ^
a.cc: In function 'int main()':
a.cc:58:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   58 |         for (R int i = 1; i <= n; ++i) {
      |                    ^
a.cc:62:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   62 |                 for (R int j = 1; j <= m; ++j) {
      |                            ^