Language: C++

#include <bits/stdc++.h>
#include <iostream>
// #include <unordered_map>
#define vi vector <ull>
#define ii pair<ull,ull>
#define vii vector<ii>

#define seti set<ull>
#define mii map<ull,ull>
#define um unordered_map
#define ll long long
#define ull  long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100100
#define _ << " " <<

using namespace std;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

string s,t;

map<pair<int,int>, string, hash_pair> ans;


string rec(int sp, int tp){
	if(ans[{sp,tp}] == "") return ans[{sp,tp}];
	if(sp >= s.size() || tp >= t.size())
		return ans[{sp,tp}] = "";
	
	if(s[sp] == t[tp]) return ans[{sp,tp}] = s[sp]+rec(sp+1, tp+1);
	string s1 = rec(sp+1, tp), s2 =  rec(sp, tp+1);
	if(s1.size() > s2.size()) return ans[{sp,tp}] = s1;
	return ans[{sp,tp}] =  s2;
}


void solve(){


	cin >> s >> t;

	cout << rec(0,0);


}


int main(){
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ull q;
	// cin >> q;
	q = 1;
	for(ull i = 0; i < q; i++){
		// cout << "Case #" << i+1 << ":" << endl;

		solve();
		// cout << endl;
	}

	

	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = std::__cxx11::basic_string<char>; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; mapped_type = std::__cxx11::basic_string<char>; key_type = std::pair<int, int>]':
a.cc:38:16:   required from here
   38 |         if(ans[{sp,tp}] == "") return ans[{sp,tp}];
      |                       ^
/usr/include/c++/14/bits/stl_map.h:531:39: error: no match for call to '(std::map<std::pair<int, int>, std::__cxx11::basic_string<char>, hash_pair>::key_compare {aka hash_pair}) (std::map<std::pair<int, int>, std::__cxx11::basic_string<char>, hash_pair>::key_type&, const std::pair<int, int>&)'
  531 |         if (__i == end() || key_comp()(__k, (*__i).first))
      |                             ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:24:12: note: candidate: 'template<class T1, class T2> size_t hash_pair::operator()(const std::pair<_T1, _T2>&) const'
   24 |     size_t operator()(const pair<T1, T2>& p) const
      |            ^~~~~~~~
a.cc:24:12: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(_Link_type, _Base_ptr, const _Key&) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >, std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >, hash_pair, std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > > >::iterator; _Link_type = std::_Rb_tree_node<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >*; _Base_ptr = std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:1267:30:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >, std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >, hash_pair, std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > > >::iterator; key_type = std::pair<int, int>]'
 1267 |       { return _M_lower_bound(_M_begin(), _M_end(), __k); }
      |                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1308:32:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::pair<int, int>; _Tp = std::__cxx11::basic_string<char>; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >, std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >, hash_pair, std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > > >::iterator; key_type = std::pair<int, int>]'
 1308 |       { return _M_t.lower_bound(__x); }
      |                ~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_map.h:529:28:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = std::__cxx11::basic_string<char>; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; mapped_type = std::__cxx11::basic_string<char>; key_type = std::pair<int, int>]'
  529 |         iterator __i = lower_bound(__k);
      |                        ~~~~~~~~~~~^~~~~
a.cc:38:16:   required from here
   38 |         if(ans[{sp,tp}] == "") return ans[{sp,tp}];
      |                       ^
/usr/include/c++/14/bits/stl_tree.h:1948:36: error: no match for call to '(hash_pair) (const std::pair<int, int>&, const std::pair<int, int>&)'
 1948 |         if (!_M_impl._M_key_compare(_S_key(__x), __k))
      |              ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:24:12: note: candidate: 'template<class T1, class T2> size_t hash_pair::operator()(const std::pair<_T1, _T2>&) const'
   24 |     size_t operator()(const pair<T1, T2>& p) const
      |            ^~~~~~~~
a.cc:24:12: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; _Const_Link_type = const std::_Rb_tree_node<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >*]':
/usr/include/c++/14/bits/stl_tree.h:1948:36:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(_Link_type, _Base_ptr, const _Key&) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >, std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >, hash_pair, std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > > >::iterator; _Link_type = std::_Rb_tree_node<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >*; _Base_ptr = std::_Rb_tree_node_base*]'
 1948 |         if (!_M_impl._M_key_compare(_S_key(__x), __k))
      |                                     ~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1267:30:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >, std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >, hash_pair, std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > > >::iterator; key_type = std::pair<int, int>]'
 1267 |       { return _M_lower_bound(_M_begin(), _M_end(), __k); }
      |                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1308:32:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::pair<int, int>; _Tp = std::__cxx11::basic_string<char>; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> >, std::_Select1st<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >, hash_pair, std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > > >::iterator; key_type = std::pair<int, int>]'
 1308 |       { return _M_t.lower_bound(__x); }
      |                ~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_map.h:529:28:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = std::__cxx11::basic_string<char>; _Compare = hash_pair; _Alloc = std::allocator<std::pair<const std::pair<int, int>, std::__cxx11::basic_string<char> > >; mapped_type = std::__cxx11::basic_string<char>; key_type = std::pair<int, int>]'
  529 |         iterator __i = lower_bound(__k);
      |                        ~~~~~~~~~~~^~~~~
a.cc:38:16:   required from here
   38 |         if(ans[{sp,tp}] == "") return ans[{sp,tp}];
      |                       ^
/usr/include/c++/14/bits/stl_tree.h:760:23: error: static assertion failed: comparison object must be invocable with two arguments of key type
  760 |         static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{},
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~