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

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[3300][3300];

int main(){cout<<fixed<<setprecision(10);
		   string s,t;
           cin>>s>>t;
           int n=s.size(),m=t.size();
           rep(i,1,n+1){
            rep(j,1,m+1){
             chmax(dp[i][j],dp[i-1][j]);
             chmax(dp[i][j],dp[i][j-1]);
             if(s[i-1]==t[j-1])chmax(dp[i][j],dp[i-1][j-1]+1); 
            }
           }
           //cout<<dp[n][m]<<endl;
           string ans="";
           while(n>=1&&m>=1){
             
               if(dp[n][m]==dp[n-1][m-1]+1){
                 ans=ans+s[n-1]+;
                 n--;m--;
               }
               else if(dp[n][m]==dp[n][m-1]){
                 m--;
               }
               else{
                 n--;
               }
           }
           cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:33: error: expected primary-expression before ';' token
   40 |                  ans=ans+s[n-1]+;
      |                                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAX 3000;
int dp[MAX+1][MAX+1];
int lenLCS(string& s, string& t, int i, int j)
{
  if(i>s.length() || j>t.length())
    return 0;
  if(dp[i][j]!=-1)
    return dp[i][j];
  if(s[i]==s[j])
    return dp[i][j]=lenLCS(s,t,i+1,j+1);
  else{
    return dp[i][j]=max(lenLCS(s,t,i+1,j),lenLCS(s,t,i,j+1));
  }
}
string lcs(string& s, string& t, int len){
  string lcsS="";
  int i=0,j=0;
  while(len>0){
    if(s[i]==t[j]){
      lcsS+=s[i];
      i++;
      j++;
      len--;
    }
    else{
      if(dp[i+1][j]>dp[i][j+1])
        i++;
      else j++;
    }
  }
   return lcsS;
}
int main()
{
  string s,t;
  cin>>s>>t;
  memset(dp,-1,sizeof dp);
  int len=lenLCS(s,t,0,0);
  cout<<lcs(s,t,len);
  
  return 0;
}

Compiler output:
a.cc:3:17: error: expected ']' before ';' token
    3 | #define MAX 3000;
      |                 ^
a.cc:4:8: note: in expansion of macro 'MAX'
    4 | int dp[MAX+1][MAX+1];
      |        ^~~
a.cc:4:11: error: expected unqualified-id before '+' token
    4 | int dp[MAX+1][MAX+1];
      |           ^
a.cc:4:18: error: expected unqualified-id before '+' token
    4 | int dp[MAX+1][MAX+1];
      |                  ^
a.cc: In function 'int lenLCS(std::string&, std::string&, int, int)':
a.cc:9:6: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |   if(dp[i][j]!=-1)
      |      ^~
      |      dup
a.cc:12:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 |     return dp[i][j]=lenLCS(s,t,i+1,j+1);
      |            ^~
      |            dup
a.cc:14:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
   14 |     return dp[i][j]=max(lenLCS(s,t,i+1,j),lenLCS(s,t,i,j+1));
      |            ^~
      |            dup
a.cc: In function 'std::string lcs(std::string&, std::string&, int)':
a.cc:28:10: error: 'dp' was not declared in this scope; did you mean 'dup'?
   28 |       if(dp[i+1][j]>dp[i][j+1])
      |          ^~
      |          dup
a.cc: In function 'int main()':
a.cc:39:10: error: 'dp' was not declared in this scope; did you mean 'dup'?
   39 |   memset(dp,-1,sizeof dp);
      |          ^~
      |          dup
Language: Java

import java.util.*

public class Main{

	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        Lcs(s.toCharArray(),t.toCharArray());
    }
    
		public static void Lcs(char[] s, char[] t) {
			int[][] dp = new int[s.length+1][t.length+1];	
			 helper(s,t,dp,s.length,t.length);
			 StringBuilder sb = new StringBuilder("");
			 dfs(dp,s,t,s.length,t.length,sb);
			 System.out.println(sb);
		}
	
		private static void dfs(int[][] dp, char[] s, char[] t, int i, int j,StringBuilder result) {
	
			if(i==0||j==0)return;
			if(s[i-1]==t[j-1]) {
				 dfs(dp,s,t,i-1,j-1,result);
				result.append(s[i-1]);
				return;
			}
			if(dp[i-1][j]==dp[i][j]) {
				 dfs(dp,s,t,i-1,j,result);
				 return;
			}else {
				dfs(dp,s,t,i,j-1,result);
				return;
			}
		}
	
		private static int helper(char[] s, char[] t, int[][] dp, int i, int j) {
			
			if(i==0 || j==0) {
				return 0;
			}
			if(dp[i][j]!=0) {
				return dp[i][j];
			}
			
			if(s[i-1]==t[j-1]) {
				dp[i][j]=  1+ helper(s,t,dp,i-1,j-1);
	
			}
			else {
				dp[i][j]= Math.max(helper(s,t,dp,i-1,j), helper(s,t,dp,i,j-1));
			}
			return dp[i][j];
			
		}

}


