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

v#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (1e3) + 3;
int memo[N][N];
string s1, s2;
int n, m;

void lcs(int n, int m) {
	for (int i = 0; i <= n; ++i) {
		memo[i][0] = 0;
	}
	for (int i = 0; i <= m; ++i) {
		memo[0][i] = 0;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s1[i-1] == s2[j-1]) {
				memo[i][j] = 1 + memo[i-1][j-1];
			} else {
				memo[i][j] = max(memo[i-1][j], memo[i][j-1]);
			}
		}
	}
}

void printLcs(int n, int m) {
	if (n == 0 or m == 0) return;
	if (s1[n-1] == s2[m-1]) {
		printLcs(n-1, m-1);
		printf("%c", s1[n-1]);
	} else {
		if (memo[n][m-1] > memo[n-1][m]) printLcs(n, m-1);
		else printLcs(n-1, m);
	}
}

int main() {
	getline(cin, s1);
	getline(cin, s2);
	int n = s1.size();
	int m = s2.size();
	lcs(n, m);
	printLcs(n, m);
	return 0;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | v#include <bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'v' does not name a type
    1 | v#include <bits/stdc++.h>
      | ^
a.cc:9:1: error: 'string' does not name a type
    9 | string s1, s2;
      | ^~~~~~
a.cc: In function 'void lcs(int, int)':
a.cc:21:29: error: 's1' was not declared in this scope
   21 |                         if (s1[i-1] == s2[j-1]) {
      |                             ^~
a.cc:21:40: error: 's2' was not declared in this scope
   21 |                         if (s1[i-1] == s2[j-1]) {
      |                                        ^~
a.cc:24:46: error: 'max' was not declared in this scope
   24 |                                 memo[i][j] = max(memo[i-1][j], memo[i][j-1]);
      |                                              ^~~
a.cc: In function 'void printLcs(int, int)':
a.cc:32:13: error: 's1' was not declared in this scope
   32 |         if (s1[n-1] == s2[m-1]) {
      |             ^~
a.cc:32:24: error: 's2' was not declared in this scope
   32 |         if (s1[n-1] == s2[m-1]) {
      |                        ^~
a.cc:34:17: error: 'printf' was not declared in this scope
   34 |                 printf("%c", s1[n-1]);
      |                 ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | v#include <bits/stdc++.h>
a.cc: In function 'int main()':
a.cc:42:17: error: 'cin' was not declared in this scope
   42 |         getline(cin, s1);
      |                 ^~~
a.cc:42:22: error: 's1' was not declared in this scope
   42 |         getline(cin, s1);
      |                      ^~
a.cc:42:9: error: 'getline' was not declared in this scope
   42 |         getline(cin, s1);
      |         ^~~~~~~
a.cc:43:22: error: 's2' was not declared in this scope
   43 |         getline(cin, s2);
      |                      ^~
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Atcoder6{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	static long INF = (Long.MAX_VALUE/2);
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int dp[][] = new int[t.length()+1][s.length()+1];
        for(int i = 0; i <= s.length(); i++)
        {
        	dp[0][i] = 0;
        }
        for(int i = 0; i <= t.length(); i++)
        {
        	dp[i][0] = 0;
        }
        
        for(int i = 1; i <= t.length(); i++)
        {
        	for(int j = 1; j <= s.length(); j++)
        	{	
        		if(s.charAt(j-1) == t.charAt(i-1))
        		{
        			dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j-1]+1);
        		}
        		else
        		{
        			dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
        		}
        	}
        }
        out.println(dp[t.length()][s.length()]);
        out.close();
	}

}


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

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

#define MAXN 3005

const int inf = 2e9+10;

struct node{

    int val;
    int px,py;

};

vector<vector<node>> dp(MAXN,vector<node>(MAXN,{-inf,0,0}));

node max(node& a,node b){
    
    return a.val>b.val?a:b;

}

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);

    dp[0][0].val=0;

    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){

        for(int j=0;j<b.size();j++){

            if(a[i] == b[j]){
                
                dp[i+1][j+1]=max(dp[i+1][j+1],{dp[i][j].val+1,i,j});
    
            }
                dp[i+1][j] = max(dp[i+1][j],{dp[i][j].val,i,j});
                dp[i][j+1] = max(dp[i][j+1],{dp[i][j].val,i,j});
        }
    } 
    node maxx = {0,0,0};

    for(int i=0;i<=a.size();i++)
        for(int j=0;j<=b.size();j++){

            maxx = max(maxx,dp[i][j]);

        }
#ifdef NOTINAIR
    cerr<<maxx.val<<endl;
#endif

    node cur = maxx;
    string ans;
    while(cur.px != 0 && cur.py!=0){

        if(a[cur.px] == b[cur.py])ans+=a[cur.px];
        cur = dp[cur.px][cur.py];

    }
     if(a[cur.px] == b[cur.py])ans+=a[cur.px];
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;



}


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

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

pair <int,int> prv[3005][3005];
int dp[3005][3005];

/*

axyb
abyxb 

*/

