Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;


int main(){
    string s1, s2;
    cin >> s1 >> s2;
    
    const ll base = 9973;
    vector<ll> base_pow(26);
    base_pow[0] = 1;
    for(int i=1;i<26;i++){
        base_pow[i] = (base_pow[i - 1] * base) % MOD;
    }

    // unordered_map<ll, vector<P>> viewed;
    unordered_map<int, int16_t> viewed;
    for(int i=0;i<s1.size();i++){
        ll hash = 0;
        for(int j=i;j<s1.size();j++){
            hash += base_pow[int(s1[j] - 'a')];
            hash %= MOD;
            // viewed[hash].emplace_back(j - i + 1, i);
            viewed[int(hash)] = j - i + 1;
        }
    }

    // vector<tuple<int, int, int>> ans_cand;
    int ans = 0;
    for(int i=0;i<s2.size();i++){
        ll hash = 0;
        for(int j=i;j<s2.size();j++){
            hash += base_pow[int(s2[j] - 'a')];
            hash %= MOD;
            auto it = viewed.find(hash);
            if(it != viewed.end()){
                ans = max(ans, it->second);
                // for(P& p : it->second){
                //     ans_cand.emplace_back(p.first, p.second, i);
                // }
            }
        }
    }

    // int ans = 0;
    // sort(ans_cand.begin(), ans_cand.end());
    // for(int j=0;j<ans_cand.size();j++){
    //     tuple<int, int, int>& cand = ans_cand[int(ans_cand.size()) - j - 1];
    //     vector<int> cnt(26, 0);
    //     int K = get<0>(cand);
    //     int b1 = get<1>(cand), b2 = get<2>(cand);
    //     for(int k=0;k<K;k++){
    //         cnt[int(s1[b1 + k] - 'a')]++;
    //         cnt[int(s2[b2 + k] - 'a')]--;
    //     }
    //     bool ok = true;
    //     for(int i=0;i<26;i++){
    //         if(cnt[i] != 0){
    //             ok = false;
    //             break;
    //         }
    //     }
    //     if(ok){
    //         ans = K;
    //         break;
    //     }
    // }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:26: error: no matching function for call to 'max(int&, short int&)'
   40 |                 ans = max(ans, it->second);
      |                       ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
   40 |                 ans = max(ans, it->second);
      |                       ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |                 ans = max(ans, it->second);
      |                       ~~~^~~~~~~~~~~~~~~~~