Compiler output:
Main.java:1: error: ';' expected
import java.util.*
                  ^
1 error
Language: Java

import java.util.*

public class Main{

	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        Lcs(s.toCharArray(),t.toCharArray());
    }
    
    public static void Lcs(char[] s, char[] t) {
		int[][] dp = new int[s.length+1][t.length+1];
		 int x = helper(s,t,dp,s.length,t.length);
		 System.out.println(dfs(dp,s,t,s.length,t.length));
	}

	private static String dfs(int[][] dp, char[] s, char[] t, int i, int j) {

		if(i==0||j==0)return "";
		if(s[i-1]==t[j-1]) {
			return dfs(dp,s,t,i-1,j-1)+s[i-1];
		}
		if(dp[i-1][j]==dp[i][j]) {
			return dfs(dp,s,t,i-1,j);
		}else {
			return dfs(dp,s,t,i,j-1);
		}
	}

	private static int helper(char[] s, char[] t, int[][] dp, int i, int j) {
		// if i==0 || j==0 return 0
		// if( s[i]==t[i]) return helper(s,t,dp, i-1,j-1)
	    // else return max(helper(s,t,dp,i+1,j), helper(s,t,dp,i,j+1)
		
		if(i==0 || j==0) {
			return 0;
		}
		if(dp[i][j]!=0) {
			return dp[i][j];
		}
		
		if(s[i-1]==t[j-1]) {
			dp[i][j]=  1+ helper(s,t,dp,i-1,j-1);

		}
		else {
			dp[i][j]= Math.max(helper(s,t,dp,i-1,j), helper(s,t,dp,i,j-1));
		}
		return dp[i][j];
		
	}

}

Compiler output:
Main.java:1: error: ';' expected
import java.util.*
                  ^
1 error
Language: C++

#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

const int MAX_N = 3000 + 1;
int dp[MAX_N][MAX_N];
char s[MAX_N], t[MAX_N];

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

  string s_, t_;
  cin >> s_ >> t_;

  int N, M;
  N = s_.size();
  M = t_.size();

  for (int i = 1; i <= N; i++) s[i] = s_[i-1];
  for (int i = 1; i <= M; i++) t[i] = t_[i-1];
  
  for (int j = 0; j < N; j++) dp[0][j] = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      ll tmp;
      if (s[i] == t[j]) {
	tmp = max(dp[i][j - 1], dp[i - 1][j]);
	tmp = max(dp[i - 1][j - 1] + 1, tmp);
	dp[i][j] = tmp;
      }
      else {
	tmp = max(dp[i][j - 1], dp[i - 1][j]);
	dp[i][j] = tmp;
      }
    }
  }

  string lcs = "";
  int i = N;
  int j = M;
  
  while (i > 0 && j > 0) {

    if (dp[i - 1][j] == dp[i][j]) i--;
    else if (dp[i][j - 1] == dp[i][j]) j--;
    else{
      lcs = s[i] + lcs;
      i--;
      j--;
    }
  }

  cout << lcs << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:7: error: 'll' was not declared in this scope
   38 |       ll tmp;
      |       ^~
a.cc:40:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   40 |         tmp = max(dp[i][j - 1], dp[i - 1][j]);
      |         ^~~
      |         tm
a.cc:45:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   45 |         tmp = max(dp[i][j - 1], dp[i - 1][j]);
      |         ^~~
      |         tm
Language: Java

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;
 
public class A {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		String s=fs.next(), t=fs.next();
		int n=s.length(), m=t.length();
		
		int [][] dp = new int[n+1][m+1];
		for(int i=0 ; i<n+1 ; ++i) 
			for(int j=0 ; j<m+1 ; ++j)
				dp[i][j] = 0;
		
