Language: C++

#include<bits/stdc++.h>
using namspace std;

const int maxS = 3e3 + 7;
pair<int, pair< pair<int, int>, pair<int, int> > > dp[maxS][maxS];

int main() {
  string s, t;
  cin >> s >> t;
  
  int n = (int)s.length(), m = (int)t.length();
  // size of subsequece, index of last character used
 
  int maxLen = 0;
  for(int i = 0;i <= n;i ++) {
  	for(int j = 0;j <= m;j ++) {
    	if(i == 0 || j == 0) {
        	dp[i][j] = {0, {{0, 0}, {0, 0}}};
        } else {
            if(s[i-1] == t[j-1]) {
            	dp[i][j] = {dp[i-1][j-1].first + 1, {{i-1, j-1}, {i, j}}};
              	continue;
            }
        	maxLen = max(dp[i-1][j].first, max(dp[i][j-1].first, dp[i-1][j-1].first));
          	if(maxLen == dp[i-1][j].first) {
            	dp[i][j] = dp[i-1][j];
            } else if(maxLen == dp[i][j-1].first) {
            	dp[i][j] = dp[i][j-1];
            } else {
            	dp[i][j] = dp[i-1][j-1];
            }
        }
    }	
  }
  
  int i_itr = n, j_itr = m;
  
  string ans = "";
  pair<int, int> temp;
  while(i_itr > 0 && j_itr > 0) {
    if(dp[i_itr][j_itr].second.second.first == 0) {
    	break;
    }
  	ans += s[dp[i_itr][j_itr].second.second.first];
    temp = dp[i_itr][j_itr].second.first;
    i_itr = temp.first;
    j_itr = temp.second;
  }
  
  reverse(ans.begin(), ans.end());
  cout << ans;  
}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namspace'
    2 | using namspace std;
      |       ^~~~~~~~
a.cc:5:1: error: 'pair' does not name a type
    5 | pair<int, pair< pair<int, int>, pair<int, int> > > dp[maxS][maxS];
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'string' was not declared in this scope
    8 |   string s, t;
      |   ^~~~~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:9:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    9 |   cin >> s >> t;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:10: error: 's' was not declared in this scope
    9 |   cin >> s >> t;
      |          ^
a.cc:9:15: error: 't' was not declared in this scope; did you mean 'tm'?
    9 |   cin >> s >> t;
      |               ^
      |               tm
a.cc:16:28: error: 'm' was not declared in this scope
   16 |         for(int j = 0;j <= m;j ++) {
      |                            ^
a.cc:18:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   18 |                 dp[i][j] = {0, {{0, 0}, {0, 0}}};
      |                 ^~
      |                 dup
a.cc:21:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |                 dp[i][j] = {dp[i-1][j-1].first + 1, {{i-1, j-1}, {i, j}}};
      |                 ^~
      |                 dup
a.cc:24:30: error: 'dp' was not declared in this scope; did you mean 'dup'?
   24 |                 maxLen = max(dp[i-1][j].first, max(dp[i][j-1].first, dp[i-1][j-1].first));
      |                              ^~
      |                              dup
a.cc:24:48: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |                 maxLen = max(dp[i-1][j].first, max(dp[i][j-1].first, dp[i-1][j-1].first));
      |                                                ^~~
      |                                                std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:24:26: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |                 maxLen = max(dp[i-1][j].first, max(dp[i][j-1].first, dp[i-1][j-1].first));
      |                          ^~~
      |                          std::max
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:36:26: error: 'm' was not declared in this scope
   36 |   int i_itr = n, j_itr = m;
      |                          ^
a.cc:38:9: error: expected ';' before 'ans'
   38 |   string ans = "";
      |         ^~~~
      |         ;
a.cc:39:3: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   39 |   pair<int, int> temp;
      |   ^~~~
      |   std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:39:8: error: expected primary-expression before 'int'
   39 |   pair<int, int> temp;
      |        ^~~
a.cc:41:8: error: 'dp' was not declared in this scope; did you mean 'dup'?
   41 |     if(dp[i_itr][j_itr].second.second.first == 0) {
      |        ^~
      |        dup
a.cc:44:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |         ans += s[dp[i_itr][j_itr].second.second.first];
      |         ^~~
      |         abs
a.cc:44:18: error: 'dp' was not declared in this scope; did you mean 'dup'?
   44 |         ans += s[dp[i_itr][j_itr].second.second.first];
      |                  ^~
      |                  dup
a.cc:45:5: error: 'temp' was not declared in this scope; did you mean 'tm'?
   45 |     temp = dp[i_itr][j_itr].second.first;
      |     ^~~~
      |     tm
a.cc:50:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |   reverse(ans.begin(), ans.end());
      |           ^~~
      |           abs
a.cc:50:3: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
   50 |   reverse(ans.begin(), ans.end());
      |   ^~~~~~~
      |   std::reverse
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: 'std::reverse' declared here
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
a.cc:51:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   51 |   cout << ans;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~