Language: C++

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); \
                cin.tie(0); \
                cout.tie(0)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(_v)             _v.begin(), _v.end()
#define sz(_v)              (int) _v.size()
#define first(_obj)         (*_obj.begin())
#define last(_obj)          (*prev(_obj.end()))
#define FIND(_obj, _val)    (_obj.find(_val) != _obj.end())
#define RESET(_a, _v)       fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define REP(_i, _n)         for (int _i = 0; _i < (int) _n; _i++)
#define FOR(_i, _a, _b)     for (int _i = (int) _a; _i <= (int) _b; _i++)
#define FORD(_i, _a, _b)    for (int _i = (int) _a; _i >= (int) _b; _i--)
#define FORIT(_it, _obj)    for (auto _it = _obj.begin(); _it != _obj.end(); _it++)

// DEBUG UTIL
template<typename TF>
void debug(ostream &out, TF const &f) {
    out << f << std::endl;
}
 
template<typename TF, typename ... TR>
void debug(ostream &out, TF const &f, TR const& ... rest) {
    out << f << " ";
    debug( out, rest... );
}
 
#define DEBUG(...) debug(cerr, "[", #__VA_ARGS__, "]:", __VA_ARGS__)

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vi = vector<int>;
using vii = vector<pii>;
using vll = vector<ll>;
using vs = vector<string>;

const int DR[] = {-1, 0, 1, 0, -1, 1, 1, -1}; // ccw
const int DC[] = {0, -1, 0, 1, -1, -1, 1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = 1073741823;
const ll INFLL = 4e18;
const int MAX = 3e3;

int N, M, dp[MAX+5][MAX+5], tr[MAX+5][MAX+5];
pii tr[MAX+5][MAX+5];
string s, t;

void read() {
    cin >> s >> t;

    N = sz(s);
    M = sz(t);

    s = " " + s;
    t = " " + t;
}

void solve() {
    FOR(i, 1, N)
        FOR(j, 1, M) {
            if (s[i] == t[j]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
                tr[i][j] = {i - 1, j - 1};
            }
            else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                    tr[i][j] = {i - 1, j};
                }
                else {
                    dp[i][j] = dp[i][j - 1];
                    tr[i][j] = {i, j - 1};
                }
            }
        }

    int ans = dp[N][M];
    pii pos = {N, M};
    vector<char> vec;

    while (ans > 0) {
        pii bef = tr[i][j];

        if (bef.fi < pos.fi && bef.se < pos.se) {
            vec.pb(s[pos.fi]);
            ans--;
        }

        pos = bef;
    }

    reverse(all(vec));
    for (char c : vec) cout << c;
    cout << "\n";
}

int main() {
    FAST_IO;
    int TC = 1;
    FOR(tc, 1, TC) {
        read();
        solve();
    }
}

Compiler output:
a.cc:58:5: error: conflicting declaration 'pii tr [3005][3005]'
   58 | pii tr[MAX+5][MAX+5];
      |     ^~
a.cc:57:29: note: previous declaration as 'int tr [3005][3005]'
   57 | int N, M, dp[MAX+5][MAX+5], tr[MAX+5][MAX+5];
      |                             ^~
a.cc: In function 'void solve()':
a.cc:76:41: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment
   76 |                 tr[i][j] = {i - 1, j - 1};
      |                                         ^
a.cc:81:41: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment
   81 |                     tr[i][j] = {i - 1, j};
      |                                         ^
a.cc:85:41: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment
   85 |                     tr[i][j] = {i, j - 1};
      |                                         ^
a.cc:95:22: error: 'i' was not declared in this scope; did you mean 'vi'?
   95 |         pii bef = tr[i][j];
      |                      ^
      |                      vi
a.cc:95:25: error: 'j' was not declared in this scope
   95 |         pii bef = tr[i][j];
      |                         ^