		int maxLen=-1;
		for(int i=1 ; i<n+1 ; ++i) {
			for(int j=1 ; j<m+1 ; ++j) {
				dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
				if(s.charAt(i-1) == t.charAt(j-1))
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-1] + 1);
				maxLen = Math.max(maxLen, dp[i][j]);
			}
		}
		
		if(maxLen == 0) {
			System.exit(0);
		}
		
		int x=0, y=0;
		for(int i=1 ; i<n+1 ; ++i) {
			for(int j=1 ; j<m+1 ; ++j) {
				if(dp[i][j] == maxLen) {
					x = i;y = j;
					break;
				}
			}
		}
		
//		for(int i=0 ; i<n+1 ; ++i) {
//			for(int j=0 ; j<m+1 ; ++j)
//				System.out.print(dp[i][j] + " ");
//			System.out.println();
//		}
		
		String ans="";
		while(x != 0 && y != 0) {
			ans += s.charAt(x-1);
			--x;--y;
			while(x != 0 && y != 0 && dp[x-1][y] == dp[x][y])--x;
		}
		
		System.out.println(reverse(ans));
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	public static String reverse(String str) {
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}
 
}

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

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;
 
public class A {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		String s=fs.next(), t=fs.next();
		int n=s.length(), m=t.length();
		
		int [][] dp = new int[n+1][m+1];
		for(int i=0 ; i<n+1 ; ++i) 
			for(int j=0 ; j<m+1 ; ++j)
				dp[i][j] = 0;
		
		int maxLen=-1;
		for(int i=1 ; i<n+1 ; ++i) {
			for(int j=1 ; j<m+1 ; ++j) {
				dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
				if(s.charAt(i-1) == t.charAt(j-1))
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-1] + 1);
				maxLen = Math.max(maxLen, dp[i][j]);
			}
		}
		
		if(maxLen == 0) {
			System.exit(0);
		}
		
		int x=0, y=0;
		for(int i=1 ; i<n+1 ; ++i) {
			for(int j=1 ; j<m+1 ; ++j) {
				if(dp[i][j] == maxLen) {
					x = i;y = j;
					break;
				}
			}
		}
		
//		for(int i=0 ; i<n+1 ; ++i) {
//			for(int j=0 ; j<m+1 ; ++j)
//				System.out.print(dp[i][j] + " ");
//			System.out.println();
//		}
		
		String ans="";
		while(x != 0 && y != 0) {
			ans += s.charAt(x-1);
			--x;--y;
			while(x != 0 && y != 0 && dp[x-1][y] == dp[x][y])--x;
		}
		
		System.out.println(reverse(ans));
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	public static String reverse(String str) {
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}
 
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
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.math.BigInteger;
      | ^~~~~~
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.util.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.lang.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class A {
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  string t;
  int n=s.length();
  int m=t.length();
  int dp[n+1][m+1];
  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]=dp[i-1][j-1]+1;
      else
        dp[i][j]=max(dp[i-1][j], dp[i][j-1]);    
    }
  }
   int index=dp[n][m];
  char lcs[index+1];
  int i=n, j=m;
  while(i>0 && j>0){
    if(s[i-1]==t[j-1]){
      lcs[index-1]=s[i-1];
      i--;
      j--;
      index--;
    }
    else if(s[i-1][j]>t[i][j-1])
     i--;
    else
      j--;
  }
    cout<<lcs;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:19: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   29 |     else if(s[i-1][j]>t[i][j-1])
      |                   ^
a.cc:29:27: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   29 |     else if(s[i-1][j]>t[i][j-1])
      |                           ^
Language: C++

#include<iostream>
#include<string>
#include<map>
using namespace std;
string s1,s2,ans="";
int dp[3003][3003];

   
void cal_ans(int i, int j)
{
   if(i<=0||j<=0)
   {
     return;
   }
   
   if(s1[i-1]==s2[j-1])
   {ans+=s1[i-1];
    cal_ans(i-1,j-1);

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

}



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

  

  
  cin>>s1>>s2;
  
  for(int i=0;i<=s1.size();i++)
  {
    for(int j=0;j<=s2.size();j++)
    {
         if(i==0||j==0)
           dp[i][j]=0;
         else if(s1[i-1]==s2[j-1])
         {
               dp[i][j]=1+dp[i-1][j-1];
         } 
         else
         {
           dp[i][j]=std::max(dp[i][j-1],dp[i-1][j])
         }
         
    }
  }
 
  cal_ans(s1.size(),s2.size());
  cout<<ans<<endl;


return 0;



}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:52: error: expected ';' before '}' token
   60 |            dp[i][j]=std::max(dp[i][j-1],dp[i-1][j])
      |                                                    ^
      |                                                    ;
   61 |          }
      |          ~
