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

#include <bits/stdc++.h>

using namespace std;

int main()
{

	string s, t;
	cin >> s;
	cin >> t;
	int n = s.length();
	int m = t.length();

	vector<vector<int>>dp(n + 1, vector<int>(m + 1 ,0));

	for (int i = 1; i <= n ; i++) {
		for (int j = 1; j <= m; j++) {
			int c = (s[i - 1] == t[j - 1]) ? 1:0;
			dp[i][j] = c + max(dp[i][j - 1], dp[i - 1][j - 1]);
		}
	}

	// for (int i = 1; i <= n; i++) {
	// 	for (int j = 1; j <= m; j++) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	int lMax = dp[n][m];
	//cout << lMax << endl;
	string lcs(lMax , 'a');
	int p1 = n;
	int p2 = m;
	
	while (p1 > 0 && p2 > 0) {
		if (s[p1 - 1] == t[p2 - 1]) {
			lcs[lMax - 1] = s[p1 - 1];
			p1--;
			p2--;
			lMax--;
		} else if (dp[p1 - 1][p2 - 1] > dp[p1][p2 - 1]) {
			p1--;
		} else {
			p2--;
		}
	}

	if (lmax != 0) {
		cout << lcs;
	}
	return 0;
}	

Compiler output:
a.cc: In function 'int main()':
a.cc:48:13: error: 'lmax' was not declared in this scope; did you mean 'lMax'?
   48 |         if (lmax != 0) {
      |             ^~~~
      |             lMax
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(){
	string s,t;
	cin >> s >> t;
	int n(s.size()), m(t.size());
	vector<vector<vector<char>>> dp(n+10, vector<vector<char>>(m+10));
	rep(i,n){
		rep(j,m){
			if(s[i] == t[j]){
				dp[i+1][j+1] = dp[i][j];
				dp[i+1][j+1].emplace_backs[i]);
			}else{
				if(dp[i+1][j].size() > dp[i][j+1].size()){
					dp[i+1][j+1] = dp[i+1][j];
				}else{
					dp[i+1][j+1] = dp[i][j+1];
				}
			}
		}
	}
	rep(i,dp[n][m].size()){
		cout << dp[n][m][i];
	}
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:46: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'class std::vector<char>'} has no member named 'emplace_backs'; did you mean 'emplace_back'?
   15 |                                 dp[i+1][j+1].emplace_backs[i]);
      |                                              ^~~~~~~~~~~~~
      |                                              emplace_back
Language: C++

// 動的計画法
// 最長共通部分列
// Longest Common Subsequence (LCS)

#include <cstdio>
#include <string>
#include <iostream>

#define rep(i,a) for(int i=0;i<(a);i++)
using namespace std;
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

typedef pair<int, string> P;
const int N=3005;

string s,t;

int dp[N][N]; //[i][j]---S1...Siとt1...tiに対するLCSのながさ

int rec(int i, int j) {
  if(i >= 0 || j>= 0) return 0;
  if(dp[i][j] != -1) return dp[i][j];
  int ret1 = 0;
  if( s[i] == t[i] ) ret1 = rec(i+1, j+1) + 1;
  else ret1 = max({ret1, rec(i+1, j), rec(i, j+1)});
  return dp[i][j] = ret1;
}