main()
{
	string a , b;
	cin >> a >> b;
	
	
	for(int i = 1;  i <= (int)a.size(); i++)
	{
		for(int j = 1; j <= (int)b.size(); j++)
		{
			if( a[i - 1] == b[j - 1] )
			{
				dp[i][j] = dp[i-1][j-1] + 1;
				prev[i][j] = mk(i-1 , j-1);
			}
			
			else if( dp[i-1][j] >= dp[i][j-1] )
			{
				dp[i][j] = dp[i-1][j];
				prev[i][j] = mk(i-1 , j);
			}
			else
			{
				dp[i][j] = dp[i][j-1];
				prev[i][j] = mk(i , j-1);
			}
		}
	}
	
	
	//for(int i = 1; i <= a.size(); i++)
	//{
		//for(int j = 1; j <= b.size(); j++)
		//{
			////cout << "(" << prev[i][j].first << " " << prev[i][j].second << " " << dp[i][j] << ")";
			//cout << dp[i][j] << ' ';
		//}
		//cout << endl;
	//}
	
	
	
	
	string ans = "";
	
	int i = a.size() , j = b.size();

	
	while( 1 )
	{
		if (!dp[i][j]) break;
		//cout << i << ' ' << j << ' ' << dp[i][j] << endl;
		if( dp[i-1][j-1] == dp[i][j] - 1 )
		{
			ans = a[i - 1] + ans;
			i--;
			j--;
			continue;
		}
		int I = i , J = j;
		
		i = prev[I][J].first;
		j = prev[I][J].second;
	}
		
	
	cout << ans << endl;
}


Compiler output:
a.cc:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:28:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   28 |                                 prev[i][j] = mk(i-1 , j-1);
      |                                     ^
a.cc:34:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                                 prev[i][j] = mk(i-1 , j);
      |                                     ^
a.cc:39:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   39 |                                 prev[i][j] = mk(i , j-1);
      |                                     ^
a.cc:76:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   76 |                 i = prev[I][J].first;
      |                         ^
a.cc:77:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   77 |                 j = prev[I][J].second;
      |                         ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  int sl,tl;
  sl=s.length();
  tl=t.length();
  vector<vector<string>> dp(sl+1,vector<string>(tl+1,"0"));
  for(int i=1;i<sl+1;i++)
  {
    for(int j=1;j<tl+1;j++)
    {
      if(s[i-1]==t[j-1]){string a=(dp[i-1][j-1][0]+=1)+dp[i-1][j-1].substr(1)+s[i-1];dp[i][j]=max({a,dp[i-1][j],dp[i][j-1]},[](string a,string b){return a[0]<b[0];});}
      else dp[i][j]=max({dp[i-1][j],dp[i][j-1]},[](string a,string b){return a.length()<b.length();});
      //cout<<dp[i][j]<<s[i-1]<<endl;
    }
  }
  cout<<dp[sl][tl].substr(1);

Compiler output:
a.cc: In function 'int main()':
a.cc:30:30: error: expected '}' at end of input
   30 |   cout<<dp[sl][tl].substr(1);
      |                              ^
a.cc:13:1: note: to match this '{'
   13 | {
      | ^
Language: C++

#include <iostream>  
#include <cstring>  
  
using namespace std;  
  
const int maxn = 3001;  
  
int length[maxn][maxn], word[maxn][maxn];  
string s1, s2;  
  
void print_LCS(int i, int j)  
{  
    if(i==0 || j==0) return;  
  
    if(word[i][j] == 0)  
    {  
        print_LCS(i-1, j-1);  
        cout << s1[i-1];  
    }  
    else if(word[i][j] == 1)  
    {  
        print_LCS(i, j-1);  
    }  
    else if(word[i][j] == 2)  
    {  
        print_LCS(i-1, j);  
    }  
}  
  
int main()  
{  
    ios_base::sync_with_stdio(false);  
    cin.tie(0);  
  
    cin >> s1 >> s2
      
    int n1 = s1.length(), n2 = s2.length();
    memset(word, -1, sizeof(word));  
  
    for(int i=1 ; i<=n1 ; i++)  
    {  
      for(int j=1 ; j<=n2 ; j++)  
      {  
        if(s1[i-1] == s2[j-1])  
        {  
          length[i][j] = length[i-1][j-1] + 1;  
          word[i][j] = 0; //左上  
        }  
        else if(length[i-1][j] < length[i][j-1])  
        {  
          length[i][j] = length[i][j-1];  
          word[i][j] = 1; //左  
        }  
        else  
        {  
          length[i][j] = length[i-1][j];  
          word[i][j] = 2; //右  
        }  
      }
    }
    print_LCS(n1, n2); cout << '\n';
      
    return 0 ;  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:20: error: expected ';' before 'int'
   35 |     cin >> s1 >> s2
      |                    ^
      |                    ;
   36 | 
   37 |     int n1 = s1.length(), n2 = s2.length();
      |     ~~~             
a.cc:40:22: error: 'n1' was not declared in this scope; did you mean 's1'?
   40 |     for(int i=1 ; i<=n1 ; i++)
      |                      ^~
      |                      s1
a.cc:42:24: error: 'n2' was not declared in this scope; did you mean 's2'?
   42 |       for(int j=1 ; j<=n2 ; j++)
      |                        ^~
      |                        s2
a.cc:61:15: error: 'n1' was not declared in this scope; did you mean 's1'?
   61 |     print_LCS(n1, n2); cout << '\n';
      |               ^~
      |               s1
a.cc:61:19: error: 'n2' was not declared in this scope; did you mean 's2'?
   61 |     print_LCS(n1, n2); cout << '\n';
      |                   ^~
      |                   s2
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

string a,b;
int DP[3003][3003];

int

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>b;

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

    string ats;
    int r = a.size();
    int c = b.size();

    while(r > 0 && c > 0)
    {
        if(a[r-1]==b[c-1])
            ats+=a[r-1],r--,c--;
        else if(DP[r-1][c]==DP[r][c])r--;
        else c--;
    }

    reverse(ats.begin(),ats.end());
    cout<<ats;
}


Compiler output:
a.cc:10:1: error: two or more data types in declaration of 'main'
   10 | int
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

string a,b;
int DP[3003][3003];

int

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>b;

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

    string ats;
    int r = a.size();
    int c = b.size();

    while(DP[r][c])
    {
        if(DP[r-1][c-1]+1==DP[r][c])
            ats+=a[r-1],r--,c--;
        else if(DP[r-1][c]==DP[r][c])r--;
        else c--;
    }

    reverse(ats.begin(),ats.end());
    cout<<ats;
}