Language: C++

#include <iostream>
#include <string>
using namespace std;
#define MAX 3001

int dp[MAX][MAX];

string getLCS(string s, string t, int len){
    int i = 0, j = 0;
    string LCSstring;
    while(len>0){
        if(s[i]==t[j]){
            LCSstring.push_back(s[i]);
            i++;
            j++;
            len--;    
        }
        else{
            if(dp[i][j+1] > dp[i+1][j]){
                j++;
            }
            else{
                i++;
            }
        }
    }
    return LCSstring;
}

int lenLCS(string s, int i, string t, int j){
    if(i>=s.size()||j>=t.size()){
        return  0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }

    if(s[i]==t[j]){
        return dp[i][j] = 1 + lenLCS(s, i+1,t, j+1);
    }
    else{
        return dp[i][j] = max(lenLCS(s,i+1,t,j), lenLCS(s, i, t,j+1));
    }
}

string solve(string s, string t){
    memset(dp, -1, sizeof dp);
    int l = lenLCS(s,0,t,0);
    return getLCS(s, t, l);
}
int main() {
    string s, t;
    cin >> s >> t;
    cout << solve(s, t) << endl;
}


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


/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 08, 2020 9:41 PM
 *    Problem Name  : -X-
 *    Problem Limit : NULL , NULL
 *    Problem Url   : -X-
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;
#define sz 3005
int dp[sz][sz];

int lcs(string s1, string s2,int m, int n)
{
    for(int i=0; i<=m; i++){
        for(int j=0; j<=n; j++){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }
            else if(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]);
        }
    }
    return dp[m][n];
}

