Language: C++

//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
int p1=37,p2=53;
const int m1=mod;
const int m2=mod+2;
ll good[1000023];
map <pair<int,int>,bool> mark;
map <pair<int,int>,bool> any;
void compute_hash(string s)
{
    ll mult=1;
    ll ans1=0;
    ll ans2=0;
    for(int i=s.length()-1;i>=0;i--)
    {
        ans1*=p1;
        ans1+=s[i];
        ans1%=m1;
        ans2*=p2;
        ans2+=s[i];
        ans2%=m2;
        any[mp(ans1,ans2)]=1;
    }
    mark[mp(ans1,ans2)]=1;
}
void solve()
{
    ll n;
    cin>>n;
    vs v;
    vector <pair<ll,ll>> temp;
    any[mp(0,0)]=1;
    rep(i,n)
    {
        string s;
        cin>>s;
        v.pb(s);
        compute_hash(s);
        good[s.length()]=1;
    }
    ll ans=0;
    for(auto s:v)
    {
        ll len=s.length();
        int cnt[28]={0};
        for(int i=0;i<len;i++)
        {
            cnt[s[i]-'a']++;
        }
        ll suff1=0,suff2=0;
        for(int req=1;req<len;req++)
        {
            if(any[mp(suff1,suff2)]==0)
                break;
            if(req==1)
            {
                for(char ch='a';ch<='z';ch++)
                {
                    if(cnt[ch-'a']>0)
                    {
                        ll now=ch;
                        ans+=mark[mp(now,now)];
                    }
                }
                continue;
            }
            cnt[s[len-req+1]-'a']--;
            suff1*=p1;
            suff1+=(s[len-req+1]*p1);
            suff1%=m1;
            suff2*=p2;
            suff2+=(s[len-req+1]*p2);
            suff2%=m2;
            if(good[req]==0)
                continue;
            for(char ch='a';ch<='z';ch++)
            {
                if(cnt[ch-'a']>0)
                {
                    ll now1=(suff1+ch)%m1;
                    ll now2=(suff2+ch)%m2;
                    ans+=mark[mp(now1,now2)];
                }
            }
        }
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Compiler output:
a.cc: In function 'void compute_hash(std::string)':
a.cc:52:9: error: reference to 'any' is ambiguous
   52 |         any[mp(ans1,ans2)]=1;
      |         ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:77,
                 from a.cc:2:
/usr/include/c++/14/any:81:9: note: candidates are: 'class std::any'
   81 |   class any
      |         ^~~
a.cc:38:26: note:                 'std::map<std::pair<int, int>, bool> any'
   38 | map <pair<int,int>,bool> any;
      |                          ^~~
a.cc: In function 'void solve()':
a.cc:62:5: error: reference to 'any' is ambiguous
   62 |     any[mp(0,0)]=1;
      |     ^~~
/usr/include/c++/14/any:81:9: note: candidates are: 'class std::any'
   81 |   class any
      |         ^~~
a.cc:38:26: note:                 'std::map<std::pair<int, int>, bool> any'
   38 | map <pair<int,int>,bool> any;
      |                          ^~~
a.cc:83:16: error: reference to 'any' is ambiguous
   83 |             if(any[mp(suff1,suff2)]==0)
      |                ^~~
/usr/include/c++/14/any:81:9: note: candidates are: 'class std::any'
   81 |   class any
      |         ^~~
a.cc:38:26: note:                 'std::map<std::pair<int, int>, bool> any'
   38 | map <pair<int,int>,bool> any;
      |                          ^~~