int main() {
  cin >> s >> t;
  rep(i, s.length()) {
    rep(j, t.length()) {
      if(s[i] == t[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
        // c[i+1][j+1] = c[i][j] + s[i];
      } else {
        if (dp[i][j+1] > dp[i+1][j]) {
          dp[i+1][j+1] = dp[i][j+1];
          // c[i+1][j+1] = c[i][j+1];
        } else {
          dp[i+1][j+1] = dp[i+1][j];
          // c[i+1][j+1] = c[i+1][j];
        }
      }
    }
  }

  string ans = "";
  int i = s.length();
  int j = t.length();
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      --i;
    } else if (dp[i][j] == dp[i][j - 1]) {
      --j;
    } else {
      ans = s[i - 1] + ans;
      --i;
      --j;
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int rec(int, int)':
a.cc:26:18: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   26 |   else ret1 = max({ret1, rec(i+1, j), rec(i, j+1)});
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
Language: C

#include <stdio.h>
#include <string.h>

void strrev(char *s) {
	char tmp = '\0';
	char *first = s;
	char *last = s;

	if (*first == '\0') return;

	while (*(last+1) != '\0') last++;

	while(first < last) {
		tmp = *first;
		*first = *last;
		*last = tmp;

		first++;
		last--;
	}
	return;
}

int main() {
	char S1[3010], S2[3010];
	scanf("%s", S1);
	scanf("%s", S2);
	int len1 = strlen(S1);
	int len2 = strlen(S2);
	int DP[3010][3010];
	for (int i = 0; i < 3010; i++) {
		for (int j = 0; j < 3010; j++) {
			DP[i][j] = 0;
		}
	}

	for (int i = 1; i < len1+1; i++) {
		for (int j = 1; j < len2+1; j++) {
			int max = DP[i-1][j-1] + (S1[i - 1] == S2[j - 1]);

			if (max < DP[i-1][j]) max = DP[i-1][j];
			else if (max < DP[i][j - 1]) max = DP[i][j - 1];
			DP[i][j] = max;
		}
	}

	int point = 0;
	char ans[3010];
	for (int i = ; i< 3010; i++) ans[i] = '\0';
	int i = len1, j = len2;

	while (i != 0 && j != 0) {
		if (DP[i][j] == DP[i-1][j]) i--;
		else if (DP[i][j] == DP[i][j-1]) j--;
		else {
			ans[point] = S1[i-1];
			i--; j--;
			point++;
		}
	}
	strrev(ans);
	printf("%s\n", ans);
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:49:22: error: expected expression before ';' token
   49 |         for (int i = ; i< 3010; i++) ans[i] = '\0';
      |                      ^
Language: C++

#include <iostream>
#include <vector>
#include <string>

int main() {

    std::string s;
    std::string t;

    std::cin >> s;
    std::cin >> t;

    std::vector<std::vector<int>> dp(s.size()+1, std::vector<int>(t.size()+1, 0));
    std::vector<std::vector<int>> trace(s.size()+1, std::vector<int>(t.size()+1, 0)); // keep track of which we used

    const int UP = 1;
    const int LEFT = 2;
    const int DIAG = 3;

    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= t.size(); j++) {

            int cur = dp[i-1][j];
            int curDir = UP;

            if (dp[i][j-1] > cur) {
                cur = dp[i][j-1];
                curDir = LEFT;
            }

            if (dp[i-1][j-1] > cur) {
                cur = dp[i-1][j-1];
                curDir = DIAG;
            }

            if (s[i-1] == t[j-1]) {
                if (dp[i-1][j-1]+1 > cur) {
                    cur = dp[i-1][j-1]+1;
                    curDir = DIAG;
                }
            }

            dp[i][j] = cur;
            trace[i][j] = curDir;
        }
    }

    std::string ans = "";

    int i = s.size();
    int j = t.size();
    
    while (i > 0 && j > 0) {
        if (trace[i][j] == DIAG) {
            ans += t[j-1];
            i--;
            j--;
        } else if (trace[i][j] == UP) {
            i--;
        } else {
            j--;
        }
    }

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

    std::cout << ans << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:10: error: 'reverse' is not a member of 'std'
   65 |     std::reverse(ans.begin(), ans.end());
      |          ^~~~~~~
Language: C++

#include <stdio.h>
vector<vector<int> > L;
int max(int a, int b){
  return a>b ? a:b ;
}
string LCS(string S1, string S2){
  for(int i=0;i<strlen(S1);i++)
    for(int j=0;j<strlen(S2);j++){
  		if(i==0 || j==0) L[i][j] = 0;
      	else{
  			if(S1[i] == S2[j]) L[i][j] = L[i-1][j-1] + 1;
  			else L[i][j] = max(L[i][j-1],L[i-1][j]);
        }
    }
  	string ansString;
  	for(int i=strlen(S1)-1, j=strlen(S2)-1 ; i>=0 && j>=0 ;)
    {
      if(L[i][j] == 0) break;
      if(L[i][j] != max(L[i-1][j],L[i][j-1])){ ansString.append(S1[i]);
                                              i--;
                                              j--;
                                             }
      else if(L[i][j] == L[i-1][j]) i--;
      else if(L[i][j] == L[i][j-1]) j--;
    }
  
  	reverse(ansString.begin(),ansString.end());
	retutrn ansString;
}
int main()
{
  string s,t;
  string commonSeq = LCS(s,t);
  printf("%s",commonSeq);
}

Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<vector<int> > L;
      | ^~~~~~
a.cc:6:1: error: 'string' does not name a type; did you mean 'stdin'?
    6 | string LCS(string S1, string S2){
      | ^~~~~~
      | stdin
a.cc: In function 'int main()':
a.cc:32:3: error: 'string' was not declared in this scope; did you mean 'stdin'?
   32 |   string s,t;
      |   ^~~~~~
      |   stdin
a.cc:33:9: error: expected ';' before 'commonSeq'
   33 |   string commonSeq = LCS(s,t);
      |         ^~~~~~~~~~
      |         ;
a.cc:34:15: error: 'commonSeq' was not declared in this scope
   34 |   printf("%s",commonSeq);
      |               ^~~~~~~~~
Language: C++

import java.util.*;
import java.io.*;
import java.lang.*;
// ArrayList<Integer>[] arr=new ArrayList[n];
public class Main{	
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
         StringBuilder sb=new StringBuilder();
         BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
         String s1=s.nextLine(),t1=s.nextLine();
         int n=s1.length(),m=t1.length();
        int[][] dp=new int[n+1][m+1];
        for(int i=1;i<=n;i++){
            char c1=s1.charAt(i-1);
            for(int j=1;j<=m;j++){
                char c2=t1.charAt(j-1);
                if(c1==c2){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=Math.max(dp[i][j-1],dp[i-1][j]);
                }
            }
        }
         /*for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                System.out.print(dp[i][j]+" ");
            }
            System.out.println();
        }*/
         int i=n,j=m,res=dp[n][m];
         while(i!=0&&j!=0){
            if(dp[i-1][j-1]==res){
                i--;j--;
            }
            else{
                sb.insert(0,s1.charAt(i-1));
                res--;
                i--;j--;
            }
         }
        System.out.println(sb);
        }
    }


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.lang.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main{
      | ^~~~~~
Language: C

#include <stdio.h>
#include <string.h>
int max(int a,int b)
{
	if(a>b) return a;
	else return b;
}
int dp[4000][4000];
int main()
{
	char a[4000],b[4000];
	scanf("%s%s",a,b);
	int n1=strlen(a),n2=strlen(b);
	for(int i=n1;i>=0;i--)
	{
		for(int j=n2;j>=0;j--)
		{
			if(j==n2 || i==n1){ dp[i][j]=0; continue;}
			if(a[i]==b[j]) dp[i][j]=1+dp[i+1][j+1];
			else dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
		}
	}
//	printf("1\n");
//	printf("%d\n",dp[0][0]);
	char ans[3005];
	int k=0;
	int i=0;j=0;
		while(i<n1&&j<n2)
		{
			if(dp[i][j]>dp[i+1][j]&&dp[i][j]>dp[i][j+1])
			{
				ans[k++]=a[i];
				i++;
				j++;
			}
			if(dp[i][j]==dp[i+1][j]){ i++;  continue;}
			if(dp[i][j]==dp[i][j+1]){ j++;continue;}
		}
	
	if(k==0)
	{
		printf(" ");
		return 0;
	}
	printf("%s",ans);
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:27:17: error: 'j' undeclared (first use in this function)
   27 |         int i=0;j=0;
      |                 ^
main.c:27:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<iostream>
//#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	char S[3000], T[3000];
	scanf("%s", S);
	int N = strlen(S);
	scanf("%s", T);
	int M = strlen(T);

	short dp[3001][3001];
	dp[0][0] = 0;
	rep1(i, N) dp[i][0] = 0;
	rep1(j, M) dp[0][j] = 0;
	rep(i, N) {
		rep(j, M) {
			dp[i + 1][j + 1] = (S[i] == T[j] ? dp[i][j] + 1 : max(dp[i][j + 1], dp[i + 1][j]));
		}
	}
	char kotae[3000];
	int k = dp[N][M];
	int i = N, j = M;
	while (k > 0) {
		while (i > 0 && dp[i - 1][j] == dp[i][j]) i--;
		while (j > 0 && dp[i][j - 1] == dp[i][j]) j--;
		i--;
		j--;
		kotae[--k] = S[i];
	}
	fwrite(kotae, 1, dp[N][M], stdout);

	Would you please return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:17: error: 'strlen' was not declared in this scope
   33 |         int N = strlen(S);
      |                 ^~~~~~
a.cc:8:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include<vector>
  +++ |+#include <cstring>
    8 | #include<string>
Language: Java

import java.io.IOException;
import java.util.Scanner;

public class LCS {
    static char[] s, t;

    static int[][] memo;
    static boolean[][] vis;

    static int dp(int idxA, int idxB) {
        if(idxA == s.length || idxB == t.length) return 0;
        if(vis[idxA][idxB]) return memo[idxA][idxB];
        int ans = 0;
        if(s[idxA] == t[idxB]) {
            ans = 1 + dp(idxA + 1, idxB + 1);
        } else {
            ans = dp(idxA + 1, idxB);
            ans = Math.max(ans, dp(idxA, idxB + 1));
        }
        vis[idxA][idxB] = true;
        return memo[idxA][idxB] = ans;
    }

    static void trace(int idxA, int idxB) {
        if(idxA == s.length || idxB == t.length) {
            System.out.println();
            return;
        }
        if(s[idxA] == t[idxB]) {
            System.out.print(s[idxA]);
            trace(idxA + 1, idxB + 1);
        } else {
            int ans = dp(idxA, idxB);
            if(ans == dp(idxA + 1, idxB)) {
                trace(idxA + 1, idxB);
            } else {
                trace(idxA, idxB + 1);
            }
        }
    }

    static int solveBottomUp() {
        memo = new int[s.length + 1][t.length + 1];

        for(int i = 0; i <= s.length; i++)
            memo[i][t.length] = 0;
        for(int i = 0; i <= t.length; i++)
            memo[s.length][i] = 0;

        for(int idxA = s.length - 1 ; idxA >= 0; idxA--) {
            for(int idxB = t.length - 1 ; idxB >= 0 ; idxB--) {
                int ans = 0;
                if(s[idxA] == t[idxB]) {
                    ans = 1 + memo[idxA + 1][idxB + 1];
                } else {
                    ans = memo[idxA + 1][idxB];
                    ans = Math.max(ans, memo[idxA][idxB + 1]);
                }
                memo[idxA][idxB] = ans;
            }
        }
        return memo[0][0];
    }

    static int solveTopDown() {
        memo = new int[s.length][t.length];
        vis = new boolean[s.length][t.length];
        return dp(0, 0);
    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        s = sc.next().toCharArray();
        t = sc.next().toCharArray();
        System.out.println(solveTopDown());
        trace(0, 0);
    }
}


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

#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s1,s2;
	cin >> s1 >> s2;
	int n1 = s1.length();
	int n2 = s2.length();
	vector <vector<int> > dp(n1+1,vector <int> (n2+1,0));
	// vector <vector<pair <int,int>>>dp2(n1+1,vector <pair<int,int>>(n2+1));
	for(int i=0;i<n1;i++)
	{
		for(int j=0;j<n2;j++)
		{
			// dbg2(i,j);
			if(s1[i]==s2[j])
			{
				if(dp[i+1][j+1]<1+dp[i][j])
				{
					// cout << i << " " << j << "\n";
					dp[i+1][j+1]=dp[i][j]+1;
					dp2[i+1][j+1]={i,j};
				}
			}
			if(dp[i+1][j]<=dp[i][j])
			{
				dp[i+1][j]=dp[i][j];
				dp2[i+1][j]=dp2[i][j];
			}
			if(dp[i][j+1]<=dp[i][j])
			{
				dp[i][j+1]=dp[i][j];
				dp2[i][j+1]=dp2[i][j];
			}
		}
	}
	int a=n1;
	int b=n2;
	vector <char> res;
	while (a>0 and b>0)
	{
		if(dp[a][b]==dp[a-1][b])
		{
			a-=1;

		}
		else if(dp[a][b]==dp[a][b-1])
		{
			b-=1;
		}
		else
		{
			a-=1;
			b-=1;
			res.push_back(s1[a]);
		}
	}
	reverse(res.begin(),res.end());
	for(auto a:res)
		cout << a;
	// for(int i=0;i<=n1;i++)
	// {
	// 	for(int j=0;j<=n2;j++)
	// 	{
	// 		cout << dp2[i][j].first << "," << dp2[i][j].second << " ";
	// 		if(dp[i][j]>=ans)
	// 		{
	// 			ans=dp[i][j];
	// 			a=dp2[i][j].first;
	// 			b=dp2[i][j].second;
	// 		}
	// 	}
	// 	cout << "\n";
	// }
	// cout << ans << "\n";
	// if(s1[a]==s2[b])
	// 	{
	// 		cout << s1[a];
	// 	}
	// while(a!=0&&b!=0)
	// {
	// 	a=dp2[a][b].first;
	// 	b=dp2[a][b].second;
	// 	dbg2(s1[a],s2[b]);
	// 	if(s1[a]==s2[b])
	// 	{
	// 		// cout << s1[a];
	// 	}

	// }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:41: error: 'dp2' was not declared in this scope; did you mean 'dp'?
   39 |                                         dp2[i+1][j+1]={i,j};
      |                                         ^~~
      |                                         dp
a.cc:45:33: error: 'dp2' was not declared in this scope; did you mean 'dp'?
   45 |                                 dp2[i+1][j]=dp2[i][j];
      |                                 ^~~
      |                                 dp
a.cc:50:33: error: 'dp2' was not declared in this scope; did you mean 'dp'?
   50 |                                 dp2[i][j+1]=dp2[i][j];
      |                                 ^~~
      |                                 dp
Language: C++

#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
  string s,t;
  cin>>s>>t;
  int n,m;
  n = s.size();
  m = t.size();
  vector <vector <int> > dp(n+1,vector <int>(m+1));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      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]);
      }
    }
  }
  /*for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=m;j++)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<"\n";
  }*/
  char dest[dp[n][m]];
  int count = 0;
  int i = n;
  int j = m;
  //cout<<i<<" "<<j<<" "<<endl;
  /*while(i>0 && j>0)
  {
    if(dp[i][j] == 1+dp[i-1][j-1])
    {
      if(n>m)
      {
      	dest[count] = t[j-1];
	    count++;
	    i--;
	    j--;
	  }
	  else
	  {
	  	dest[count] = s[i-1];
      	count++;
      	i--;
      	j--;
	  }
    }
    else if(dp[i][j-1] > dp[i-1][j])
    {
      j--;
    }
    else
    {
      i--;
    }
  }
  for(int i=dp[n][m]-1;i>=0;i--)
  {
    cout<<dest[i];
  }
  cout<<endl;*/
  #include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
  string s,t;
  cin>>s>>t;
  int n,m;
  n = s.size();
  m = t.size();
  vector <vector <int> > dp(n+1,vector <int>(m+1));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      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]);
      }
    }
  }
  /*for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=m;j++)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<"\n";
  }*/
  char dest[dp[n][m]];
  int count = 0;
  int i = n;
  int j = m;
  //cout<<i<<" "<<j<<" "<<endl;
  while(i>0 && j>0)
  {
    if(dp[i][j] == 1+dp[i-1][j-1])
    {
      if(n>m)
      {
      	dest[count] = t[j-1];
	    count++;
	    i--;
	    j--;
	  }
	  else
	  {
	  	dest[count] = s[i-1];
      	count++;
      	i--;
      	j--;
	  }
    }
    else if(dp[i][j-1] > dp[i-1][j])
    {
      j--;
    }
    else
    {
      i--;
    }
  }
  for(int i=dp[n][m]-1;i>=0;i--)
  {
    cout<<dest[i];
  }
  cout<<endl;
  return 0;
}
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   81 | int main()
      |         ^~
