Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007
 
// // for using in pairs
#define F first
#define S second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2> p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

template<typename T>
void swap(T &a, T &b)
{
	T t = a;
	a = b;
	b = t;
}

// Utility functions.
void swap(int &a, int &b)
{
	int t = a;
	a = b;
	b = t;
}

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}

int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;	
}

//////////////////// START CODE HERE ///////////////////////////


void solve(int tc)
{
	string a, b;
	cin >> a >> b;
	int n = a.size();
	int m = b.size();

	pair<int, tuple<int, int, char>> dp[n + 1][m + 1];

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			if (!i || !j)
			{
				dp[i][j] = {0, make_tuple(-1, -1, '$')};
				continue;
			}
			if (a[i - 1] == b[j - 1])
				dp[i][j] = {dp[i - 1][j - 1].F + 1, make_tuple(i - 1, j - 1, a[i - 1])};
			else if (dp[i - 1][j].F > dp[i][j - 1].F)
				dp[i][j] = {dp[i - 1][j].F, make_tuple(i - 1, j, '$')}};
			else
				dp[i][j] = {dp[i][j - 1].F, make_tuple(i, j - 1, '$')};
		}
	}
	auto [i, j, c] = dp[n][m].S;
	stack<char> ans;
	while (i >= 0 && j >= 0)
	{
		if (c != '$')
			ans.push(c);
		auto [i2, j2, c2] = dp[i][j].S;
		i = i2;
		j = j2;
		c = c2;
	}
	while (ans.size())
	{
		cout << ans.top();
		ans.pop();
	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Compiler output:
a.cc: In function 'void solve(long long int)':
a.cc:115:87: error: expected ';' before '}' token
  115 |                                 dp[i][j] = {dp[i - 1][j].F, make_tuple(i - 1, j, '$')}};
      |                                                                                       ^
      |                                                                                       ;
a.cc:116:25: error: 'else' without a previous 'if'
  116 |                         else
      |                         ^~~~
a.cc:117:39: error: 'j' was not declared in this scope
  117 |                                 dp[i][j] = {dp[i][j - 1].F, make_tuple(i, j - 1, '$')};
      |                                       ^
a.cc: At global scope:
a.cc:120:26: error: 'dp' was not declared in this scope; did you mean 'dup'?
  120 |         auto [i, j, c] = dp[n][m].S;
      |                          ^~
      |                          dup
a.cc:120:29: error: 'n' was not declared in this scope; did you mean 'yn'?
  120 |         auto [i, j, c] = dp[n][m].S;
      |                             ^
      |                             yn
a.cc:120:32: error: 'm' was not declared in this scope; did you mean 'tm'?
  120 |         auto [i, j, c] = dp[n][m].S;
      |                                ^
      |                                tm
a.cc:122:9: error: expected unqualified-id before 'while'
  122 |         while (i >= 0 && j >= 0)
      |         ^~~~~
a.cc:131:9: error: expected unqualified-id before 'while'
  131 |         while (ans.size())
      |         ^~~~~
a.cc:136:1: error: expected declaration before '}' token
  136 | }
      | ^