Language: C++

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
const int N = 3e3 + 5;
int dp[N][N];

struct hash_pair {
};

class FLCS {
public:
    string s, t;
    int n, m;
    unordered_map<pair<int, int>, pair<int, int>, hash_pair> par;

    int rec(int i, int j) {
        if (i < 0 or j < 0) return 0;
        if (dp[i][j] != -1) return dp[i][j];
        int res;
        if (s[i] == t[j]) {
            par[{i, j}] = {i - 1, j - 1};
            res = 1 + rec(i - 1, j - 1);
        } else {
            int p1 = rec(i - 1, j), p2 = rec(i, j - 1);
            if (p1 >= p2) {
                res = p1;
                par[{i, j}] = {i - 1, j};
            } else {
                res = p2;
                par[{i, j}] = {i, j - 1};
            }
        }
        return dp[i][j] = res;
    }

    void solve(std::istream &in, std::ostream &out) {
        in >> s >> t;
        n = s.length(), m = t.length();
        memset(dp, -1, sizeof dp);
        int len = rec(n - 1, m - 1);
        int i = n - 1, j = m - 1;
        string res = "";
        while (par.find({i, j}) != par.end()) {
            if (s[i] == t[j]) res += s[i];
            auto p = par[{i, j}];
            i = p.first, j = p.second;
        }
        reverse(res.begin(), res.end());
        out << res;
    }
};


int32_t main() {
    FLCS solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Compiler output:
In file included from /usr/include/c++/14/bits/hashtable.h:35,
                 from /usr/include/c++/14/bits/unordered_map.h:33,
                 from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:7:
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::__hash_code std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_M_hash_code(const _Key&) const [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, std::pair<long long int, long long int> >; _ExtractKey = std::__detail::_Select1st; _Hash = hash_pair; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true; __hash_code = long unsigned int]':
/usr/include/c++/14/bits/hashtable_policy.h:865:45:   required from 'std::__detail::_Map_base<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>::mapped_type& std::__detail::_Map_base<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>::operator[](key_type&&) [with _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = hash_pair; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>; mapped_type = std::pair<long long int, long long int>; key_type = std::pair<long long int, long long int>]'
  865 |       __hash_code __code = __h->_M_hash_code(__k);
      |                            ~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/unordered_map.h:992:20:   required from 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&&) [with _Key = std::pair<long long int, long long int>; _Tp = std::pair<long long int, long long int>; _Hash = hash_pair; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; mapped_type = std::pair<long long int, long long int>; key_type = std::pair<long long int, long long int>]'
  992 |       { return _M_h[std::move(__k)]; }
      |                ~~~~^
a.cc:34:23:   required from here
   34 |             par[{i, j}] = {i - 1, j - 1};
      |                       ^
/usr/include/c++/14/bits/hashtable_policy.h:1335:23: error: static assertion failed: hash function must be invocable with an argument of key type
 1335 |         static_assert(__is_invocable<const _Hash&, const _Key&>{},
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1335:23: note: 'std::__is_invocable<const hash_pair&, const std::pair<long long int, long long int>&>()' evaluates to false
/usr/include/c++/14/bits/hashtable_policy.h:1337:25: error: no match for call to '(const hash_pair) (const std::pair<long long int, long long int>&)'
 1337 |         return _M_hash()(__k);
      |                ~~~~~~~~~^~~~~