a.cc:81:9: note: remove parentheses to default-initialize a variable
   81 | int main()
      |         ^~
      |         --
a.cc:81:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:82:1: error: a function-definition is not allowed here before '{' token
   82 | {
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
    
    string s,t;
    cin>>s>>t;
    string L[s.size() + 1][t.size() + 1];  
    int i, j;  
      
    for (i = 0; i <= s.size(); i++)  
    {  
        for (j = 0; j <= t.size(); j++)  
        {  
        if (i == 0 || j == 0)  
            L[i][j] = "";  
      
        else if (X[i - 1] == Y[j - 1])  
            L[i][j] = L[i - 1][j - 1] + Y[j - 1];  
      
        else
            L[i][j] = (L[i - 1][j].size() > L[i][j - 1].size()) ? L[i - 1][j] : L[i][j-1] ;  
        }  
    }  
          
    
    cout<< L[s.size()][t.size()];
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: 'X' was not declared in this scope
   19 |         else if (X[i - 1] == Y[j - 1])
      |                  ^
a.cc:19:30: error: 'Y' was not declared in this scope
   19 |         else if (X[i - 1] == Y[j - 1])
      |                              ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
    
    string s,t;
    cin>>s>>t;
    string L[m + 1][n + 1];  
    int i, j;  
      
    for (i = 0; i <= m; i++)  
    {  
        for (j = 0; j <= n; j++)  
        {  
        if (i == 0 || j == 0)  
            L[i][j] = "";  
      
        else if (X[i - 1] == Y[j - 1])  
            L[i][j] = L[i - 1][j - 1] + Y[j - 1];  
      
        else
            L[i][j] = (L[i - 1][j].size() > L[i][j - 1].size()) ? L[i - 1][j] : L[i][j-1] ;  
        }  
    }  
          
    
    cout<< L[m][n];
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: 'm' was not declared in this scope
    9 |     string L[m + 1][n + 1];
      |              ^
a.cc:9:21: error: 'n' was not declared in this scope
    9 |     string L[m + 1][n + 1];
      |                     ^
a.cc:17:13: error: 'L' was not declared in this scope
   17 |             L[i][j] = "";
      |             ^
a.cc:19:18: error: 'X' was not declared in this scope
   19 |         else if (X[i - 1] == Y[j - 1])
      |                  ^
a.cc:19:30: error: 'Y' was not declared in this scope
   19 |         else if (X[i - 1] == Y[j - 1])
      |                              ^
a.cc:20:13: error: 'L' was not declared in this scope
   20 |             L[i][j] = L[i - 1][j - 1] + Y[j - 1];
      |             ^
a.cc:23:13: error: 'L' was not declared in this scope
   23 |             L[i][j] = (L[i - 1][j].size() > L[i][j - 1].size()) ? L[i - 1][j] : L[i][j-1] ;
      |             ^
a.cc:28:12: error: 'L' was not declared in this scope
   28 |     cout<< L[m][n];
      |            ^
Language: C++

#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-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]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
} 
  