void print_lcs(string s1, string s2, int length,int m, int n)
{
    char ans[length+1];
    ans[length] = '\0';
    int i=m, j=n;
    while(i>0 && j>0){
        if(s1[i-1]==s2[j-1]){
            ans[length-1] = s1[i-1];
            i--;
            j--;
            length--;
        }
        else if (dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    cout << ans << endl;
}


int main(){
    ios_base::sync_with_stdio(false);

    string s1,s2;
    cin >> s1 >> s1;

    int m = s1.length();
    int n = s2.length();
    int len = lcs(s1,s2,m,n);
    print_lcs(s1,s2,len,mi,n);

    return 0 ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:25: error: 'mi' was not declared in this scope; did you mean 'm'?
   62 |     print_lcs(s1,s2,len,mi,n);
      |                         ^~
      |                         m
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll MAX_N = 3000;

string dp[MAX_N + 5][MAX_N + 5];
int main() {
    INIT;

    string s, t;
    cin >> s >> t;

    rep(i, MAX_N + 5) rep(j, MAX_N + 5) dp[i][j] = "";

    // vector<vector<string>> dp(MAX_N + 5, vector<string>(MAX_N + 5, ""));
    rep(i, SZ(s)) {
        rep(j, SZ(t)) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + s[i];
            } else {
                ll s1 = SZ(dp[i][j + 1]);
                ll s2 = SZ(dp[i + 1][j]);
                if (s1 > s2) {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                } else {
                    dp[i + 1][j + 1] = dp[i + 1][j];
                }
                // dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }

    cout << dp[SZ(s)][SZ(t)] << endl;

    return 0;
}

Compiler output:
a.cc:44:28: error: size of array 'dp' is not an integral constant-expression
   44 | string dp[MAX_N + 5][MAX_N + 5];
      |                      ~~~~~~^~~
a.cc:44:17: error: size of array 'dp' is not an integral constant-expression
   44 | string dp[MAX_N + 5][MAX_N + 5];
      |           ~~~~~~^~~
Language: C++

    // Problem : F - LCS
    // Contest : AtCoder - Educational DP Contest
    // URL : https://atcoder.jp/contests/dp/tasks/dp_f
    // Memory Limit : 1024 MB
    // Time Limit : 2000 ms
    // Powered by CP Editor (https://github.com/cpeditor/cpeditor)
     
    #include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace std;
    using namespace __gnu_pbds;
     
    #define int long long
    #define db double
    #define mod 1000000007
    #define pb push_back
    #define pp pair<int,int>
    #define rep(i,a,b) for(int i=a;i<b;i++)
    #define repe(i,a,b) for(int i=a;i<=b;i++)
    #define repr(i,a,b) for(int i=b;i>=a;i--)
    #define maxn 200005
    #define ss second
    #define ff first
    #define all(a) a.begin(),a.end()
    #define lb lower_bound
    #define ub upper_bound
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
    int inv(int a, int b){
     return 1<a ? b - inv(b%a,a)*b/a : 1;
    }
    void solve()
    {
    	string s,t;
    	cin >> s >> t;
    	int n=s.size(),m=t.size();
    	int dp[n+1][m+1];
    	memset(dp,0,sizeof(dp));
    	rep(i,1,n+1)
    		rep(j,1,m+1)
    		{
    			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    			if(s[i-1] == t[j-1])
    				dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
    		}		
    	string ans;
    	int i=n,j=m;
    	while(i>0 and j>0)
    	{
    		if(s[i-1] == s[j-1]) ans.pb(s[i-1), i--, j--;
            else if(dp[i][j-1] > dp[i-1][j]) j--;
            else i--;
    	}
    	reverse(all(ans));
    	cout <<ans ;
    }
    signed main()
    {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t=1;
        //cin >> t;
        while(t--)
        solve();
        return 0;
    }

Compiler output:
a.cc: In function 'void solve()':
a.cc:50:50: error: expected ']' before ')' token
   50 |                 if(s[i-1] == s[j-1]) ans.pb(s[i-1), i--, j--;
      |                                                  ^
      |                                                  ]
Language: C++

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
rec(string &s, string &t, int i, int j, vector<vector<int>> &dp) {
    if (i == s.size() or j == t.size()) {
        return 0;
    }
    if (dp[i][j] != -1) {
        return dp[i][j];
    }
    int a = INT_MIN;
    int b = INT_MIN;
    int c = INT_MIN;

    if (s[i] == t[j]) {
        a = rec(s, t, i + 1, j + 1, dp) + 1;
    }
    b = rec(s, t, i + 1, j, dp);
    c = rec(s, t, i, j + 1, dp);

    return dp[i][j] = max(a, max(b, c));
}
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n + 1, vi(m + 1, 0));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            int a = INT_MIN;
            int b = INT_MIN;
            int c = INT_MIN;

            if (s[i] == t[j]) {
                a = dp[i + 1][j + 1] + 1;
            }
            b = dp[i + 1][j];
            c = dp[i][j + 1];
            dp[i][j] = max(a, max(b, c));
        }
    }
    // rep(i, 0, n + 1) {
    //     rep(j, 0, m + 1) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    string res = "";
    int i = 0;
    int j = 0;
    while (i < n and j < n) {
        if (dp[i][j] > dp[i + 1][j + 1]) {
            res += s[i];
            i++;
            j++;
        }
        else {
            i++;
        }
    }
    cout << res << endl;

    return 0;
}

Compiler output:
a.cc:17:1: error: ISO C++ forbids declaration of 'rec' with no type [-fpermissive]
   17 | rec(string &s, string &t, int i, int j, vector<vector<int>> &dp) {
      | ^~~
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,Y;
  cin>>X>>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:65:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   65 | 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:66:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   66 | 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)
      |                       ~~~~~~~~~~~~^~~
a.cc:67:5: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
   67 | 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; 
}
int main()
{
  string a ,b;
  cin>>a>>b;
  lcs(a,b,a.length(),b.length());
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:7: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
   62 |   lcs(a,b,a.length(),b.length());
      |       ^
      |       |
      |       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: Java

import java.io.*;
import java.util.StringTokenizer;

public class LCS {

    static int n;
    static int m;
    static int L[][] = new int[m+1][n+1];
    static StringBuilder str = new StringBuilder("");
    static int[][] dp;
    static char[] X;
    static char[] Y;

    static void lcs() {

        for (int i = 0; i <= m ; i++) {
            for (int j = 0; j <= n ; j++) {

                if (i==0 || j==0)
                    dp[i][j]=0;
                else if (X[i-1]==Y[j-1])
                    dp[i][j]=dp[i-1][j-1]+1;
                else
                    dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
            }
        }

    }
    static void trace(){
        int i = m;
        int j = n;

        while (i>0&&j>0){

            if (X[i-1]==Y[j-1]){
                str.append(X[i-1]);
                i--;
                j--;
            }else {
                if (dp[i-1][j]>dp[i][j-1])
                    i--;
                else
                    j--;
            }
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        String s1 = scan.next();
        String s2 = scan.next();
        n=s2.length();
        m=s1.length();
        dp=new int[m+1][n+1];
        X=s1.toCharArray();
        Y=s2.toCharArray();

        lcs();
        trace();

        System.out.println(str.reverse());
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}



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: Java

import java.io.*;
import java.util.StringTokenizer;

public class LCS {

    static int n;
    static int m;
    static int L[][] = new int[m+1][n+1];
    static StringBuilder str = new StringBuilder("");
    static int[][] dp;
    static char[] X;
    static char[] Y;

    static void lcs() {

        for (int i = 0; i <= m ; i++) {
            for (int j = 0; j <= n ; j++) {

                if (i==0 || j==0)
                    dp[i][j]=0;
                else if (X[i-1]==Y[j-1])
                    dp[i][j]=dp[i-1][j-1]+1;
                else
                    dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
            }
        }

    }
    static void trace(){
        int i = m;
        int j = n;

        while (i>0&&j>0){

            if (X[i-1]==Y[j-1]){
                str.append(X[i-1]);
                i--;
                j--;
            }else {
                if (dp[i-1][j]>dp[i][j-1])
                    i--;
                else
                    j--;
            }
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        String s1 = scan.next();
        String s2 = scan.next();
        n=s2.length();
        m=s1.length();
        dp=new int[m+1][n+1];
        X=s1.toCharArray();
        Y=s2.toCharArray();

        lcs();
        trace();

        System.out.println(dp[m][n]);
        System.out.println(str.reverse());
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}



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++

#include<bits/stdc++.h>
using namespace std;
string lcs(string a,string b){
    int al=a.length(),bl=b.length();
    int dp[al+1][bl+1];
    for(int i{};i<al;i++){
        for(int j{};j<bl;j++){
            if(a[i]==b[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else{
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    string r;
    int i{al},j{bl};
    while(i*j!=0){
        if(a[i-1]==b[j-1]){
            r=a[i-1]+r;
            --i;
            --j;
        }
        else if(dp[i][j-1]>dp[i-1][j]){
            --j;
        }
        else{
            --i;
        }
    }
    return r;
}
int main(){
  string a,string b;
  cout<<lcs(a,b);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:19: error: expected initializer before 'b'
   34 |   string a,string b;
      |                   ^
a.cc:35:15: error: 'b' was not declared in this scope
   35 |   cout<<lcs(a,b);
      |               ^
Language: C++

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)

int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("zgir.gir","r",stdin);
	// freopen("zcik.cik","w",stdout);
	// #endif

	string a,b;
	cin>>a>>b;
	lli dp[a.size()+5][b.size()+5];
	memset(dp, 0, sizeof(dp));
	for (lli i = 0; i <= a.size(); i++){
		for (lli j = 0; j <= b.size(); j++){
			if(i==0 || j==0) dp[i][j]=0;
			else 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]);
		}
	}
	lli i=a.size();
	lli j=b.size();
	while(i!=0 && j!=0){
		if(a[i-1]==b[j-1]){
			cvp.pb(a[i-1]);
			i--;
			j--;  
		 }
		else {
			if(dp[i-1][j]>dp[i][j-1]) i--;
			else j--;
		}
	}
	reverse(cvp.begin(), cvp.end());
	cout<<cvp;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:25: error: 'cvp' was not declared in this scope
   35 |                         cvp.pb(a[i-1]);
      |                         ^~~
a.cc:44:17: error: 'cvp' was not declared in this scope
   44 |         reverse(cvp.begin(), cvp.end());
      |                 ^~~
Language: C++

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

ll dp[3001][3001];

void main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    string s,t;
    cin>>s>>t;
    for(ll i=1;i<=s.size();++i){
        for(ll j=1;j<=t.size();++j){
            if(s[i-1] == t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll i=s.size(),j=t.size();
    string ans;
    while(i and j){
        if(s[i-1] == t[j-1]){
            ans+=s[i-1];
            --i,--j;
            continue;
        }
        if(dp[i-1][j]> dp[i][j-1])
            --i;
        else
            --j;        
    }
    cout<<ans;
    
}

Compiler output:
a.cc:7:1: error: '::main' must return 'int'
    7 | void main(){
      | ^~~~
Language: C++

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

ll dp[3001][3001];

void main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    string s,t;
    cin>>s>>t;
    for(ll i=1;i<=s.size();++i){
        for(ll j=1;j<=t.size();++j){
            if(s[i-1] == t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll i=s.size(),j=t.size();
    string ans;
    while(i and j){
        if(s[i-1] == t[j-1]){
            ans+=s[i-1];
            --i,--j;
            continue;
        }
        if(dp[i-1][j]> dp[i][j-1])
            --i;
        else
            --j;        
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc:7:1: error: '::main' must return 'int'
    7 | void main(){
      | ^~~~
Language: C++

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

ll dp[3001][3001];

ll main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    string s,t;
    cin>>s>>t;
    for(ll i=1;i<=s.size();++i){
        for(ll j=1;j<=t.size();++j){
            if(s[i-1] == t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll i=s.size(),j=t.size();
    string ans;
    while(i and j){
        if(s[i-1] == t[j-1]){
            ans+=s[i-1];
            --i,--j;
            continue;
        }
        if(dp[i-1][j]> dp[i][j-1])
            --i;
        else
            --j;        
    }
    cout<<ans;
}

Compiler output:
a.cc:3:22: error: '::main' must return 'int'
    3 | #define ll long long int
      |                      ^~~
a.cc:7:1: note: in expansion of macro 'll'
    7 | ll main(){
      | ^~
Language: Java

def lcs(X, Y, m, n): 
  
    if m == 0 or n == 0: 
       return 0; 
    elif X[m-1] == Y[n-1]: 
       return 1 + lcs(X, Y, m-1, n-1); 
    else: 
       return max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n)); 
X = "AGGTAB"
Y = "GXTXAYB"
print ("Length of LCS is ", lcs(X, Y, len(X), len(Y))) 

  

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
def lcs(X, Y, m, n): 
^
  (use --enable-preview to enable unnamed classes)
Main.java:1: error: <identifier> expected
def lcs(X, Y, m, n): 
         ^
Main.java:1: error: <identifier> expected
def lcs(X, Y, m, n): 
            ^
Main.java:1: error: <identifier> expected
def lcs(X, Y, m, n): 
               ^
Main.java:1: error: <identifier> expected
def lcs(X, Y, m, n): 
                  ^
Main.java:1: error: ';' expected
def lcs(X, Y, m, n): 
                   ^
Main.java:5: error: class, interface, enum, or record expected
    elif X[m-1] == Y[n-1]: 
    ^
Main.java:7: error: class, interface, enum, or record expected
    else: 
    ^
Main.java:9: error: class, interface, enum, or record expected
X = "AGGTAB"
^
9 errors
Language: C++

/*
 axyb
 abyxb
 ans=b
  0 1 2 3 4
0 1 1 1 1 1
1 1 1 1 2 2
2 1 1 2 2 2
3 1 2 2 2 3
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

    int dp[n][m];

    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
        {
            if(i==0 && j==0)
            {
                if(s[i]==t[j]) dp[i][j] = 1;
                else dp[i][j]=0;
            }
            else if(i==0 && j>0)
            {
                if(s[i]==t[j]) dp[i][j] = 1;
                else dp[i][j]=dp[i][j-1];
            }
            else if(i>0 && j==0)
            {
                if(s[i]==t[j]) dp[i][j] = 1;
                else dp[i][j]=dp[i-1][j];
            }
            else
            {
                if(s[i]==t[j]) dp[i][j] = 1 + dp[i-1][j-1];
                else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }   
        }
    }
    
    int i=n-1;
    int j=m-1;
    string ans ="";
    while(i>=0 && j>=0)
    {
        if(dp[i][j]==0) break;
        if(s[i]==t[j]) {
            ans += s[i];
            i--;
            j--;
            continue;
        }
        else 
        {
            if(i>0 && j>0) 
            {
                if(dp[i-1][j] >= dp[i][j-1]) {
                    i--;
                }
                else j--;
            }
            else if(i==0 && j>0)  j--;
            else if(i>0 && j==0) i--;
        }
    }
    reverse(a.begin(),a.end());
    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:76:13: error: 'a' was not declared in this scope
   76 |     reverse(a.begin(),a.end());
      |             ^
Language: C++

#include<bits/stdc++.h>
#include"substring.h"
typedef long long int ll;
using namespace std;

string subsequence(string s1,string s2)
{   
    int x = s1.length();
    int y = s2.length();
    int dp[x+1][y+1];
    for(int i=0;i<=x;i++)
    {
        for(int j=0;j<=y;j++)
        {
            dp[i][j] = 0;
        }
    }
    for(int i=1;i<=x;i++)
    {
        for(int j=1;j<=y;j++)
        {
            if(s1[i-1] == s2[j-1])
            {
                dp[i][j] = 1 +dp[i-1][j-1];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string res;
    int j=y;
    for(int i=x;i>0;i--)
    {
        if(dp[i][j] == 1+dp[i-1][j-1])
        res+=s1[i-1];
        j--;
    }
    reverse(res.begin(),res.end());
    return res;
}

int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    cout<<subsequence(s1,s2)<<endl;
}

Compiler output:
a.cc:2:9: fatal error: substring.h: No such file or directory
    2 | #include"substring.h"
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstring>
using namespace std;
char a[1010],b[1010];
int dp[1010][1010],path[1010][1010];
void LCS(char x[],char y[]){
	int len1=strlen(x+1);
	int len2=strlen(y+1);
	memset(dp,0,sizeof(dp));
	for (int i=1;i<=len1;i++)
		for (int j=1;j<=len2;j++){
			if (x[i]==y[j])
				dp[i][j]=dp[i-1][j-1]+1,path[i][j]=1;
			else if (dp[i-1][j]>=dp[i][j-1])
				dp[i][j]=dp[i-1][j],path[i][j]=2;
			else
				dp[i][j]=dp[i][j-1],path[i][j]=3;
		}
}
void PrintLcs(int x,int y){
	if (x==0||y==0) return;
	if (path[x][y]==1){
		PrintLcs(x-1,y-1);
		putchar(a[x]);
	}
	else if(path[x][y]==2)PrintLcs(x-1,y);
	else PrintLcs(x,y-1);
}
int main(){
	gets(a+1);
	gets(b+1);
	LCS(a,b);
	PrintLcs(strlen(a+1),strlen(b+1));
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
char a[1010],b[1010];
int dp[1010][1010],path[1010][1010];
void LCS(char x[],char y[]){
	int len1=strlen(x+1);
	int len2=strlen(y+1);
	memset(dp,0,sizeof(dp));
	for (int i=1;i<=len1;i++)
		for (int j=1;j<=len2;j++){
			if (x[i]==y[j])
				dp[i][j]=dp[i-1][j-1]+1,path[i][j]=1;
			else if (dp[i-1][j]>=dp[i][j-1])
				dp[i][j]=dp[i-1][j],path[i][j]=2;
			else
				dp[i][j]=dp[i][j-1],path[i][j]=3;
		}
}
void PrintLcs(int x,int y){
	if (x==0||y==0) return;
	if (path[x][y]==1){
		PrintLcs(x-1,y-1);
		putchar(a[x]);
	}
	else if(path[x][y]==2)PrintLcs(x-1,y);
	else PrintLcs(x,y-1);
}
int main(){
	gets(a+1);
	gets(b+1);
	LCS(a,b);
	PrintLcs(strlen(a+1),strlen(b+1));
	return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
char a[1010],b[1010];
int dp[1010][1010],path[1010][1010];
void LCS(char x[],char y[]){
	int len1=strlen(x+1);
	int len2=strlen(y+1);
	memset(dp,0,sizeof(dp));
	for (int i=1;i<=len1;i++)
		for (int j=1;j<=len2;j++){
			if (x[i]==y[j])
				dp[i][j]=dp[i-1][j-1]+1,path[i][j]=1;
			else if (dp[i-1][j]>=dp[i][j-1])
				dp[i][j]=dp[i-1][j],path[i][j]=2;
			else
				dp[i][j]=dp[i][j-1],path[i][j]=3;
		}
}
void PrintLcs(int x,int y){
	if (x==0||y==0) return;
	if (path[x][y]==1){
		PrintLcs(x-1,y-1);
		putchar(a[x]);
	}
	else if(path[x][y]==2)PrintLcs(x-1,y);
	else PrintLcs(x,y-1);
}
int main(){
	gets(a+1);
	gets(b+1);
	LCS(a,b);
	PrintLcs(strlen(a+1),strlen(b+1));
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   29 |         gets(a+1);
      |         ^~~~
      |         getw