Compiler output:
a.cc:10:1: error: two or more data types in declaration of 'main'
   10 | int
      | ^~~
Language: C++

#include<iostream>
using namespace std;
int main()
{
	int n1,n2;
	string s,t;
	cin>>s>>t;
	n1=s.length();
	n2=t.length();
	int dp[n1+1][n2+1],to[n1+1][n2+1];
	for(int i=0;i<=n1;i++){
		for(int j=0;j<=n2;j++){
			if(i==0||j==0)dp[i][j]=0;
			else{
				dp[i][j]=dp[i-1][j];
				to[i][j]=1;
				if(dp[i][j]<dp[i][j-1]){dp[i][j]=dp[i][j-1];to[i][j]=2;}
				if(s[i-1]==t[j-1])
				if(dp[i][j]<1+dp[i-1][j-1]){
					dp[i][j]=1+dp[i-1][j-1];
					to[i][j]=3;
					//cout<<i<<" "<<j<<"\n";
				}
			}
			//cout<<to[i][j]<<" ";
		}
		//cout<<"\n";
	}
	string res;
	int i=n1,j=n2;
	while(i>0&&j>0){
		if(to[i][j]==3){
			i--;
			j--;
			res+=s[i];
		}
		else if(to[i][j]==2){
			j--;
		}
		else i--;
	}
	reverse(res.begin(),res.end());
	cout<<res;
}

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

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

int dp[3002][3002];
string s, t;

int solve(int x, int y) {
	if(x == s.size() || y == t.size()) return 0;
	int &ret = dp[x][y];
	if(ret != -1) return ret;
	if(s[x] == t[y]) ret = solve(x+1, y+1) + 1;
	else {
		ret = max(solve(x+1, y), solve(x, y+1));
	}
	return ret;
}