/* Driver program to test above function */
int main() 
{ 
  string s,t;
  cin>>s>>t;
  char X[] = s; 
  char Y[] = t; 
  int m = strlen(X); 
  int n = strlen(Y); 
  lcs(X, Y, m, n); 
  return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:14: error: initializer fails to determine size of 'X'
   63 |   char X[] = s;
      |              ^
a.cc:63:14: error: array must be initialized with a brace-enclosed initializer
a.cc:64:14: error: initializer fails to determine size of 'Y'
   64 |   char Y[] = t;
      |              ^
a.cc:64:14: error: array must be initialized with a brace-enclosed initializer
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int dp[3005][3005];

int main() {
  string s, t;
  cin >> s >> t;
  int m = s.size();
  int n = t.size();

  rep(i, 3005) {
    dp[0][i] = 0;
    dp[i][0] = 0;
    rep(j, 3005) {
      trace[i][j] = false;
    }
  }

  string ans;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
        trace[i][j] = true;
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  // DP テーブルの末端から周囲を見て最適な行動をする
  int d = dp[m][n];
  int y = s.size();
  int x = t.size();
  while (d > 0) {
    if (dp[y-1][x] == d) y--;
    else if (dp[y][x-1] == d) x--;
    else {
      ans.push_back(s[y-1]);
      x--; y--; d--;
    }
  }

  // cerr << dp[m][n] << endl;
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:7: error: 'trace' was not declared in this scope
   29 |       trace[i][j] = false;
      |       ^~~~~
a.cc:38:9: error: 'trace' was not declared in this scope
   38 |         trace[i][j] = true;
      |         ^~~~~
Language: C++

#include<bits/stdc++.h>
 
using namespace std;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
unordered_map<pair<int,int>,string,hash_pair> ash;
string helper(string s,string t,int i,int j){
	if(ash.find(make_pair(i,j)) != ash.end()){
		return ash[{i,j}];
	}
	if(i >= s.length() || j >= t.length()){
		return "";
	}
	else if(s[i] == t[j]){
		ash[{i,j}] = strcat(s[i],helper(s,t,i+1,j+1)); 
		return ash[{i,j}];
	}
	else{
		string a = helper(s,t,i+1,j);
		string b = helper(s,t,i,j+1);
		if(a.length() > b.length()){
			ash[{i,j}] = a;
			return a;
		}
		else{
			ash[{i,j}] = b;
		return b;
	}
	}
}
int main(){
	string s,t;
	cin>>s>>t;
	cout<<helper(s,t,0,0);
}

Compiler output:
a.cc: In function 'std::string helper(std::string, std::string, int, int)':
a.cc:23:36: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'char*' [-fpermissive]
   23 |                 ash[{i,j}] = strcat(s[i],helper(s,t,i+1,j+1));
      |                              ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                    |
      |                                    __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
a.cc:23:48: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   23 |                 ash[{i,j}] = strcat(s[i],helper(s,t,i+1,j+1));
      |                                          ~~~~~~^~~~~~~~~~~~~
      |                                                |
      |                                                std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:149:70: note:   initializing argument 2 of 'char* strcat(char*, const char*)'
  149 | extern char *strcat (char *__restrict __dest, const char *__restrict __src)
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std; 
void lcs( string s, string t, 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] = '\0';
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; 
} 
int main() 
{ 
string s, t;
cin >> s >> t; 
int m = s.size(); 
int n = t.size(); 
lcs(s, t, m, n); 
return 0; 
} 


Compiler output:
a.cc: In function 'void lcs(std::string, std::string, int, int)':
a.cc:12:18: error: 'X' was not declared in this scope
   12 |         else if (X[i-1] == Y[j-1])
      |                  ^
a.cc:12:28: error: 'Y' was not declared in this scope
   12 |         else if (X[i-1] == Y[j-1])
      |                            ^
a.cc:24:13: error: 'X' was not declared in this scope
   24 |         if (X[i-1] == Y[j-1])
      |             ^
a.cc:24:23: error: 'Y' was not declared in this scope
   24 |         if (X[i-1] == Y[j-1])
      |                       ^
Language: C++

#include<bits/stdc++.h>

using namespace std;
void lcs(string s, string t){
  int n = s.size();
  int m = t.size();
  int dp[n+1][m+1];
  vector<char>c;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=m; j++){
      if( i==0 || j==0 ){
	dp[i][j] = 0;
      }
      else if(s[i-1] == t[j-1]){
	dp[i][j] = 1+dp[i][j-1];
      }
      else{
	dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  }
  int i=n;
  int j=m;
  while(i > 0 && j > 0){
    if(s[i-1] == t[j-1]){
      c.push_back(s[i-1]);
      i = i-1;
      j = j-1;	
    }
    else if(dp[i-1][j] > dp[i][j-1]){
	i= i-1;
	j = j;
      }
      else {
	i =i;
	j = j-1;
      }
    }
  for(int a = c.size()-1; a >=0; a--){
    cout << c[a];
  }
}
int main(){
  string s, t;
  cin >> s;
  cin >> t;
  lcs(s, t);
  return 0;
}


Compiler output:
a.cc:23:9: error: 'n' was not declared in this scope; did you mean 'yn'?
   23 |   int i=n;
      |         ^
      |         yn
a.cc:24:9: error: 'm' was not declared in this scope; did you mean 'tm'?
   24 |   int j=m;
      |         ^
      |         tm
a.cc:25:3: error: expected unqualified-id before 'while'
   25 |   while(i > 0 && j > 0){
      |   ^~~~~
a.cc:40:3: error: expected unqualified-id before 'for'
   40 |   for(int a = c.size()-1; a >=0; a--){
      |   ^~~
a.cc:40:27: error: 'a' does not name a type
   40 |   for(int a = c.size()-1; a >=0; a--){
      |                           ^
a.cc:40:34: error: 'a' does not name a type
   40 |   for(int a = c.size()-1; a >=0; a--){
      |                                  ^
a.cc:43:1: error: expected declaration before '}' token
   43 | }
      | ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>S>>T;
  DP[S.size()+1][T.size()+1];
  
  for(int i=1; i<=S.size(); ++i){
    for(int j=1; j<T.size(); ++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]);
    }
  }
  
  int len=DP[S.size()][T.size()];
  int i=S.size();
  int j=T.size();
  string ans;
  
  while(len>0){
    if(S[i]==T[j]){
      ans[len]=S[i];
      i--;
      j--;
      len--;
    }
    else if(DP[i][j]==DP[i-1][j]) i--;
    else j--;
  }
  
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:3: error: 'DP' was not declared in this scope; did you mean 'PP'?
   30 |   DP[S.size()+1][T.size()+1];
      |   ^~
      |   PP
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>S>>T;
  DP[S.size()+1][T.size()+1];
  
  for(int i=1; i<=S.size(); ++i){
    for(int j=1; j<T.size(); ++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]);
    }
  }
  
  int len=DP[S.size()][T.size()];
  i=S.size();
  j=T.size();
  string ans;
  
  while(len>0){
    if(S[i]==T[j]){
      ans[len]=S[i];
      i--;
      j--;
      len--;
    }
    else if(DP[i][j]==DP[i-1][j]) i--;
    else j--;
  }
  
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:3: error: 'DP' was not declared in this scope; did you mean 'PP'?
   30 |   DP[S.size()+1][T.size()+1];
      |   ^~
      |   PP
