Language: C++

#include <bits/stdc++.h>
#define ll long long
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
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<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
int dp[3001][3001];

int f(string s1,string s2,int i,int j,int n,int m){
  if(i==n || j==m){return 0;}
  if(dp[i][j]!=-1){return dp[i][j];} 
  int ans;
  if(s1[i]==s2[j]){ ans = 1 + f(s1,s2,i+1,j+1,n,m);}
  else{
      ans = max(f(s1,s2,i+1,j,n,m),f(s1,s2,i,j+1,n,m));
  }
  dp[i][j] = ans;
  return ans;
}

void print_f(string s1,string s2,int i,int j,int n,int m,string &t){
    if(!(i==n || j==m)){
        if(dp[i+1][j+1]+1 == dp[i][j]){ t.pb(s1[i]); print_f(s1,s2,i+1,j+1,n,m,t); }
        else if(dp[i+1][j]==dp[i][j]){ print_f(s1,s2,i+1,j,n,m,t);}
        else if(dp[i][j+1]==dp[i][j]){print_f(s1,s2,i,j+1,n,m,t);
    }
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t; 
    // cin>>t;
    t=1;
    while(t--){
     memset(dp,-1,sizeof(dp));
     string s1,s2; cin>>s1>>s2;
     int n,m;
     n = s1.length(); m = s2.length();
     int q = f(s1,s2,0,0,n,m);
     string t;
     print_f(s1,s2,0,0,n,m,t);
     cout<<t;
    }
}


Compiler output:
a.cc: In function 'void print_f(std::string, std::string, int, int, int, int, std::string&)':
a.cc:72:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   72 | int main() {
      |         ^~
a.cc:72:9: note: remove parentheses to default-initialize a variable
   72 | int main() {
      |         ^~
      |         --
a.cc:72:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:72:12: error: a function-definition is not allowed here before '{' token
   72 | int main() {
      |            ^
a.cc:88:2: error: expected '}' at end of input
   88 | }
      |  ^
a.cc:64:68: note: to match this '{'
   64 | void print_f(string s1,string s2,int i,int j,int n,int m,string &t){
      |                                                                    ^