criyle/codenet-compile-errors huggingface dataset:
Language: C++

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin>>s>>t;
  int dp[s.size()][t.size()];
  rep(i,s.size()){
    rep(j,t.size()){
      dp[i][j]=0;
    }
  }
  string res;
  do{
    if (dp[n][m] == dp[n-1][m])
        n -= 1;
    elif(dp[n][m] == dp[n][m-1])
        m -= 1
    else{
        n -= 1;
        m -= 1;
        res = s[n] + res;
    }
  }while(n!=0&&m!=0)
  cout<<res<<endl;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:31:12: error: 'n' was not declared in this scope
   31 |     if (dp[n][m] == dp[n-1][m])
      |            ^
a.cc:31:15: error: 'm' was not declared in this scope
   31 |     if (dp[n][m] == dp[n-1][m])
      |               ^
a.cc:33:13: error: 'n' was not declared in this scope
   33 |     elif(dp[n][m] == dp[n][m-1])
      |             ^
a.cc:33:16: error: 'm' was not declared in this scope
   33 |     elif(dp[n][m] == dp[n][m-1])
      |                ^
a.cc:33:5: error: 'elif' was not declared in this scope
   33 |     elif(dp[n][m] == dp[n][m-1])
      |     ^~~~
a.cc:40:10: error: 'n' was not declared in this scope
   40 |   }while(n!=0&&m!=0)
      |          ^
a.cc:40:16: error: 'm' was not declared in this scope
   40 |   }while(n!=0&&m!=0)
      |                ^
a.cc:40:21: error: expected ';' before 'cout'
   40 |   }while(n!=0&&m!=0)
      |                     ^
      |                     ;
   41 |   cout<<res<<endl;
      |   ~~~~
Language: C++

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin>>s>>t;
  int dp[i][j];
  rep(i,s.size()){
    rep(j,t.size()){
      dp[i][j]=0;
    }
  }
  string res;
  rep(i,s.size()-1){
    rep(j,t.size()-1){
      if(s[i]==t[j]){
        dp[i+1][j+1]=dp[i][j]+1;
        res[dp[i+1][j+1]-1]=s[i]; 
      }
      else
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
    }
  }
  cout<<res<<endl;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:23:10: error: 'i' was not declared in this scope
   23 |   int dp[i][j];
      |          ^
a.cc:23:13: error: 'j' was not declared in this scope
   23 |   int dp[i][j];
      |             ^
a.cc:26:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   26 |       dp[i][j]=0;
      |       ^~
      |       dup
a.cc:33:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   33 |         dp[i+1][j+1]=dp[i][j]+1;
      |         ^~
      |         dup
a.cc:37:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   37 |         dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      |         ^~
      |         dup
Language: C++

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin>>s>>t;
  int dp[i][j];
  rep(i,s.size()){
    rep(j,t.size()){
      dp[i][j]=0;
    }
  }
  string res;
  rep(i,s.size()-1){
    rep(j,t.size()-1){
      if(s[i]==t[j]){
        dp[i+1][j+1]=dp[i][j]+1;
        res[dp[i+1][j+1]-1]=s[i]; 
      }
      else
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
    }
  }
  cout<<res<<endl;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:23:10: error: 'i' was not declared in this scope
   23 |   int dp[i][j];
      |          ^
a.cc:23:13: error: 'j' was not declared in this scope
   23 |   int dp[i][j];
      |             ^
a.cc:26:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   26 |       dp[i][j]=0;
      |       ^~
      |       dup
a.cc:33:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   33 |         dp[i+1][j+1]=dp[i][j]+1;
      |         ^~
      |         dup
a.cc:37:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   37 |         dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      |         ^~
      |         dup
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
   string a,b;
   cin>>a>>b;
   int n=a.length();
   int m=b.length();
   
   int lcs[n+1][m+1];
   memset(dp,0,sizeof(dp));
   
   for(int i=1;i<=n;i++)
   {
      for(int j=1;j<=m;j++)
      {  
          if(a[i-1]==b[j-1])
          { 
             lcs[i][j]=1+lcs[i-1][j-1];
          } 
          else
          {
             lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
          }
           
      }
   }
   
  cout<<lcs[n][m]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |    memset(dp,0,sizeof(dp));
      |           ^~
      |           dup
Language: C++

#include<bits/stdc+++.h>
using namespace std;
int main()
{
   string a,b;
   cin>>a>>b;
   int n=a.length();
   int m=b.length();
   
   int lcs[n+1][m+1];
   memset(dp,0,sizeof(dp));
   
   for(int i=1;i<=n;i++)
   {
      for(int j=1;j<=m;j++)
      {  
          if(a[i-1]==b[j-1])
          { 
             lcs[i][j]=1+lcs[i-1][j-1];
          } 
          else
          {
             lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
          }
           
      }
   }
   
  cout<<lcs[n][m]<<endl;
}

Compiler output:
a.cc:1:9: fatal error: bits/stdc+++.h: No such file or directory
    1 | #include<bits/stdc+++.h>
      |         ^~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.Scanner;

public class Solution{

	public static  int maxi(int a,int b){
        if(a >= b) return a;
        else return b;
    }