a.cc:40:3: error: 'i' was not declared in this scope
   40 |   i=S.size();
      |   ^
a.cc:41:3: error: 'j' was not declared in this scope; did you mean 'jn'?
   41 |   j=T.size();
      |   ^
      |   jn
Language: C++

/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-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]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout << lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
char[3001] X ;
  cin>>X;
char[3001 Y;
  cin>>Y;
int m = strlen(X);
int n = strlen(Y);
lcs(X, Y, m, n); 
return 0; 
} 



Compiler output:
a.cc: In function 'int main()':
a.cc:62:6: error: expected identifier before numeric constant
   62 | char[3001] X ;
      |      ^~~~
a.cc:62:6: error: expected ']' before numeric constant
   62 | char[3001] X ;
      |      ^~~~
      |      ]
a.cc:62:5: error: structured binding declaration cannot have type 'char'
   62 | char[3001] X ;
      |     ^
a.cc:62:5: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:62:5: error: empty structured binding declaration
a.cc:62:12: error: expected initializer before 'X'
   62 | char[3001] X ;
      |            ^
a.cc:63:8: error: 'X' was not declared in this scope
   63 |   cin>>X;
      |        ^
a.cc:64:6: error: expected identifier before numeric constant
   64 | char[3001 Y;
      |      ^~~~
a.cc:64:6: error: expected ']' before numeric constant
   64 | char[3001 Y;
      |      ^~~~
      |      ]
a.cc:65:8: error: 'Y' was not declared in this scope
   65 |   cin>>Y;
      |        ^
Language: C++

/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-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]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout << lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
string X ;
  cin>>X;