string ans;
void build(int x, int y) {axyb
abyxb

	if(x == s.size() || y == t.size()) return;
	if(s[x] == t[y]) {
		ans.push_back(s[x]);
		build(x+1, y+1);
	}
	else {
		if(solve(x+1, y) >= solve(x, y+1)) build(x+1, y);
		else build(x, y+1);
	}
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin>>s>>t;
	int temp = solve(0, 0);
	build(0, 0);
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'void build(int, int)':
a.cc:20:27: error: 'axyb' was not declared in this scope
   20 | void build(int x, int y) {axyb
      |                           ^~~~
Language: C++

/******************************************
* AUTHOR : SARTHAK GUPTA *
* NICK : SOPHOZAAR *
* INSTITUTION : BIT MESRA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

string longest = "";


int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
string s1, s2;
cin >> s1 >> s2;

int m = s1.length();
int n = s2.length();

int dp[m + 1][n + 1];

for(int i = 0; i <= m; i++) {
	for(int j = 0; j <= n; j++) {
		dp[i][j] = 0;
	}
}

// LCS
for(int i = 1; i <= m; i++) {
	for(int j = 1; j <= n; j++) {

		if(s1[i - 1] == s2[j - 1]) {
			dp[i][j] = 1 + dp[i - 1][j - 1];
		}
		else {
			dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
		}
	}
}

int i = m;
int j = n;

int len = dp[m][n];


while(i >= 1 && j >= 1) {
	if(longest.size() == len)
		break;

	if(s1[i - 1] == s2[j - 1) {
		longest = s1[i - 1] + longest;
		i--;
		j--;
	}

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

cout << longest << "\n";


return 0;
}	

Compiler output:
a.cc: In function 'int main()':
a.cc:66:33: error: expected ']' before ')' token
   66 |         if(s1[i - 1] == s2[j - 1) {
      |                                 ^
      |                                 ]
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
int main()
{
  string s, t;
  cin >> s >> t;
  int ls = s.length(), lt = t.length();
  int dp[lt+1][ls+1] = {0};
  for (int i = 1; i < lt+1; ++i) {
    for (int j = 1; j < ls+1; ++j) {
      if(t[i-1] == s[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 {
          dp[i][j] = dp[i][j-1];
        }
      }
    }
  }
  int i = lt, j = ls;
  string ans = "";
  while (i > 0 && j > 0) {
    if (t[i-1] == s[j-1]) {
      ans += t[i-1];
      i--; j--;
    }else {
      if (dp[i-1][j] > dp[i][j-1]) {
        i--;
      }else {
        j--;
      }
    }
  }
  if (ans == "") {
    cout << '' << "\n";
  }else {
    reverse(all(ans));
    cout << ans << "\n";
  }
  return 0;
}

Compiler output:
a.cc:44:13: error: empty character constant
   44 |     cout << '' << "\n";
      |             ^~
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
int main()
{
  string s, t;
  cin >> s >> t;
  int ls = s.length(), lt = t.length();
  int dp[lt+1][ls+1] = {0};
  for (int i = 1; i < lt+1; ++i) {
    for (int j = 1; j < ls+1; ++j) {
      if(t[i-1] == s[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 {
          dp[i][j] = dp[i][j-1];
        }
      }
    }
  }
  int i = lt, j = ls;
  string ans = "";
  while (i > 0 && j > 0) {
    if (t[i-1] == s[j-1]) {
      ans += t[i-1];
      i--; j--;
    }else {
      if (dp[i-1][j] > dp[i][j-1]) {
        i--;
      }else {
        j--;
      }
    }
  }
  if (ans == "") {
    cout << "" << "\n";
  }else {
    reverse(all(ans));
    commentut << ans << "\n";
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:5: error: 'commentut' was not declared in this scope
   47 |     commentut << ans << "\n";
      |     ^~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int strlen(char s[60000]){
	int i;
	for(i=0;s[i]!=NULL;i++);
	return i;
}
int lcs(char a[60000],char b[60000], int m, int n){
	const int s=m+1;
	const int t=n+1;
	int l[s][t];
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(!(i*j)){
				l[i][j]=0;
			}
			else{
				if(a[i-1]==b[j-1]){
					l[i][j]=l[i-1][j-1]+1;
				}
				else{
					l[i][j]=max(l[i-1][j],l[i][j-1]);
				}
			}
		}
	}
	return l[m][n];
}

int main(){
	int m,n,f;
	char a[60000],b[60000];
	gets(a);
	gets(b);
	m=strlen(a);
	n=strlen(b);
	f=lcs(a,b,m,n);
	cout<<f;
	return 0;
}


Compiler output:
a.cc: In function 'int strlen(char*)':
a.cc:5:23: warning: NULL used in arithmetic [-Wpointer-arith]
    5 |         for(i=0;s[i]!=NULL;i++);
      |                       ^~~~
a.cc: In function 'int main()':
a.cc:33:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   33 |         gets(a);
      |         ^~~~
      |         getw
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using std::max;

int LCS(char* s1, char* s2,char *res)
{
    int i,j,M,N,k=0,upbd;
    M=strlen(s1);
    N=strlen(s2);
    int **dp;
    dp=new int* [M+2];
    for(i=0;i<M+2;i++)
        dp[i]=new int [N+2];
    for(i=0;i<N+2;i++)
        dp[0][i]=0;
    
    for(i=1;i<M+1;i++)
    {
        dp[i][0]=0;
        for(j=1;j<N+1;j++)
        {
            if(s1[i-1]==s2[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    k=dp[M][N];

    i=M;
    j=N;
    upbd=k;
    res[k]='\0';
    while(i>0 && j>0)
    {
        if(dp[i-1][j]==dp[i-1][j-1] && dp[i-1][j-1]==dp[i][j-1] )
        {
            if (dp[i][j]==dp[i-1][j-1]+1)
                res[--upbd]=s1[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]==dp[i][j])
                i--;
            else
                j--;
        }
    }
    for(i=0;i<M+2;i++)
        delete [] dp[i];
    delete [] dp;

    return k;
}

#define MAXLENGTH 3003
int main(void)
{
    char s[MAXLENGTH],t[MAXLENGTH],r[MAXLENGTH];
    scanf("%s%s",s,t)
    LCS(s,t,r);
    printf("%s\n",r);
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:63:22: error: expected ';' before 'LCS'
   63 |     scanf("%s%s",s,t)
      |                      ^
      |                      ;
   64 |     LCS(s,t,r);
      |     ~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

string s, t;
vector<vector<int>> memo;

// s[i, ), t[j, ) の共通部分列で最大のサイズを求める
int Solve(size_t i, size_t j) {
    if (s.size() <= i || t.size() <= j) return memo[i][j] = 0;
    if (memo[i][j] != -1) return memo[i][j];

    int res = 0;
    if (s[i] == t[j]) {
        res = 1 + Solve(i + 1, j + 1);
        sol[i][j] = (int)(s[i] - 'a');
    }
    else res = max(Solve(i + 1, j), Solve(i, j + 1));

    return memo[i][j] = res;
}

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

    cin >> s >> t;
    memo.resize(s.size() + 1, vector<int>(t.size() + 1, -1));

    Solve(0, 0);
    string ans;
    for (size_t i = 0, j = 0; i < s.size() && j < t.size(); ) {
        if (s[i] == t[j]) { ans += s[i]; ++i; ++j; }
        else if (memo[i + 1][j] < memo[i][j + 1]) ++j;
        else ++i;
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int Solve(size_t, size_t)':
a.cc:18:9: error: 'sol' was not declared in this scope
   18 |         sol[i][j] = (int)(s[i] - 'a');
      |         ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
char s1[3005],s2[3005];
int la1[3005][3005],la2[3005][3005];
int main(){
	scanf("%s%s",s1,s2);
	int len1=strlen(s1),len2=strlen(s2);
	bool flag=0;
	dp[0][0]=(s1[0]==s2[0]);
	la1[0][0]=-1;la2[0][0]=-1;
	for(int i=0;i<len2;i++){
		if(s1[0]==s2[i]){
			dp[0][i]=1;
			la1[0][i]=-1;
			la2[0][i]=i-1
		}
		else{
			la1[0][i]=0;
			la2[0][i]=i-1;
			dp[0][i]=dp[0][i-1];
		}
	}
	for(int i=1;i<len1;i++){
		if(s1[i]==s2[0]){
			dp[i][0]=1;
			la1[i][0]=i-1;
			la2[i][0]=-1;
		}
		else{
			dp[i][0]=dp[i-1][0];
			la1[i][0]=i-1;
			la2[i][0]=0;
		}
		for(int j=1;j<len2;j++){
			dp[i][j]=dp[i][j-1];
			la1[i][j]=i;la2[i][j]=j-1;
			if(dp[i][j]<dp[i-1][j]){
				la1[i][j]=i-1;
				la2[i][j]=j;
				dp[i][j]=dp[i-1][j];
			}
			if(dp[i][j]<dp[i-1][j-1]+(s1[i]==s2[j])){
				la1[i][j]=i-1;
				la2[i][j]=j-1;
				dp[i][j]=dp[i-1][j-1]+(s1[i]==s2[j]);
			}
		}
	}
	string s;
	int x=len1-1,y=len2-1;
	while((~x)&&(~y)){
		if(la1[x][y]==x-1&&la2[x][y]==y-1){
			s+=s1[x];
			x=x-1;
			y=y-1;
		}
		else{
			int tx=la1[x][y],ty=la2[x][y];
			x=tx,y=ty;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:38: error: expected ';' before '}' token
   16 |                         la2[0][i]=i-1
      |                                      ^
      |                                      ;
   17 |                 }
      |                 ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[3003][3003];
string s,t;
pair<int,int>p[3003][3003];
bool vis[26];
int dfs(int ss,int ts){
	if(dp[ss][ts])return dp[ss][ts];
	int a=0,mx=0;
	memset(0,vis,sizeof(vis));
	p[ss][ts]=make_pair(-1,-1);
	for(int i=ss;i>0;i--)
		if(!vis[s[i-1]-'a'])
		{
			vis[s[i-1]-'a']=1;
			for(int j=ts;j>mx;j--)
				if(s[i-1]==t[j-1])
				{
					if(dp[ss][ts]<dfs(i-1,j-1)+1)
						dp[ss][ts]=dp[i-1][j-1],
						p[ss][ts]=make_pair(i-1,j-1);
					mx=max(mx,j);
				}
		}
	return dp[ss][ts];
}
void out(pair<int,int>x){
	if(x.first==-1&&x.second==-1)return;
	out(p[x.first][x.second]);
	if(x.first!=s.size())cout<<s[x.first];
}
int main(){
	cin>>s>>t;
	dfs(s.size(),t.size());
	out(make_pair(s.size(),t.size()));
}


Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:10:18: error: invalid conversion from 'bool*' to 'int' [-fpermissive]
   10 |         memset(0,vis,sizeof(vis));
      |                  ^~~
      |                  |
      |                  bool*
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:61:37: note:   initializing argument 2 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                                 ~~~~^~~
Language: C++

#include <bits/stdc++.h>


using namespace std;

string l,s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    getline(cin,s);
    getline(cin,t);
    cin >> l;
    cin >> s;
    int sL=l.length(),sS=s.length();
    int dp[sL][sS];
    for (int i = 0; i <= sL; i ++)
    {
        dp[i][0]=0;
    }
    for (int i = 0; i <= sS; i++)
    {
        dp[0][i]=0;
    }

    for (int i = 1; i <= sL ; i++)
        for (int j = 1; j <= sS ; j++)
        {
            if (l[i-1] == s[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }

    int x = sL, y = sS;
    string kq="";
    while (x > 0 && y > 0)
    {
        if (l[x-1]==s[y-1])
        {
            kq=s[y-1]+kq;
            x--;
            y--;
        }
        else
        if (dp[x][y] = dp[x-1][y])
        {
                x--;
        }
        else

        {
            y--;
        }
    }
    cout << kq ;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 't' was not declared in this scope; did you mean 'tm'?
   14 |     getline(cin,t);
      |                 ^
      |                 tm
Language: C++

#include <bits/stdc++.h>


using namespace std;

string l,s;

int main()
{
    cin >> l;
    cin >> s;
    int sL=l.length(),sS=s.length();
    int dp[sL][sS];
    for (int i = 0; i <= n; i ++)
    {
        dp[i][0]=0;
    }
    for (int i = 0; i <= m; i++)
    {
        dp[0][i]=0;
    }

    for (int i = 1; i <= sL ; i++)
        for (int j = 1; j <= sS ; j++)
        {
            if (l[i-1] == s[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else 
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }

    int x = sL, y = sS;
    string kq="";
    while (x > 0 && y > 0)
    {
        if (l[x-1]==s[y-1])
        {
            kq=s[y-1]+kq;
            x--;
            y--;
        }
        else
        if (dp[x][y] = dp[x-1][y])
        {
                x--;
        }
        else

        {
            y--;
        }
    }
    cout << kq ;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:26: error: 'n' was not declared in this scope
   14 |     for (int i = 0; i <= n; i ++)
      |                          ^
a.cc:18:26: error: 'm' was not declared in this scope
   18 |     for (int i = 0; i <= m; i++)
      |                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<char> f[3001][3001];
int g[3001][3001];
char s[3001],t[3001];
int main()
{
	int i,j,len_s,len_t;
	scanf("%s",s);

	scanf("%s",t);

	len_s=strlen(s);
	len_t=strlen(t);
	for(i=1;i<=len_s;i++)
	{
		for(j=1;j<=len_t;j++)
		{
			if(g[i-1][j]>g[i][j-1])
			{
				f[i][j].assign(f[i-1][j].begin(), f[i-1][j].end());
				g[i][j]=g[i-1][j];
			}
			else
			{
				f[i][j].assign(f[i][j-1].begin(), ff[i][j-1].end());
				g[i][j]=g[i][j-1];
			}
			if(s[i-1]==t[j-1])
			{
				f[i][j].push_back(s[i-1]);
				g[i][j]=g[i-1][j-1]+1;
			}
		}
	}
	printf("%s",f[len_s][len_t].data());
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:67: error: 'ff' was not declared in this scope; did you mean 'ffs'?
   26 |                                 f[i][j].assign(f[i][j-1].begin(), ff[i][j-1].end());
      |                                                                   ^~
      |                                                                   ffs
Language: C++

#include<bits/stdc++.h>
using namespace std;
string f[3001][3001];
int g[3001][3001]
char s[3001],t[3001];
int main()
{
	int i,j,len_s,len_t;
	scanf("%s",s);

	scanf("%s",t);

	len_s=strlen(s);
	len_t=strlen(t);
	for(i=1;i<=len_s;i++)
	{
		for(j=1;j<=len_t;j++)
		{
			if(s[i-1]==t[j-1])
			{
				f[i][j]=f[i-1][j-1]+s[i-1];
				g[i][j]=g[i-1][j-1]+1;
			}
			else
			{
				if(g[i-1][j]>g[i][j-1])
				{
					f[i][j]=f[i-1][j];
					g[i][j]=g[i-1][j];
				}
				else
				{
					f[i][j]=f[i][j-1];
					g[i][j]=g[i][j-1];
				}
			}
		}
	}
	printf("%s",f[len_s][len_t].c_str());
	return 0;
}

Compiler output:
a.cc:5:1: error: expected initializer before 'char'
    5 | char s[3001],t[3001];
      | ^~~~
a.cc: In function 'int main()':
a.cc:9:20: error: 's' was not declared in this scope
    9 |         scanf("%s",s);
      |                    ^
a.cc:11:20: error: 't' was not declared in this scope
   11 |         scanf("%s",t);
      |                    ^
a.cc:22:33: error: 'g' was not declared in this scope
   22 |                                 g[i][j]=g[i-1][j-1]+1;
      |                                 ^
a.cc:26:36: error: 'g' was not declared in this scope
   26 |                                 if(g[i-1][j]>g[i][j-1])
      |                                    ^
Language: C++

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
const ul N=3001;
string s,t,ans;
ul dp[N][N],i,j;
inline void solve(){
  IN2(s,t);
  REP(i,s.size()){
    REP(j,t.size()){
      if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
    }
  }
  i=s.size();j=t.size();
  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;
    }
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Compiler output:
a.cc:22:7: error: 'ul' does not name a type
   22 | const ul N=3001;
      |       ^~
a.cc:24:1: error: 'ul' does not name a type
   24 | ul dp[N][N],i,j;
      | ^~
a.cc: In function 'void solve()':
a.cc:27:7: error: 'i' was not declared in this scope
   27 |   REP(i,s.size()){
      |       ^
a.cc:7:25: note: in definition of macro 'FOR'
    7 | #define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
      |                         ^
a.cc:27:3: note: in expansion of macro 'REP'
   27 |   REP(i,s.size()){
      |   ^~~
a.cc:28:9: error: 'j' was not declared in this scope
   28 |     REP(j,t.size()){
      |         ^
a.cc:7:25: note: in definition of macro 'FOR'
    7 | #define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
      |                         ^
a.cc:28:5: note: in expansion of macro 'REP'
   28 |     REP(j,t.size()){
      |     ^~~
a.cc:29:21: error: 'dp' was not declared in this scope; did you mean 'dup'?
   29 |       if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
      |                     ^~
      |                     dup
a.cc:30:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   30 |       dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
      |       ^~
      |       dup
a.cc:34:3: error: 'i' was not declared in this scope
   34 |   i=s.size();j=t.size();
      |   ^
a.cc:34:14: error: 'j' was not declared in this scope
   34 |   i=s.size();j=t.size();
      |              ^
a.cc:36:8: error: 'dp' was not declared in this scope; did you mean 'dup'?
   36 |     if(dp[i][j]==dp[i-1][j])--i;
      |        ^~
      |        dup
Language: C++

#include<bits/stdc++.h>
using namespace std;
string f[3001][3001],s,t;
int len_s,len_t;
char tmp[3001];
int main()
{
	scanf("%s",tmp);
	s=tmp;
	scanf("%s",tmp);
	t=tmp;
	len_s=s.length();
	len_t=t.length();
	for(i=1;i<=len_s;i++)
	{
		for(j=1;j<=len_t;j++)
		{
			if(s[i-1]==t[i-1])
			{
				f[i][j]=f[i-1][j-1]+s.substr(i-1,1);		
			}
			else
			{
				if(f[i-1][j].length()>f[i][j-1].length())
					f[i][j]=f[i-1][j];
				else
					f[i][j]=f[i][j-1];
			}
		} 
	}
	printf("%s",f[i][j]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'i' was not declared in this scope
   14 |         for(i=1;i<=len_s;i++)
      |             ^
a.cc:16:21: error: 'j' was not declared in this scope
   16 |                 for(j=1;j<=len_t;j++)
      |                     ^
a.cc:31:23: error: 'i' was not declared in this scope
   31 |         printf("%s",f[i][j]);
      |                       ^
a.cc:31:26: error: 'j' was not declared in this scope
   31 |         printf("%s",f[i][j]);
      |                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
string f[3001][3001],s,t;
char tmp[3001];
int  len_s,len_t,g[3001]={0};
int main()
{
	scanf("%s",tmp);
	s=tmp;
	scanf("%s",tmp);
	t=tmp;
	len_s=s.length();
	len_t=t.length();
	for(int i=1;i<=len_s;i++)
	{
		for(int j=1;j<=len_t;j++)
		{
			if(s[i-1]==t[i-1])
			{
				f[i][j]=f[i-1][j-1]+s.substr(i-1,1);
				g[i][j]=g[i-1][j-1]+1;
			}
			else
			{
				if(g[i-1][j]>g[i][j-1])
				{
					f[i][j]=f[i-1][j];
					g[i][j]=g[i-1][j];
				}
				else
				{
					f[i][j]=f[i][j-1];
					g[i][j]=g[i][j-1];
				}
			}
		}
	}
	printf("%s",f[len_s][len_t].c_str());
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:37: error: invalid types 'int[int]' for array subscript
   21 |                                 g[i][j]=g[i-1][j-1]+1;
      |                                     ^
a.cc:21:47: error: invalid types 'int[int]' for array subscript
   21 |                                 g[i][j]=g[i-1][j-1]+1;
      |                                               ^
a.cc:25:42: error: invalid types 'int[int]' for array subscript
   25 |                                 if(g[i-1][j]>g[i][j-1])
      |                                          ^
a.cc:25:50: error: invalid types 'int[int]' for array subscript
   25 |                                 if(g[i-1][j]>g[i][j-1])
      |                                                  ^
a.cc:28:45: error: invalid types 'int[int]' for array subscript
   28 |                                         g[i][j]=g[i-1][j];
      |                                             ^
a.cc:28:55: error: invalid types 'int[int]' for array subscript
   28 |                                         g[i][j]=g[i-1][j];
      |                                                       ^
a.cc:33:45: error: invalid types 'int[int]' for array subscript
   33 |                                         g[i][j]=g[i][j-1];
      |                                             ^
a.cc:33:53: error: invalid types 'int[int]' for array subscript
   33 |                                         g[i][j]=g[i][j-1];
      |                                                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
string f[3001][3001];
char tmp[3001];
int  len_s,len_t,g[3001]={0};
int main()
{
	scanf("%s",tmp);
	s=tmp;
	scanf("%s",tmp);
	t=tmp;
	len_s=s.length();
	len_t=t.length();
	for(int i=1;i<=len_s;i++)
	{
		for(j=1;j<=len_t;j++)
		{
			if(s[i-1]==t[i-1])
			{
				f[i][j]=f[i-1][j-1]+s.substr(i-1,1);
				g[i][j]=g[i-1][j-1]+1;
			}
			else
			{
				if(g[i-1][j]>g[i][j-1])
				{
					f[i][j]=f[i-1][j];
					g[i][j]=g[i-1][j];
				}
				else
				{
					f[i][j]=f[i][j-1];
					g[i][j]=g[i][j-1];
				}
			}
		}
	}
	printf("%s",f[len_s][len_t].c_str());
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 's' was not declared in this scope
    9 |         s=tmp;
      |         ^
a.cc:11:9: error: 't' was not declared in this scope; did you mean 'tm'?
   11 |         t=tmp;
      |         ^
      |         tm
a.cc:16:21: error: 'j' was not declared in this scope
   16 |                 for(j=1;j<=len_t;j++)
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
string f[3001][3001],s,t;
char tmp[3001];
int g[3001][3001];
int main()
{
	int i,j,len_s,len_t;
	scanf("%s",tmp);
	s=tmp;
	scanf("%s",tmp);
	t=tmp;
	len_s=s.length();
	len_t=t.length();
	for(i=1;i<=len_s;i++)
	{
		for(j=1;j<=len_t;j++)
		{
			if(s[i-1]==t[j-1])
			{
				f[i][j]=f[i-1][j-1]+s.substr(i-1,1);
				g[i][j]=g[i-1][j-1]+1;
			}
			else
			{
				if(g[i-1][j]>g[i][j-1])
				{
					f[i][j]=f[i-1][j];
					g[i][j]=g[i-1][j];
				}
				else
				{
					f[i][j]=f[i][j-1];
					g[i][j]=f[i][j-1];
				}
			}
		}
	}
	printf("%s",f[len_s][len_t].c_str());
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:57: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in assignment
   34 |                                         g[i][j]=f[i][j-1];
      |                                                 ~~~~~~~~^
      |                                                         |
      |                                                         std::string {aka std::__cxx11::basic_string<char>}
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( string X, string 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] = ''; // 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,Y;
  cin >> X >> Y;
  int m = X.length(); 
  int n = Y.length(); 
  lcs(X, Y, m, n); 
  return 0; 
} 

Compiler output:
a.cc:32:17: error: empty character constant
   32 |    lcs[index] = ''; // Set the terminating character
      |                 ^~
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( string X, string 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] = ''; // 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,Y;
  cin >> X >> Y;
  int m = strlen(X); 
  int n = strlen(Y); 
  lcs(X, Y, m, n); 
  return 0; 
} 

Compiler output:
a.cc:32:17: error: empty character constant
   32 |    lcs[index] = ''; // Set the terminating character
      |                 ^~
a.cc: In function 'int main()':
a.cc:64:18: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   64 |   int m = strlen(X);
      |                  ^
      |                  |
      |                  std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 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:65:18: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   65 |   int n = strlen(Y);
      |                  ^
      |                  |
      |                  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)
      |                       ~~~~~~~~~~~~^~~
Language: C++

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

int dp[3005][3005];

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < t.size(); j++){
      if(s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      dp[i + 1][j + 1] = max({dp[i][j + 1], dp[i + 1][j], dp[i + 1][j + 1]});
    }
  }

  string ans = "";
  int x = s.size(), y = t.size();
  while(dp[x][y]){
    while(dp[x][y] == dp[x - 1][y]) x--;
    while(dp[x][y] == dp[x][y - 1]) y--;
    x--, y--;
    ans += s[x];
  }
  
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:11: error: 'all' was not declared in this scope
   28 |   reverse(all(ans));
      |           ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
  int n,i,j,m;
  cin>>a>>b;
  n = a.length();
  m = b.length();
  vector<vector<int>>dp(n,vector<int>(m,0));
  for(i=0;i<n;i++){
    if(a[i] == b[0])
      dp[i][0] = 1;
  	else dp[i][0] = 0;
  }
  for(i=0;i<m;i++){
    if(a[0] == b[i])
      dp[0][i] = 1;
  	else dp[0][i] = 0;
  }
  for(i=1;i<n;i++){
    for(j=1;j<n;j++){
      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]);
    }
  }
  cout<<dp[n-1][m-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: 'a' was not declared in this scope
    7 |   cin>>a>>b;
      |        ^
a.cc:7:11: error: 'b' was not declared in this scope
    7 |   cin>>a>>b;
      |           ^
Language: C

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

typedef long long ll;

const int MAXN = 3e3 + 5;
const int INF = 0x3f3f3f3f;

int n, m, d[MAXN][MAXN] = {0};
char s[MAXN], t[MAXN], ans[MAXN];
int cnt = 0;

void backtrace(int i, int j) {
    if (i == 0 || j == 0) return;
    if (d[i][j] == d[i - 1][j - 1] + 1) {
        backtrace(i - 1, j - 1);
        putchar(s[i]);
    }
    else if (d[i][j] == d[i - 1][j]) backtrace(i - 1, j);
    else backtrace(i, j - 1);
}

int main() {
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            if (s[i] == t[j]) {
                d[i][j] = d[i - 1][j - 1] + 1;
            }
            else {
                d[i][j] = max(d[i - 1][j], d[i][j - 1]);
            }
        }
    backtrace(n, m);
    return 0;
}


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

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

typedef long long ll;

const int MAXN = 3e3 + 5;
const int INF = 0x3f3f3f3f;

int n, m, d[MAXN][MAXN] = {0};
char s[MAXN], t[MAXN], ans[MAXN];
int cnt = 0;

void backtrace(int i, int j) {
    if (i == 0 || j == 0) return;
    if (d[i][j] == d[i - 1][j - 1] + 1) {
        backtrace(i - 1, j - 1);
        putchar(s[i]);
    }
    else if (d[i][j] == d[i - 1][j]) backtrace(i - 1, j);
    else backtrace(i, j - 1);
}

int main() {
    gets(s + 1);
    gets(t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            //printf("%d, %d: %c %c\n", i, j, s[i - 1], t[j - 1]);
            if (s[i] == t[j]) {
                d[i][j] = d[i - 1][j - 1] + 1;
            }
            else {
                d[i][j] = max(d[i - 1][j], d[i][j - 1]);
            }
        }
    backtrace(n, m);
    return 0;
}


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