    public static String LCS(String s,String t){
        int n = s.length();
        int m = t.length();

        int[][] arr = new int[n+1][];

        for(int i = 0;i <= n;i++){
            arr[i] = new int[m+1];
        }

        for(int i = 0;i <= n;i++){
            arr[i][0] = 0;
        }

        for(int i = 0;i <= m;i++){
            arr[0][i] = 0;
        }

        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++){
                if(s.charAt(i) == t.charAt(j)){
                    arr[i+1][j+1] = arr[i][j]+1;
                }

                else{
                    arr[i+1][j+1] = maxi(arr[i+1][j], arr[i][j+1]);
                }
            }
        }


        String res = "";

        int r = n, c = m;
        
        while(res.length() < arr[n][m]){

        	if(arr[r][c] == arr[r-1][c]){
        		r = r-1;
        	}

        	else if(arr[r][c] == arr[r][c-1]){
        		c = c-1;
        	}

        	else{
        		res = res + s.charAt(r-1);
        		r = r-1;
        		c = c-1;
        	
        	}
        	
        }

        return res;
    }

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);

		String s,t;

		s = in.next();
		t = in.next();

		String ans = LCS(s,t);

		StringBuilder ans1 = new StringBuilder();

		System.out.println(ans);

		ans1.append(ans);

		ans1 = ans1.reverse(); 

		System.out.println(ans1);
	}
}

Compiler output:
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution{
       ^
1 error
Language: C++

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

#define endl "\n"

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll DIM = 100007;
const ll INF = 1000000007;
ll n, m, k;
ll a, b, c;
ll v[DIM+7], w[DIM+7];
string used[3007][3007];
string s, s1;

string f(ll a,ll b){
    if(a==-1||b==-1)return "";
    if(used[a][b][0]!="-")return used[a][b];
    string ans="",ans1="",ans2="";
if(s[a]==s1[b])ans=f(a-1,b-1)+s[a];else {ans1=f(a-1,b);ans2=f(a,b-1);}
if(ans1.size()<ans2.size())swap(ans1,ans2);
if(ans.size()<ans1.size())swap(ans1,ans);
used[a][b]=ans;
k++;
return ans;
}

int main()
{
    for(ll i=0;i<3007;i++)
    for(ll j=0;j<3007;j++)
        used[i][j]="-";
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> s >> s1;
    cout<<f(s.size()-1,s1.size()-1);
    //cout<<endl<<k;
}


Compiler output:
a.cc: In function 'std::string f(ll, ll)':
a.cc:20:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   20 |     if(used[a][b][0]!="-")return used[a][b];
Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define pii pair<int,int>
#define mp make_pair
using namespace std;
vector<string> v[n]
string memo(string s,string t,string ans){
	if(s.size()==0 || t.size()==0) return ans;
	if(s[0] == t[0]) {
		ans.push_back(s[0]);
		return memo(s.substr(1),t.substr(1),ans);
	}
	else{
		string s1 = memo(s.substr(1),t,ans);
		stirng s2 = memo(s,t.substr(1),ans);
		if(s1.size()>s2.size()) return s1;
		else return s2;
	}
}
int main(){
	std::ios::sync_with_stdio(0);
	cin.tie(0);
	string s,t;
	cin >> s >> t;
	//v.reserve(3005)
	cout << memo(s,t,"") << "\n";
}

Compiler output:
a.cc:8:18: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 | vector<string> v[n]
      |                  ^
      |                  yn
a.cc:9:1: error: expected initializer before 'string'
    9 | string memo(string s,string t,string ans){
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:28:17: error: 'memo' was not declared in this scope
   28 |         cout << memo(s,t,"") << "\n";
      |                 ^~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    string S, T;
    cin >> S >> T;
    vector<vector<ll>> DP(S.size() + 1, vector<ll>(T.size() + 1, 0));
    for (int i = 1; i <= S.size(); i++) {
        for (int j = 1; j <= T.size(); j++) {
            if (S[i - 1] == T[j - 1]) {
                DP[i][j] = DP[i - 1][j - 1] + 1;
            }
            else {
                DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]);
            }
        }
    }
    string ans;
    int count = DP[S.size()][T.size()];
    int i = S.size(), j = T.size();
    while (count > 0) {
        while(DP[i - 1][j] == DP[i][j]) i--;
        while(DP[i][j - 1] == DP[i][j]) j--;
        ans += S[i - 1];
        i--; j--;
        count--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:5: error: 'reverse' was not declared in this scope
   31 |     reverse(ans.begin(), ans.end());
      |     ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
  string s, t;
  cin >> s >> t;
  int ss = s.size();
  int ts = t.size();
  vector<vector<string>>dp(ss + 1, vector<string>(ts + 1, ""));
  //dp[i][j] = sをi番目まで、tをj番目まで処理したときの最大の文字列
  for (int i = 1; i <= ss; i ++) {
    for (int j = 0; j <= tt; j ++) dp[i][j] = dp[i - 1][j];
    for (int j = 1; j <= tt; j ++) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + s[i - 1];
      }
    }
  }
  cout << dp[ss][ts] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:26: error: 'tt' was not declared in this scope; did you mean 'ts'?
   11 |     for (int j = 0; j <= tt; j ++) dp[i][j] = dp[i - 1][j];
      |                          ^~
      |                          ts