string Y;
  cin>>Y;
int m = X.length();
int n = Y.length();
lcs(X, Y, m, n); 
return 0; 
} 



Compiler output:
a.cc: In function 'int main()':
a.cc:68:5: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
   68 | lcs(X, Y, m, n);
      |     ^
      |     |
      |     std::string {aka std::__cxx11::basic_string<char>}
a.cc:8:17: note:   initializing argument 1 of 'void lcs(char*, char*, int, int)'
    8 | void lcs( char *X, char *Y, int m, int n )
      |           ~~~~~~^
Language: C++

/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-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]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout << lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
string X ;
  cin>>X;
string Y;
  cin>>Y;
int m = X.length;
int n = Y.length();
lcs(X, Y, m, n); 
return 0; 
} 



Compiler output:
a.cc: In function 'int main()':
a.cc:66:11: error: cannot convert 'std::__cxx11::basic_string<char>::length' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'int'
   66 | int m = X.length;
      |           ^~~~~~
a.cc:68:5: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
   68 | lcs(X, Y, m, n);
      |     ^
      |     |
      |     std::string {aka std::__cxx11::basic_string<char>}
a.cc:8:17: note:   initializing argument 1 of 'void lcs(char*, char*, int, int)'
    8 | void lcs( char *X, char *Y, int m, int n )
      |           ~~~~~~^