a.cc:12:26: error: 'tt' was not declared in this scope; did you mean 'ts'?
   12 |     for (int j = 1; j <= tt; j ++) {
      |                          ^~
      |                          ts
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
  string s, t;
  cin >> s >> t;
  int ss = s.size();
  int ts = t.size();
  vector<vector<string>>dp(ss + 1, vector<string>(tt + 1, ""));
  //dp[i][j] = sをi番目まで、tをj番目まで処理したときの最大の文字列
  for (int i = 1; i <= ss; i ++) {
    for (int j = 0; j <= tt; j ++) dp[i][j] = dp[i - 1][j];
    for (int j = 1; j <= tt; j ++) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + s[i - 1];
      }
    }
  }
  cout << dp[ss][ts] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:51: error: 'tt' was not declared in this scope; did you mean 'ts'?
    8 |   vector<vector<string>>dp(ss + 1, vector<string>(tt + 1, ""));
      |                                                   ^~
      |                                                   ts
Language: C++

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <cstring>

int main() {
  std::string s, t;
  std::cin >> s >> t;
  std::vector<std::vector<int>> dp_len(s.size());
  std::vector<std::vector<int>> dp_prev(s.size());
  int final_len = 0, final_pos = 0;

  dp_len[0].resize(t.size());
  dp_prev[0].resize(t.size(), -1);
  for (int j = 0; j < t.size(); ++j) {
    if (s[0] == t[j]) {
      dp_len[0][j] = 1;
      final_len = 1;
      final_pos = j;
    }
  }

  for (int i = 1; i < s.size(); ++i) {
    dp_len[i].resize(t.size());
    dp_prev[i].resize(t.size(), -1);
    int pos = -1;
    for (int j = 0; j < t.size(); ++j) {
      if (s[i] == t[j]) {
        dp_prev[i][j] = pos;
        dp_len[i][j] = (pos < 0 ? 0 : dp_len[i - 1][pos]) + 1;
        if (dp_len[i][j] > final_len) {
          final_len = dp_len[i][j];
          final_pos = j;
        }
      }
      else {
        dp_prev[i][j] = dp_prev[i - 1][j];
        dp_len[i][j] = dp_len[i - 1][j];
      }
      if (dp_len[i - 1][j] > dp_len[i - 1][pos])
        pos = j;
    }
  // for (int j = 0; j < t.size(); ++j) std::cout << std::setw(4) << dp_len[i][j];
  // std::cout << std::endl;
  // for (int j = 0; j < t.size(); ++j) std::cout << std::setw(4) << dp_prev[i][j];
  // std::cout << std::endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:49:4: error: expected '}' at end of input
   49 |   }
      |    ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[3001],t[3001];
    gets(s);
    gets(t);
    int t1=strlen(s),t2=strlen(t);
    string ans[2][t2+1];
    for(int i=1;i<=t1;i++)
    {
        for(int j=1;j<=t2;j++)
        {
            if(s[i-1]==t[j-1])
            {
                ans[i%2][j]=ans[(i-1)%2][j-1]+s[i-1];
            }else
            {
                if(ans[i%2][j-1].size()>ans[(i-1)%2][j].size())
                {
                    ans[i%2][j]=ans[i%2][j-1];
                }else
                {
                    ans[i%2][j]=ans[(i-1)%2][j];
                }
            }
        }
    }
    printf("%s",&ans[t1%2][t2][0]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
    6 |     gets(s);
      |     ^~~~
      |     getw
Language: C

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[3001],t[3001];
    gets(s);
    gets(t);
    int t1=strlen(s),t2=strlen(t);
    string ans[2][t2+1];
    for(int i=1;i<=t1;i++)
    {
        for(int j=1;j<=t2;j++)
        {
            if(s[i-1]==t[j-1])
            {
                ans[i%2][j]=ans[(i-1)%2][j-1]+s[i-1];
            }else
            {
                if(ans[i%2][j-1].size()>ans[(i-1)%2][j].size())
                {
                    ans[i%2][j]=ans[i%2][j-1];
                }else
                {
                    ans[i%2][j]=ans[(i-1)%2][j];
                }
            }
        }
    }
    printf("%s",&ans[t1%2][t2][0]);
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main() 
{
    string s,t;
    getline(cin,s);
    getline(cin,t);

    if(s.size() < t.size())
    	s.swap(t);

    int dp[s.size()+1][t.size()+1];

    for (int i = 0; i < s.size()+1; ++i)
    {
    	for (int j = 0; j < t.size()+1; ++j)
    	{
    		if(i == 0 || j == 0)
    		{
    			dp[i][j] = 0;
    		}
    		else
    		{
    			if(s[i-1] == t[j-1])
    				dp[i][j] = 1 + dp[i-1][j-1];
    			else
    				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    		}
    	}
    }

    int a = s.size();
    int b = t.size();
    string ans;
    while(1)
    {
    	if(a == 0 && b == 0)
    		break;
    	if(s[a-1] == t[b-1])
    	{
    		ans = ans +  s[a-1];
    		a = a-1;
    		b = b-1;
    	}
    	else
    	{
    		if(dp[a-1][b] == dp[a][b])
    			a = a-1;
    		else
    			b = b-1;
    	}
    }

    reverse(ans.begin(),ans.end());
    cout << ans << "\n";

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:5: error: 'reverse' was not declared in this scope
   56 |     reverse(ans.begin(),ans.end());
      |     ^~~~~~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
int dp[3001][3001];
int solve(string s, string t, int slength, int tlength){
	if(slength==0 || tlength ==0){
		return 0;
	}
	if(s[slength-1] == t[tlength-1]){
		return dp[slength-1][tlength-1] = 1 + solve(s, t, slength-1, tlength-1);
	}
	else{
		return dp[slength-1][tlength-1] = max(solve(s, t, slength-1, tlength), solve(s, t, slength, tlength-1));
	}
}
int main(){
	string s, t;
	cin>>s>>t;
	memset(dp, 0, sizeof(dp));
	solve(s, t, s.length(), t.length());
	int min=0;
	string ans="";
	for(int i=0;i<s.length();i++){
		for(int j=0;j<t.length();j++){
			if(dp[i][j]>min){
				min=dp[i][j];
				ans+=t[j];
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'memset' was not declared in this scope
   19 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #include<string>
Language: C++

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

int main()
{
	string a,b;
  	cin>>a>>b;
  	int m=a.length();
  	int n=b.length();
  
  int dp[m+1][n+1];
  
  for(int i=0;i<=m;i++)
    for(int j=0;j<=n;j++){
      if(i==0||j==0)
        dp[i][j]=0;
      else if(a[i-1]==b[j-1])
        dp[i][j]=1+dp[i-1][j-1];
      else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  int i=a.lenght(),j=b.length();
    string ans="";
    while(i>0&&j>0){
        if(dp[i][j]!=dp[i-1][j]&&dp[i][j]!=dp[i][j-1]){
            ans+=a[i-1];
            i--;j--;
        }
        else if(dp[i][j]==dp[i][j-1]) j--;
        else i--;
    }
    reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:11: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'lenght'; did you mean 'length'?
   21 |   int i=a.lenght(),j=b.length();
      |           ^~~~~~
      |           length
a.cc:23:16: error: 'j' was not declared in this scope
   23 |     while(i>0&&j>0){
      |                ^
Language: C++

#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;

const int N = 3000 + 5;

string dp[N][N];

int32_t main()
{
    ios::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    string a,b;
    cin >> a >> b;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    a += ' ';
    b += ' ';
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    for(int i = 1;i < a.size(); ++i)
    {
        for(int j = 1;j < b.size(); ++j)
        {
            if(a[i] == b[j])
            {
                string x = dp[i-1][j-1];
                x += a[i];
                if(x.size() > dp[i][j-1].size())
                    dp[i][j] = x;
                else
                    dp[i][j] = dp[i][j-1];
            }
            else
            {
                if(dp[i][j-1].size() > dp[i-1][j].size())
                    dp[i][j] = dp[i][j-1];
                else
                    dp[i][j] = dp[i-1][j];
            }
        }
    }
    int x = a.size() - 1, y = b.size() - 1;
    cout << dp[x][y];
}
    int x = a.size() - 1, y = b.size() - 1;
    cout << dp[x][y];
}

Compiler output:
a.cc:49:13: error: 'a' was not declared in this scope
   49 |     int x = a.size() - 1, y = b.size() - 1;
      |             ^
a.cc:50:5: error: 'cout' does not name a type
   50 |     cout << dp[x][y];
      |     ^~~~
a.cc:51:1: error: expected declaration before '}' token
   51 | }
      | ^
Language: C++

#include <stdio.h>
#include <iomanip>
#include <string.h>
#include <deque>
using namespace std;
const int N = 3000;
string s, t;
int dp[3001][3001];
main() {
  cin >> s >> t;
  for(int i = 1; i <= (int)strlen(s); i++) {
    for(int j = 1; j <= (int)strlen(t); j++) {
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      if(s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }
    }
  }

  deque < char > ans;
  int n = strlen(s), m = strlen(t);
  while(n && m) {
    if(dp[n][m] == dp[n - 1][m]) n--;
    else if(dp[n][m] == dp[n][m - 1]) m--;
    else if(dp[n][m] == dp[n - 1][m - 1] + 1) {
      ans.push_front(s[n - 1]); n--; m--;
    }

  }

  for(int i = 0; i < ans.size(); i++) {
    printf("%c", ans[i]);
  }
}

Compiler output:
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:10:3: error: 'cin' was not declared in this scope
   10 |   cin >> s >> t;
      |   ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <deque>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:11:35: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   11 |   for(int i = 1; i <= (int)strlen(s); i++) {
      |                                   ^
      |                                   |
      |                                   std::string {aka std::__cxx11::basic_string<char>}
In file included from a.cc:3:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:12:37: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   12 |     for(int j = 1; j <= (int)strlen(t); j++) {
      |                                     ^
      |                                     |
      |                                     std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:21:18: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   21 |   int n = strlen(s), m = strlen(t);
      |                  ^
      |                  |
      |                  std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:22:14: error: 'm' was not declared in this scope
   22 |   while(n && m) {
      |              ^
Language: C++

#include <iostream>
#include <iomanip>
#include <string.h>
#include <deque>
using namespace std;
const int N = 3005;
string s, t;
int dp[N][N];
main() {
	cin >> s >> t;
	for(int i = 1; i <= (int)s.size(); i++) {
		for(int j = 1; j <= (int)t.size(); j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if(s[i - 1] == t[j - 1]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
		}
	}

	deque < char > ans;
	int n = s.size(), m = t.size();
	while(n && m) {
		if(dp[n][m] == dp[n - 1][m - 1] + 1)
			ans.push_front(s[n - 1]); n--; m--;
		else if(dp[n][m] == dp[n - 1][m]) n--;
		else if(dp[n][m] == dp[n][m - 1]) m--;
	}

	for(int i = 0; i < ans.size(); i++) printf("%c", ans[i]);
}

Compiler output:
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:25:17: error: 'else' without a previous 'if'
   25 |                 else if(dp[n][m] == dp[n - 1][m]) n--;
      |                 ^~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <string.h>
#include <deque>
using namespace std;
const int N = 3001;
string s, t;
int dp[N][N];
main() {
	cin >> s >> t;
	for(int i = 1; i <= (int)strlen(s); i++) {
		for(int j = 1; j <= (int)strlen(t); j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if(s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
		}
	}

	deque < char > ans;
	int n = strlen(s), m = strlen(t);
	while(dp[n][m]) {
		if(dp[n][m] == dp[n - 1][m - 1] + 1) {
			ans.push_front(s[n - 1]); n--; m--;
		} else {
			if(dp[n][m] == dp[n - 1][m]) n--;
			if(dp[n][m] == dp[n][m - 1]) m--;
		}
	}

	for(int i = 0; i < ans.size(); i++) printf("%c", ans[i]);
}

Compiler output:
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:11:41: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   11 |         for(int i = 1; i <= (int)strlen(s); i++) {
      |                                         ^
      |                                         |
      |                                         std::string {aka std::__cxx11::basic_string<char>}
In file included from a.cc:3:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:12:49: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   12 |                 for(int j = 1; j <= (int)strlen(t); j++) {
      |                                                 ^
      |                                                 |
      |                                                 std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:21:24: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   21 |         int n = strlen(s), m = strlen(t);
      |                        ^
      |                        |
      |                        std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:22:21: error: 'm' was not declared in this scope
   22 |         while(dp[n][m]) {
      |                     ^
Language: C++

#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
#define F first
#define S second
const int N=3e3+10;
int max(int a,int b){return a>b?a:b;}
string a,b;
int val[N][N];
pair<int,int> to[N][N];
int dp(int l,int r){
  if(l<0||r<0)return 0;
  if(val[l][r]>=0)return val[l][r];
  if(a[l]==b[r]){
  	val[l][r]=dp(l-1,r-1)+1;
    to[l][r]={-1,-1};
  }
  else{
    int x=dp(l-1,r),y=dp(l,r-1);
    if(x>y){
      val[l][r]=x;
      to[l][r]={-1,0};
    }
    else{
      val[l][r]=y;
      to[l][r]={0,-1};
    }
    return val[l][r];
  }
}
int main(){
  cin>>a>>b;
  string s;
  int l=(int)a.size()-1,r=(int)b.size()-1,tl,tr;
  for(int i=0;i<=l;i++)for(int j=0;j<=r;j++)val[i][j]=-1;
  dp(l,r);
  while(l>0&&r>0){
    if(to[l][r]=={-1,-1})s+=a[l];
    tl=l+to[l][r].F;
    tr=r+to[l][r].S;
    l=tl;
    r=tr;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:18: error: expected primary-expression before '{' token
   39 |     if(to[l][r]=={-1,-1})s+=a[l];
      |                  ^
a.cc:39:18: error: expected ')' before '{' token
   39 |     if(to[l][r]=={-1,-1})s+=a[l];
      |       ~          ^
      |                  )
a.cc: In function 'int dp(int, int)':
a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
Language: Java

package EduDp;
import java.util.*;
public class lcs {
	public static int[][] dp;
	public static String b;
	public static String a;
	public static String findString(int r, int c, String st) {
		if(r < 0 || c < 0)return st;
		if(r == 0 && c == 0)return st;
		if(r == 0)return findString(r, c-1, st);
		if(c == 0)return findString(r-1, c, st);
		if(a.charAt(r-1) == b.charAt(c-1))return findString(r-1, c-1, a.charAt(r-1) + ""+st);
		if(dp[r-1][c] > dp[r][c-1])return findString(r-1, c, st);
		else return findString(r, c-1, st);
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		b = sc.nextLine();
		a = sc.nextLine();
		int alen = a.length();
		int blen = b.length();
//		System.out.println(alen+" "+blen);
		dp = new int[alen+1][blen+1];
		
		for(int i = 0; i <= alen; i ++) {		
			for(int j = 0; j <= blen; j++) {
				if(i == 0 || j == 0) {
					dp[i][j] = 0;
					continue;
				}
				if(i + j == 0);
				else if(i == 0)dp[i][j] = dp[i][j-1];
				else if(j == 0)dp[i][j] = dp[i-1][j];
				else dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
//				System.out.println(a.charAt(i-1) +" "+b.charAt(j-1));
				if(a.charAt(i-1) == b.charAt(j-1)) {
					dp[i][j] = dp[i-1][j-1]+1;
				}
			}
		}
//		for(int i = 0; i < alen+1; i++)System.out.println(Arrays.toString(dp[i]));
		System.out.println(findString(alen, blen, ""));
	}
}


Compiler output:
Main.java:3: error: class lcs is public, should be declared in a file named lcs.java
public class lcs {
       ^
1 error
Language: C++

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

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   }  
   int index = L[m][n]; 
   char lcs[index+1]; 
   lcs[index] = ''; 

   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1];
          i--; j--; index--;
      } 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   }
  cout << lcs << endl;
}

int main()
{
  string s1, s2;
  cin >> s1 >> s2;
  lcs(s1, s2, s1.length(), s2.length());
  return 0;
}

Compiler output:
a.cc:21:17: error: empty character constant
   21 |    lcs[index] = '';
      |                 ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

ll dp[1001][1001];

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		string s,t;
		cin>>s>>t;
		ll dp[s][t]={0};
		ll l1=s.length(),l2=t.length();
		for(ll i=l1-1;i>=0;i--){
			for(ll j=l2-1;j>=0;j--){
				if(s[i]==t[j])
					dp[i][j]=dp[i+1][j+1]+1;
				else{
					dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
				}
			}
		}
		for(ll i=0;i<l1;i++){
			for(ll j=0;j<l2;j++){
				if(s[i]==t[j])
					cout<<s[i];
				else if(dp[i+1][j]>=dp[i][j+1]){
					i++;
				}
				else{
					j++;
				}
			}
		}
		return 0;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:26: error: could not convert 't' from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long unsigned int'
   26 |                 ll dp[s][t]={0};
      |                          ^
      |                          |
      |                          std::string {aka std::__cxx11::basic_string<char>}
a.cc:26:26: error: size of array 'dp' has non-integral type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
a.cc:26:23: error: could not convert 's' from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long unsigned int'
   26 |                 ll dp[s][t]={0};
      |                       ^
      |                       |
      |                       std::string {aka std::__cxx11::basic_string<char>}
a.cc:26:23: error: size of array 'dp' has non-integral type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
Language: C++

#ifndef _MSC_VER
#include <bits/stdc++.h>
#endif // ! _MSC_VER

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<uint, uint> Pos;

static const uint m_max = 100001;
static const uint mod = 1000000007;

// bool m[m_max+2][m_max+2];
// uint c[m_max+2][m_max+2];

const uint dx[] = { 2, 1, 0, 1 };
const uint dy[] = { 1, 2, 1, 0 };

// int mwA[1001];
// int mwB[1001];
int dp[3002][3002];

int main(int, char**)
{
	string t, s;
	cin >> s >> t;

	// constract
	dp[0][0] = 0;
	for (unsigned int i = 0; i < s.length(); i++) {
		for (unsigned int j = 0; j < t.length(); j++) {
			if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
			else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
		}
	}

// #define TMP1
	// debug
#ifdef TMP1
	cerr << "    , ";
	for (unsigned int j = 0; j < t.length(); j++)
		cerr << t[j] << ", ";
	cerr << "\n";
	for (unsigned int i = 0; i <= s.length(); i++) {
		if (i == 0) cerr << " : ";
		else cerr << s[i-1] << ": ";
		for (unsigned int j = 0; j <= t.length(); j++)
			cerr << dp[i][j] << ", ";
		cerr << "\n";
	}
#endif

#define TMP2
	// make output
	string ans(dp[s.length()][t.length()], '\0');
	unsigned int j = t.length();
	while (dp[i][j] > 0) {
		--i; --j;
#ifdef TMP2
		cerr << "i:" << i;
#endif
#ifdef TMP2
		cerr << "\n  j:" << j;
		cerr << ":" << dp[i+1][j+1] << "," << dp[i][j+1] << "," << dp[i+1][j] << "," << dp[i][j];
#endif
		while (dp[i+1][j+1] == dp[i+1][j])
			--j;

		while (dp[i+1][j+1] == dp[i][j+1])
			--i;

#ifdef TMP2
		cerr << "[" << s[i] << "]";
#endif
		ans[dp[i][j]] = s[i];
#ifdef TMP2
		cerr << "\n";
#endif
	}

	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:59:19: error: 'i' was not declared in this scope
   59 |         while (dp[i][j] > 0) {
      |                   ^
Language: C++

#ifndef _MSC_VER
#include <bits/stdc++.h>
#endif // ! _MSC_VER

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<uint, uint> Pos;

static const uint m_max = 100001;
static const uint mod = 1000000007;

// bool m[m_max+2][m_max+2];
// uint c[m_max+2][m_max+2];

const uint dx[] = { 2, 1, 0, 1 };
const uint dy[] = { 1, 2, 1, 0 };

// int mwA[1001];
// int mwB[1001];
int dp[3002][3002];

int main(int, char**)
{
	string t, s;
	cin >> s >> t;

	// constract
	dp[0][0] = 0;
	for (unsigned int i = 0; i < s.length(); i++) {
		for (unsigned int j = 0; j < t.length(); j++) {
			if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
			else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
		}
	}

// #define TMP1
	// debug
#ifdef TMP1
	cerr << "    , ";
	for (unsigned int j = 0; j < t.length(); j++)
		cerr << t[j] << ", ";
	cerr << "\n";
	for (unsigned int i = 0; i <= s.length(); i++) {
		if (i == 0) cerr << " : ";
		else cerr << s[i-1] << ": ";
		for (unsigned int j = 0; j <= t.length(); j++)
			cerr << dp[i][j] << ", ";
		cerr << "\n";
	}
#endif

#define TMP2
	// make output
	string ans(dp[s.length()][t.length()], '\0');
	unsigned int x = ans.length();
	unsigned int j = t.length();
	for (unsigned int i = s.length(); i > 0; ) {
		--i; --j;
#ifdef TMP2
		cerr << "i:" << i;
#endif
#ifdef TMP2
			cerr << "\n  j:" << j;
			cerr << ":" << dp[i+1][j+1] << "," << dp[i][j+1] << "," << dp[i+1][j] << "," << dp[i][j];
#endif
			while (dp[i+1][j+1] == dp[i+1][j])
				--j;

			while (dp[i+1][j+1] == dp[i][j+1])
				--i;

#ifdef TMP2
				cerr << "[" << s[i] << "]";
#endif
			ans[--x] = s[i];
		}
#ifdef TMP2
		cerr << "\n";
#endif
	}

	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc:85:9: error: 'cout' does not name a type
   85 |         cout << ans << endl;
      |         ^~~~
a.cc:86:9: error: expected unqualified-id before 'return'
   86 |         return 0;
      |         ^~~~~~
a.cc:87:1: error: expected declaration before '}' token
   87 | }
      | ^
Language: C++

#ifndef _MSC_VER
#include <bits/stdc++.h>
#endif // ! _MSC_VER

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<uint, uint> Pos;

static const uint m_max = 100001;
static const uint mod = 1000000007;

// bool m[m_max+2][m_max+2];
// uint c[m_max+2][m_max+2];

const uint dx[] = { 2, 1, 0, 1 };
const uint dy[] = { 1, 2, 1, 0 };

// int mwA[1001];
// int mwB[1001];
int dp[3002][3002];

int main(int, char**)
{
	string t, s;
	cin >> s >> t;

	// constract
	dp[0][0] = 0;
	for (unsigned int i = 0; i < s.length(); i++) {
		for (unsigned int j = 0; j < t.length(); j++) {
			if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
			else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
		}
	}

// #define TMP1
	// debug
#ifdef TMP1
	cerr << "    , ";
	for (unsigned int j = 0; j < t.length(); j++)
		cerr << t[j] << ", ";
	cerr << "\n";
	for (unsigned int i = 0; i <= s.length(); i++) {
		if (i == 0) cerr << " : ";
		else cerr << s[i-1] << ": ";
		for (unsigned int j = 0; j <= t.length(); j++)
			cerr << dp[i][j] << ", ";
		cerr << "\n";
	}
#endif

#define TMP2
	// make output
	string ans(dp[s.length()][t.length()], '\0');
	unsigned int i = s.length();
	unsigned int m = t.length();
	for (unsigned int x = ans.length(); x > 0; ) {
		--i;
#ifdef TMP2
		cerr << "i:" << i;
#endif
		for (unsigned int j = m; j > 0;) {
			--j;
#ifdef TMP2
			cerr << "\n  j:" << j;
			cerr << ":" << dp[i+1][j+1] << "," << dp[i][j+1] << "," << dp[i+1][j] << "," << dp[i][j];
#endif
			if ((dp[i+1][j+1] > dp[i][j])
				&& (dp[i+1][j+1] > dp[i][j+1])
				&& (dp[i+1][j+1] > dp[i+1][j])) {
#ifdef TMP2
				cerr << "[" << s[i] << "]";
#endif
				ans[--x] = s[i];
				--m;
				break;
			}
		}
#ifdef TMP2
		cerr << "\n";
#endif
	}
#ifdef TMP2
	cerr << "x:" << x << endl;
#endif

	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:87:25: error: 'x' was not declared in this scope
   87 |         cerr << "x:" << x << endl;
      |                         ^
Language: C++

#ifndef _MSC_VER
#include <bits/stdc++.h>
#endif // ! _MSC_VER

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<uint, uint> Pos;

static const uint m_max = 100001;
static const uint mod = 1000000007;

// bool m[m_max+2][m_max+2];
// uint c[m_max+2][m_max+2];

const uint dx[] = { 2, 1, 0, 1 };
const uint dy[] = { 1, 2, 1, 0 };

// int mwA[1001];
// int mwB[1001];
int dp[3002][3002];

int main(int, char**)
{
	string t, s;
	cin >> s >> t;

	// constract
	dp[0][0] = 0;
	for (unsigned int i = 0; i < s.length(); i++) {
		for (unsigned int j = 0; j < t.length(); j++) {
			if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
			else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
		}
	}

// #define TMP1
	// debug
#ifdef TMP1
	cerr << "    , ";
	for (unsigned int j = 0; j < t.length(); j++)
		cerr << t[j] << ", ";
	cerr << "\n";
	for (unsigned int i = 0; i <= s.length(); i++) {
		if (i == 0) cerr << " : ";
		else cerr << s[i-1] << ": ";
		for (unsigned int j = 0; j <= t.length(); j++)
			cerr << dp[i][j] << ", ";
		cerr << "\n";
	}
#endif

#define TMP2
	// make output
	string ans(dp[s.length()][t.length()], '\0');
	unsigned int x = ;
	unsigned int i = s.length();
	unsigned int m = t.length();
	for (unsigned int x = ans.length(); x > 0; ) {
		--i;
#ifdef TMP2
		cerr << "i:" << i;
#endif
		for (unsigned int j = m; j > 0;) {
			--j;
#ifdef TMP2
			cerr << "\n  j:" << j;
			cerr << ":" << dp[i+1][j+1] << "," << dp[i][j+1] << "," << dp[i+1][j] << "," << dp[i][j];
#endif
			if ((dp[i+1][j+1] > dp[i][j])
				&& (dp[i+1][j+1] > dp[i][j+1])
				&& (dp[i+1][j+1] > dp[i+1][j])) {
#ifdef TMP2
				cerr << "[" << s[i] << "]";
#endif
				ans[--x] = s[i];
				--m;
				break;
			}
		}
#ifdef TMP2
		cerr << "\n";
#endif
	}
#ifdef TMP2
	cerr << "x:" << x << endl;
#endif

	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:58:26: error: expected primary-expression before ';' token
   58 |         unsigned int x = ;
      |                          ^
Language: C++

#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x)
#define mid (l + r) / 2
#define fi first
#define sc second
#define N 1000000009

using namespace std;

typedef long long int lli;

int main(){
	ios::sync_with_stdio(0);
	string a, b;
	cin >> a >> b;

	vector <vector <int>> dp(a.size()+1, vector <int>(b.size()+1));

	for(int i=0; i<a.size(); i++){
		for(int j=0; j<b.size(); j++){
			if(a[i] == a[j]){
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
			}
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
		}
	}

	int ans = 0;
	for(int i=0; i<a.size(); i++){
		for(int j=0; j<b.size(); j++)
			answer = max(answer, dp[i][j]);
	}

	cout << answer;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:25: error: 'answer' was not declared in this scope
   36 |                         answer = max(answer, dp[i][j]);
      |                         ^~~~~~
a.cc:39:17: error: 'answer' was not declared in this scope
   39 |         cout << answer;
      |                 ^~~~~~
Language: C++


int dp[3001][3001] = {};
	
int main(){
	string s, t;

	cin >> s >> t;


	for(int i=1; i<=s.size(); i++){
		for(int j=1; j<=t.size(); j++){
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else{
				if(dp[i][j-1] < dp[i-1][j]){
					dp[i][j] = dp[i-1][j];
				}
				else if(dp[i][j-1] < dp[i-1][j]){
					dp[i][j] = dp[i][j-1];
				}
			}
		}
	}

	string ans;
	int li = s.size()+1, lj = t.size()+1;
	for(int i=s.size(); i>=0; i--){
		for(int j=t.size(); j>=0; j--){
			if(dp[i][j] == dp[i-1][j]){

			}
			else if(dp[i][j] == dp[i][j-1]){

			}
		}
	}
	

	reverse(ans.begin(), ans.end());

	if(ans.size() == 0){
		cout << " " << endl;
	}
	else{
		cout << ans << endl;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: 'string' was not declared in this scope
    5 |         string s, t;
      |         ^~~~~~
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >> s >> t;
      |         ^~~
a.cc:7:16: error: 's' was not declared in this scope
    7 |         cin >> s >> t;
      |                ^
a.cc:7:21: error: 't' was not declared in this scope
    7 |         cin >> s >> t;
      |                     ^
a.cc:26:15: error: expected ';' before 'ans'
   26 |         string ans;
      |               ^~~~
      |               ;
a.cc:40:17: error: 'ans' was not declared in this scope
   40 |         reverse(ans.begin(), ans.end());
      |                 ^~~
a.cc:40:9: error: 'reverse' was not declared in this scope
   40 |         reverse(ans.begin(), ans.end());
      |         ^~~~~~~
a.cc:43:17: error: 'cout' was not declared in this scope
   43 |                 cout << " " << endl;
      |                 ^~~~
a.cc:43:32: error: 'endl' was not declared in this scope
   43 |                 cout << " " << endl;
      |                                ^~~~
a.cc:46:17: error: 'cout' was not declared in this scope
   46 |                 cout << ans << endl;
      |                 ^~~~
a.cc:46:32: error: 'endl' was not declared in this scope
   46 |                 cout << ans << endl;
      |                                ^~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define MAXN 3010

int s1[MAXN], s2[MAXN], dp[MAXN][MAXN];

solve(int a, int b){
    if(dp[a][b]!=-1)return dp[a][b];
    if(a==0 or b==0)return dp[a][b]=0;
    if(s1[a]==s2[b])return dp[a][b] = 1+solve(a-1,b-1);
    return dp[a][b]=max(solve(a-1,b),solve(a,b-1));
}

int main(){

    int n, m;

    cin >> n >> m;

    for(int i=1; i<=n; i++){
        cin>>s1[i];
    }
    for(int i=1; i<=m; i++){
        cin>>s2[i];
    }
    memset(dp,-1,sizeof dp);
    cout << solve(n,m) << endl;
    return 0;

}


Compiler output:
a.cc:9:1: error: ISO C++ forbids declaration of 'solve' with no type [-fpermissive]
    9 | solve(int a, int b){
      | ^~~~~
Language: C++

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int dp[3005][3005];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin>>s>>t;
    int n,m;
    n=s.size();
    m=t.size();
    if(s[0]==t[0])
    {
        dp[1][1]=1;
    }
    else
    {
        dp[1][1]=0;
    }
    for(int i=2; i<=n; i++)
    {
        for(int j=2; j<=m; j++)
        {
            if(s[i]==t[j])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string res="";
    int i=n,j=m;
    int x=dp[n][m];
        while(i>=1 || j>=1)
        {
            if(dp[i-1][j]==x)
            {
                i--;
            }
           else if(dp[i][j-1]==x)
            {
                j--;
            }
            else
            {
                x--;
                j--;
                res+=s[i-1];
                i--;
            }
        }
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;
    return 0;
}



Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~
a.cc:60:12: error: expected constructor, destructor, or type conversion before '(' token
   60 |     reverse(res.begin(),res.end());
      |            ^
a.cc:61:5: error: 'cout' does not name a type
   61 |     cout<<res<<endl;
      |     ^~~~
a.cc:62:5: error: expected unqualified-id before 'return'
   62 |     return 0;
      |     ^~~~~~
a.cc:63:1: error: expected declaration before '}' token
   63 | }
      | ^