Language: C++

/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-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]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout << "LCS of " << X << " and " << Y << " is " << lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
char X[];
  cin>>X:
char Y[];
  cin>>Y;
int m = strlen(X); 
int n = strlen(Y); 
lcs(X, Y, m, n); 
return 0; 
} 



Compiler output:
a.cc: In function 'int main()':
a.cc:62:6: error: storage size of 'X' isn't known
   62 | char X[];
      |      ^
a.cc:65:8: error: 'Y' was not declared in this scope
   65 |   cin>>Y;
      |        ^
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define pb push_back
#define endl "\n"
using namespace std;

int main()
{      ios_base::sync_with_stdio(false);
  
    cin.tie(0);cout.tie(0);
    string a,b;
    cin>>a>>b;
    
  ll m[3005][3005];

    for(ll i=1;i<=a.length();i++)
    {
        for(ll j=1;j<=b.length();j++)
        {
            if(a[i-1]==b[j-1])
            {
                m[i][j]=m[i-1][j-1]+1;
            }
            else
            {
                if(m[i-1][j]>=m[i][j-1])
                {
                    m[i][j]=m[i-1][j];
                }
                else m[i][j]=m[i][j-1];
            }

        }
    }ll ind =m[a.length()][b.length()];vector<char>at;ll i=a.length();ll j=b.length();
 while(i>0&&j>0  )
 {
     
     if(m[i-1][j-1]+1==m[i][j])
     {
         
         at.pb(a[i-1]);
         i--;
         j--;
         
     }
     else if(m[i][j-1]>m[i-1][j])
     {
              j--;
     
           
     }
     else
                 {
                 i--;
                     
                 }
     
     
 }
   for(auto x = at.crbegin() ; x!=at.crend() ; x++){
           cout<<*xendl;
   }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:19: error: 'xendl' was not declared in this scope; did you mean 'endl'?
   63 |            cout<<*xendl;
      |                   ^~~~~
      |                   endl
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define endl "\n"
using namespace std;

int main()
{      ios_base::sync_with_stdio(false);
  
     cin.tie(0);cout.tie(0)
    string a,b;
    cin>>a>>b;
    
  string m[3005][3005];

    for(ll i=1;i<=a.length();i++)
    {
        for(ll j=1;j<=b.length();j++)
        {
            if(a[i-1]==b[j-1])
            {
                m[i][j]=m[i-1][j-1]+a[i-1];
            }
            else
            {
                if(m[i-1][j].length()>=m[i][j-1].length())
                {
                    m[i][j]=m[i-1][j];
                }
                else m[i][j]=m[i][j-1];
            }

        }
    }
    cout<<m[a.length()][b.length()]<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:28: error: expected ';' before 'string'
   11 |      cin.tie(0);cout.tie(0)
      |                            ^
      |                            ;
   12 |     string a,b;
      |     ~~~~~~                  
a.cc:13:10: error: 'a' was not declared in this scope
   13 |     cin>>a>>b;
      |          ^
a.cc:13:13: error: 'b' was not declared in this scope
   13 |     cin>>a>>b;
      |             ^
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define endl "\n"
using namespace std;

int main()
{      ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0)
    string a,b;
    cin>>a>>b;

    char* m[3004][3004];

    for(ll i=1;i<=a.length();i++)
    {
        for(ll j=1;j<=b.length();j++)
        {
            if(a[i-1]==b[j-1])
            {
                m[i][j]=m[i-1][j-1]+a[i-1];
            }
            else
            {
                if(strlen(m[i-1][j])>=strlen(m[i][j-1]))
                {
                    m[i][j]=m[i-1][j];
                }
                else m[i][j]=m[i][j-1];
            }

        }
    }
    cout<<m[a.length()][b.length()]<<endl;


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:27: error: expected ';' before 'string'
   10 |     cin.tie(0);cout.tie(0)
      |                           ^
      |                           ;
   11 |     string a,b;
      |     ~~~~~~                 
a.cc:12:10: error: 'a' was not declared in this scope
   12 |     cin>>a>>b;
      |          ^
a.cc:12:13: error: 'b' was not declared in this scope
   12 |     cin>>a>>b;
      |             ^