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

#include<bits/stdc++.h>
using namespace std;
int LCS(string a,string b, int sa,int sb)
{
  if(sa==0||sb==0)
    return 0;
  if(a[sa-1]==b[sb-1])
  return(1+LCS(a,b,sa-1,sb-1)
         else 
         return max(LCS(a,b,sa-1,sb),LCS(a,b,sa,sb-1));
 
 
}
 int main()
 {
 string a,b;
   cin>>a>>b;
   int sa=a.length();
   int sb=b.length();
   return LCS(a,b,sa,sb);
   
 
 }

Compiler output:
a.cc: In function 'int LCS(std::string, std::string, int, int)':
a.cc:8:30: error: expected ')' before 'else'
    8 |   return(1+LCS(a,b,sa-1,sb-1)
      |         ~                    ^
      |                              )
    9 |          else
      |          ~~~~                 
a.cc:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int LCS(string a,string b, int sa,int sb)
{
  if(n==0||m==0)
    return 0;
  if(a[sa-1]==b[sb-1])
  return(1+LCS(a,b,sa-1,sb-1)
         else 
         return max(LCS(a,b,sa-1,sb),LCS(a,b,sa,sb-1);
 

}
 int main()
 {
 string a,b;
   cin>>a>>b;
   int sa=a.length();
   int sb=b.length();
   return LCS(a,b,sa,sb);
   
 
 }

Compiler output:
a.cc: In function 'int LCS(std::string, std::string, int, int)':
a.cc:5:6: error: 'n' was not declared in this scope
    5 |   if(n==0||m==0)
      |      ^
a.cc:5:12: error: 'm' was not declared in this scope
    5 |   if(n==0||m==0)
      |            ^
a.cc:8:30: error: expected ')' before 'else'
    8 |   return(1+LCS(a,b,sa-1,sb-1)
      |         ~                    ^
      |                              )
    9 |          else
      |          ~~~~                 
a.cc:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 100001

//long long int mod=1e18 ;



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

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


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


		
}
	
	
	
	



#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 100001

//long long int mod=1e18 ;



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

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


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


		
}
	
	
	
	





Compiler output:
a.cc:81:5: error: redefinition of 'int main()'
   81 | int main(){
      |     ^~~~
a.cc:14:5: note: 'int main()' previously defined here
   14 | int main(){
      |     ^~~~
Language: C++

#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    string s,t;
    cin>>s>>t;
    lli m=s.size()+1;
    lli n=t.size()+1;
    vector<vector<string>> dp(m,vector<string>(n);
    rep(i,m){
        rep(j,n){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+s[i];
            }
            else{
                if(dp[i][j+1].size()>dp[i+1][j].size()){
                    dp[i+1][j+1]=dp[i][j+1];
                }
                else{
                    dp[i+1][j+1]=dp[i+1][j];
                }
            }
        }

    }
    out(dp[s.size()][t.size()]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:50: error: expected ')' before ';' token
   27 |     vector<vector<string>> dp(m,vector<string>(n);
      |                              ~                   ^
      |                                                  )
Language: C++

#include<bits\stdc++.h>
using namespace std;
const int MOD=1e9+7;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  vector<vector<int>>a(n+1,vector<int>(m+1));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      if(s[i-1]==t[j-1])
        a[i][j]=a[i-1][j-1]+1;
      else
        a[i][j]=max(a[i-1][j],a[i][j-1]);
    }
  }
  string ans=" ";
  int x=n,y=m;
  while(y!=0 && x!=0)
  {
    if(a[x-1][y]==a[x][y])
      --x;
    else if(a[x][y-1]==a[x][y])
      --y;
    else
    {
      ans=t[y-1]+ans;
      --x;
      --y;
    }
  }
  cout<<ans<<"\n";
  return 0;
}

Compiler output:
a.cc: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;
 int  main()
{ string s,t;
cin>>s>>t;
int n1,n2;
n1=s.length();
n2=t.length();
int dp[n1+1][n2+1]={0};
for(int i=0;i<=n1;i++)
{ for(int j=0;j<=n2;j++)
    {  if(i==0||j==0)
    { dp[i][j]=0;
        continue;
    }

        if(s[i-1]==t[j-1])
        dp[i][j]=1+dp[i-1][j-1];
        else
            dp[i][j]=0;
        dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));

    }
}
//cout<<dp[n1][n2]<<endl;

string ans="";
for(int i=n1;i>=1;  )
{ for(int j=n2;j>=1;  )
    { int var=dp[i][j];
        if(s[i-1]==t[j-1])
        { if(var==1+dp[i-1][j-1])
            { ans+=s[i-1];
                i=i-1;
                j=j-1;
            }
            else if(var==dp[i-1][j])
                i=i-1;
            else
                j=j-1;
        }
        else
        { if(var==dp[i-1][j])
            i=i-1;
            else
                j=j-1;
        }
        if(i==0||j==0)
            break;
    }
    if(i==0||j==0)
        break;
}

for(int i=ans.length()-1;i>=0;i--)
    cout<<ans[i];
cout<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:14: error: 'j' was not declared in this scope
   51 |     if(i==0||j==0)
      |              ^
Language: C++

#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string s,t;
  cin>>s>>t;
  int dp[n+1][m+1];
  memset(dp,0,sizeof(dp));
  for (int i=1;i<=n;i++)
  {
    for (int j=1;j<=m;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]);
    }
  }
  
  int i=n,j=m;
    string ans = "";
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            ans += s[i-1];
            i--,j--;
        }
        else
        {
            if(dp[i-1][j] >= dp[i][j-1])
                i--;
            else
                j--;
        }
    }
 
    reverse(ans.begin() , ans.end());
    cout<<ans<<"\n";
  return 0;
}

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

#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string s,t;
  cin>>s>>t;
  int dp[n+1][m+1];
  memset(dp,0,sizeof dp);
  for (int i=1;i<=n;i++)
  {
    for (int j=1;j<=m;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]);
    }
  }
  
  int i=n,j=m;
    string ans = "";
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            ans += s[i-1];
            i--,j--;
        }
        else
        {
            if(dp[i-1][j] >= dp[i][j-1])
                i--;
            else
                j--;
        }
    }
 
    reverse(ans.begin() , ans.end());
    cout<<ans<<"\n";
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vector<vector<int>> dp(3010), vector<int>(3010),0));
  rep(i,n)rep(j,m){
    dp[i+1][j+1] = dp[i][j];
    if(s[i]==t[j]){
      dp[i+1][j+1]++;
    }
    dp[i+1][j+1] = max(dp[i+1][j+1], max(dp[i][j+1],dp[i+1][j]));
  }
  string ans = "";
  int cnt = m;
  for(int i=n; i>0; i--){
    if(dp[i][cnt]!=dp[i-1][cnt]){
      ans.push_back(s[i-1]);
      cnt--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << ln;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:44: error: invalid declarator before '(' token
   23 |   vector<vector<int>> dp(3010), vector<int>(3010),0));
      |                                            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,h;
  cin>>s>>h;
  int a[s.size()+1][h.size()+1]
  for(int i=0;i<=s.size();i++)
  {
    a[i][0]=0;
  }
  for(int i=0;i<=h.size();i++)
  {
    a[0][i]=0;
  }
  for(int i=1;i<=s.size();i++)
  {
    for(int j=1;j<=h.size();j++)
    {
     if(s[i-1]==h[j-1])
     {
       a[i][j]=a[i-1][j-1]+1;
     }
     else
     {
       a[i][j]=max(a[i-1][j],a[i][j-1]);
     }
    }
  }
  cout<<a[s.size()][h.size()];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: expected initializer before 'for'
    8 |   for(int i=0;i<=s.size();i++)
      |   ^~~
a.cc:8:15: error: 'i' was not declared in this scope
    8 |   for(int i=0;i<=s.size();i++)
      |               ^
a.cc:14:5: error: 'a' was not declared in this scope
   14 |     a[0][i]=0;
      |     ^
a.cc:22:8: error: 'a' was not declared in this scope
   22 |        a[i][j]=a[i-1][j-1]+1;
      |        ^
a.cc:26:8: error: 'a' was not declared in this scope
   26 |        a[i][j]=max(a[i-1][j],a[i][j-1]);
      |        ^
a.cc:30:9: error: 'a' was not declared in this scope
   30 |   cout<<a[s.size()][h.size()];
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
  string a,b,s="";
 ll dp[3005][3005];
int LCS(ll i,ll j){
    if(i<0||j<0)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
   if(a[i]==b[j]){
       return dp[i][j]=1+LCS(i-1,j-1);
   }
  else 
  return dp[i][j]=max(LCS(i-1,j),LCS(i,j-1));
}
int main(){
    IOS;
    cin>>a>>b;
    memset(dp,-1,sizeof(dp));
    LCS(a.length()-1,b.length()-1)<<endl;
    ll n=a.length()-1,m=b.length()-1;
  while(n>=0||m>=0){
      if(a[n]==b[m]){
        s+=a[n];
        n--;
        m--;
      }
      else 
      if(dp[n-1][m]>dp[n][m-1]){
          n--;
      }
      else 
      m--;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:35: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   28 |     LCS(a.length()-1,b.length()-1)<<endl;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
Language: C++

#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define li long long int
#define mx 100005
li len_s,len_t;
char s[3005],t[3005],res[3005];

int dp[3005][3005];

void f()
{
    dp[0][0]=0;
    for(int i=1;i<=len_t;i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=len_s;i++)
    {
        dp[i][0]=0;
    }

    for(int i=1;i<=len_s;i++)
    {
        for(int j=1;j<=len_t;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
}


void gen()
{
    int i=len_s,j=len_t,k;
    int idx=0;

    while(i>0 && j>0)
    {
        if(dp[i][j]==dp[i-1][j-1]+1)
        {
            res[idx]=s[i-1];
            idx++;
            i=i-1;
            j=j-1;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i=i-1;
            }
            else
            {
                j=j-1;
            }
        }
    }
    res[idx]='\0';
    strrev(res);
    cout<<res;
    return;
}

int main()
{
    cin>>s>>t;
    len_s=strlen(s);
    len_t=strlen(t);
    f();
    gen();
    return 0;
}


Compiler output:
a.cc: In function 'void gen()':
a.cc:67:5: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   67 |     strrev(res);
      |     ^~~~~~
      |     strsep
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define li long long int
#define mx 100005
li len_s,len_t;
char s[3005],t[3005],res[3005];

int dp[3005][3005];

void f()
{
    dp[0][0]=0;
    for(int i=1;i<=len_t;i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=len_s;i++)
    {
        dp[i][0]=0;
    }

    for(int i=1;i<=len_s;i++)
    {
        for(int j=1;j<=len_t;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
}


void gen()
{
    int i=len_s,j=len_t,k;
    int idx=0;

    while(i>0 && j>0)
    {
        if(dp[i][j]==dp[i-1][j-1]+1)
        {
            res[idx]=s[i-1];
            idx++;
            i=i-1;
            j=j-1;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i=i-1;
            }
            else
            {
                j=j-1;
            }
        }
    }
    res[idx]='\0';
    strrev(res);
    cout<<res;
    return;
}

int main()
{
    cin>>s>>t;
    len_s=strlen(s);
    len_t=strlen(t);
    f();

    gen();
    return 0;
}


Compiler output:
a.cc: In function 'void gen()':
a.cc:66:5: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   66 |     strrev(res);
      |     ^~~~~~
      |     strsep
Language: C++

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

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

    int dp[3001][3001] = {0};

    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] = dp[i][j] + 1;
            } else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    string result = "";

    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 {
            result = s[i - 1] + result;
            i--;
            j--;
        }
    }

    cout << result << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:12: error: 'i' was not declared in this scope
   25 |     while (i > 0 && j > 0) {
      |            ^
a.cc:25:21: error: 'j' was not declared in this scope
   25 |     while (i > 0 && j > 0) {
      |                     ^
Language: C++


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

int max(int a, int b); 

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

  int i = m, j = n;
  while (i > 0 && j > 0) {
    if (X[i - 1] == Y[j - 1]) {
      lcsAlgo[index - 1] = X[i - 1];
      i--;
      j--;
      index--;
    }

    else if (L[i - 1][j] > L[i][j - 1])
      i--;
    else
      j--;
  }
  
  cout << lcsAlgo << "\n";
 
}

int main() 
{ 
	char X[3000]; 
	char Y[3000];
	 
	cin>>X;
	cin>>Y;
	int m = strlen(X); 
	int n = strlen(Y); 
	
	cout << "Length of LCS is "
		<< lcs( X, Y, m, n ); 
	
	return 0; 
}  


Compiler output:
a.cc: In function 'int lcs(char*, char*, int, int)':
a.cc:47:1: warning: no return statement in function returning non-void [-Wreturn-type]
   47 | }
      | ^
/usr/bin/ld: /tmp/cceq3lcX.o: in function `lcs(char*, char*, int, int)':
a.cc:(.text+0x208): undefined reference to `max(int, int)'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
 int tt[3001][3001];
int solve(string s,string t,int se,int te)
{
    if(se==0||te==0)
        return 0;

    if(tt[se][te]!= -1)
            return tt[se][te];

    if(s.at(se-1)==t.at(te-1))
        return tt[se][te]=1+solve(s,t,se-1,te-1);
    else
    {
        return tt[se][te]=max(solve(s,t,se,te-1),solve(s,t,se-1,te));
    }

}
int main()
{
    memset(tt,-1,sizeof(tt));
    for(int i=0;i<3002;i++)
    {
        for(int j=0;j<3002;j++)
        {
            if(i==0||j==0)
                tt[i][j]=0;
        }
    }
    string s,t;
     cin>>s>>t;

    int yo=solve(s,t,s.length(),t.length())<<endl;

    int sa=s.length(),ta=t.length();
    string sample="";
    int i=sa,j=ta;
    while(i>0&j>0)
    {
        if(s.at(i-1)==t.at(j-1))
        {
            sample+=s.at(i-1);
            i--,j--;
        }
        else
        {
                if(tt[i][j-1]>tt[i-1][j])
                j--;
                else i--;
        }
    }
    reverse(sample.begin(),sample.end());
    cout<<sample<<endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:44: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   34 |     int yo=solve(s,t,s.length(),t.length())<<endl;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
Language: C++

a, b = input(), input()
n, m = len(a), len(b)
dp = [[[0, 0, 0] for _ in range(m+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(m):
        skip_a = dp[i][i+1]
        skip_b = dp[i+1][j]
        match = dp[i][j]
        match_len = match[0] + 1 if a[i] == b[j] else 0
        if skip_a[0] >= skip_b[0] and skip_a[0] >= match_len:
            dp[i+1][j+1] = [skip_a[0], i, j+1]
        elif skip_b[0] >= skip_a[0] and skip_b[0] >= match_len:
            dp[i+1][j+1] = [skip_b[0], i+1, j]
        else:
            dp[i+1][j+1] = [match_len, i, j]
ans = []
r = n
c = m
while r >= 1 and c >= 1:
    parent = [dp[r][c][1], dp[r][c][2]]
    
    if parent[0] == r-1 and parent[1] == c-1:
        ans.append(a[r-1])
    
    r = parent[0]
    c = parent[1]

print(''.join(reversed(ans)))

"""
int main() {
    string a;
    string b;
    cin >> a >> b;
    
    //scanf("%s%s", &a.c_str(), &b.c_str());
    int n = a.length();
    int m = b.length();
    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(m+1, vector<int>(3)));
    // {length, parent_r, parent_c}
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            vector<int> skip_a = dp[i][j+1];
            vector<int> skip_b = dp[i+1][j];
            vector<int> match = dp[i][j];
            int match_len = a[i] == b[j] ? match[0] + 1 : 0;
            if (skip_a[0] >= skip_b[0] && skip_a[0] >= match_len) {
                dp[i+1][j+1] = {skip_a[0], i, j+1};
            }
            else if (skip_b[0] >= skip_a[0] && skip_b[0] >= match_len) {
                dp[i+1][j+1] = {skip_b[0], i+1, j};
            }
            else {
                dp[i+1][j+1] = {match_len, i, j};
            }
        }
    }
    
    string ans;
    int r = n;
    int c = m;
    while (r >= 1 && c >= 1) {
        //cout << r << " " << c << endl;
        vector<int> parent = {dp[r][c][1], dp[r][c][2]};
        
        if (parent[0] == r-1 && parent[1] == c-1) {
            ans.push_back(a[r-1]);
        }
        r = parent[0];
        c = parent[1];
    }
    reverse(ans.begin(), ans.end());
	cout << ans << endl;
	//cout << dp[n][m][0] << endl;
	
	return 0;
}
"""

Compiler output:
a.cc:28:7: error: empty character constant
   28 | print(''.join(reversed(ans)))
      |       ^~
a.cc:30:3: warning: missing terminating " character
   30 | """
      |   ^
a.cc:30:3: error: missing terminating " character
a.cc:79:3: warning: missing terminating " character
   79 | """
      |   ^
a.cc:79:3: error: missing terminating " character
a.cc:1:1: error: 'a' does not name a type
    1 | a, b = input(), input()
      | ^
a.cc:79:1: error: expected unqualified-id before string constant
   79 | """
      | ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  string t;
  cin>>s>>t;
  int N=s.size();
  int M=t.size();
  vector<vector<int>>L(N+1,vector<int>(M+1,0));
  for(int i=1;i<=N;i++){
  for(int j=1;j<=M;j++){
   if(s.at(i-1)==t.at(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 ans="";
  int I=N; int J=M;
  while(1<=I && 1<=J){
  if(dp[I][J]=1+dp[I-1][J-1]){
   I--; J--; ans=s.at(I-1)+ans;
  }else if(dp[I][J]==dp[I-1][J]){
   I--;
  }else{
  J--;
  }
  
  }cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:6: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |      dp[i][j]=1+dp[i-1][j-1];
      |      ^~
      |      dup
a.cc:15:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |       dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      |       ^~
      |       dup
a.cc:20:6: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |   if(dp[I][J]=1+dp[I-1][J-1]){
      |      ^~
      |      dup
Language: C++

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

int main() {
	string s,t;
	cin>>s>>t;
	
	int ssize=s.size(); tsize=t.size();
	
	dp[0][0]=0;
	
	for(int i=0; i<ssize ; i++){
		for(int j=0;j<tsize;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]=max(dp[i+1][j] ,dp[i][j]);
			dp[i][j+1]=max(dp[i][j+1], dp[i][j]);
		}
	}
	
	int ans=0,x,y;
	
	for(int i=1; i<=ssize;i++) 
		if (dp[i][tsize]>ans) {
			ans=dp[i][tsize];
			x=i;	y=tsize;
		}
	
	for(int i=1; i<=tsize;i++) 
		if (dp[ssize][i]>ans) {
			ans=dp[ssize][i];
			y=i;	x=ssize;
		}

	string r="";
	
	while(ans){
		if(s[x-1]==t[y-1]){
			r+= s[x-1];		
			x--;y--;ans--;
		}
		else if (dp[x-1][y]>dp[x][y-1]){
			x--;
		}
		else y--;
		
	}
	reverse(r.begin(),r.end());
	cout<<r<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:29: error: 'tsize' was not declared in this scope; did you mean 'ssize'?
    9 |         int ssize=s.size(); tsize=t.size();
      |                             ^~~~~
      |                             ssize
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define F(i_a,a,b) for(i = a; i <= b; i ++)
#define RF(i,a,b) for(i = a; i >= b;i --)
#define sz(a) sizeof(a)
using namespace std;

typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef unordered_map<int,int> umii;
typedef unordered_map<char,int> umci;

//LCS ->longest common subsequence
//LCS -> f(i,j) => a[0...i]
//                  b[0....j]
//dp[i][j] represents the LCS of a[0....i] & b[0....j]
//dp[i][j] = (a[i] == b[j]) ? (1 + dp[i - 1][j - 1]) : 
//                            max(dp[i - 1][j], dp[i][j - 1]) 

int dp[3001][3001];
string a,b;

void solve()
{
    int i_a, i_b, lim_a = a.size(), lim_b = b.size();
    cin>>a>>b;
    dp[0][0] = 0;
    F(i_a, 1, lim_a)
    {
        F(i_b, 1, lim_b)
        {
            dp[i_a][i_b] = (a[i_a] == b[i_b])?(1 + dp[i_a - 1][i_b - 1]): max(dp[i_a - 1][i_b], dp[i_a][i_b - 1]);
        }
    }
    cout<<dp[lim_a][lim_b]<<'\n';
}

signed main()
{
    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);
    //#else
    //#endif
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:3:24: error: 'i' was not declared in this scope
    3 | #define F(i_a,a,b) for(i = a; i <= b; i ++)
      |                        ^
a.cc:30:5: note: in expansion of macro 'F'
   30 |     F(i_a, 1, lim_a)
      |     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=3010;
string s,t,gay="";
int dp[N][N],ans,n,m;
int play(int x,int y){
	if(x<0||y<0) return 0;
	if(dp[x][y]!=-1) return dp[x][y];
	if(s[x]==t[y]) return dp[x][y]=1+play(x-1,y-1);
	return dp[x][y]=max(play(x-1,y),play(x,y-1));
}
int main(){
	ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(NULL);
	fflush(stdin); cin>>s; fflush(stdin); cin>>t;
	n=s.length(); m=t.length();
	for(i=0;i<n;++i) for(j=0;j<m;++j) dp[i][j]=-1;
	ans=play(n-1,m-1);
//	for(i=0;i<n;++i){
//		for(j=0;j<m;++j) cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
//	cout<<ans<<endl; 
	--n; --m;
	while(n>=0&&m>=0){
		if(s[n]==t[m]){
			gay+=s[n];
			--n;
			--m;
			continue;
		}
		if(dp[n-1][m]>dp[n][m-1]) --n;
		else --m;
	}
	reverse(gay.begin(),gay.end());
	cout<<gay;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'i' was not declared in this scope
   17 |         for(i=0;i<n;++i) for(j=0;j<m;++j) dp[i][j]=-1;
      |             ^
a.cc:17:30: error: 'j' was not declared in this scope
   17 |         for(i=0;i<n;++i) for(j=0;j<m;++j) dp[i][j]=-1;
      |                              ^
Language: Java

import java.util.*;
public class LCSAtCoder{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            String A=sc.next();
            String B=sc.next();
            System.out.println(longestCommonSubsequence(A,B));
        }
    }

    public static String longestCommonSubsequence(String A, String B) {
        int lenA=A.length();
        int lenB=B.length();
        int[][] dp=new int[lenA+1][lenB+1];
        int[][] back=new int[lenA+1][lenB+1];
        for (int i=1;i<=lenA;i++) {
            for (int j=1;j<=lenB;j++) {
                if (A.charAt(i-1)==B.charAt(j-1)) {
                    dp[i][j]=dp[i-1][j-1]+1;
                    back[i][j]=1; //左上
                }else if(dp[i-1][j]>dp[i][j-1]){
                    dp[i][j]=dp[i-1][j];
                    back[i][j]=2; //上
                }else{
                    dp[i][j]=dp[i][j-1];
                    back[i][j]=0; //左
                }
            }
        }
        int i=lenA,j=lenB;
        StringBuilder res=new StringBuilder();
        while(i>0 && j>0){
            if (back[i][j]==1) {
                i--;j--;
                res.append(A.charAt(i));
            }else if(back[i][j]==2){
                i--;
            }else{
                j--;
            }
        }
        return res.reverse().toString();
    }

}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;
#define N (int)1e6+1

string dp[3000+1][3000+1];
string a,b;

int main()
{
	ios
	cin>>a>>b;
	f(0,0,"");
	string ans="";
	for(int i=0;i<=a.length();i++)
	{
		for(int j=0;j<=b.length();j++)
		{
			if(i==0 || j==0)dp[i][j]="";
			else if(a[i-1]==b[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+a[i-1];
			}
			else
			{
				if(dp[i-1][j].length()>dp[i][j-1].length())dp[i][j]=dp[i-1][j];
				else dp[i][j]=dp[i][j-1];
			}
		}
	}
	cout<<dp[a.length()][b.length()]<<nl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'f' was not declared in this scope
   33 |         f(0,0,"");
      |         ^
Language: C++

                ans.pb(s[i-1]);
#include <bits/stdc++.h>
using namespace std; 


void fst() {ios::sync_with_stdio(0);cin.tie(0);
    }    
int nxt(){int x;cin>>x;return x;}
int nex_l(){long long x;cin>>x;return x;}
  
typedef long long ll; typedef vector<int> vi;typedef vector<bool> vb;typedef vector<vi> vvi; 
typedef vector<vb> vvb;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
  
#define fr first 
#define sc second 
#define mp make_pair 
#define pb push_back 
#define all(v) v.begin(), v.end()
#define binary(n) cout<<bitset<31>(n)<<"\n";
#define FOR(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define input_arr(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";
const int MS=1E5;
main(){
    fst();
    string s,t;
    cin>>s>>t;
    vvi DP(s.size()+1,vi (t.size()+1));
    rep(i,1,s.size()+1){
        rep(j,1,t.size()+1){
            if(s[i-1]==t[j-1]){
                DP[i][j]=max(DP[i-1][j],DP[i][j-1]+1);
            }
            else 
            DP[i][j]=max(DP[i][j-1],DP[i-1][j]);

        }
    }
    string ans;
    int i=s.size(),j=t.size();
        while(i>0 && j>0){
            if(DP[i][j]==DP[i-1][j]+1) {
                ans.pb(s[i-1]);
                i--;
            }
            else if(DP[i][j]==DP[i][j-1]+1){
                ans.pb(s[i-1]);
                j--;
            }
            else if(DP[i][j]==DP[i-1][j-1]+1){
                ans.pb(s[i-1]);
                i--,j--;
            }
            else i--,j--;
        }
    rep(i,0,s.size()+1){
        rep(j,0,t.size()+1){
            cerr<<DP[i][j]<<" ";
        }
        cerr<<"\n";

    }
    reverse(all(ans));
    cout<<ans;

    

}

    


Compiler output:
a.cc:1:17: error: 'ans' does not name a type
    1 |                 ans.pb(s[i-1]);
      |                 ^~~
a.cc:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main(){
      | ^~~~
Language: C++

//https://atcoder.jp/contests/dp/tasks/dp_f
#include<bits/stdc++.h>
#define forz(i,n) for(int i=0;i<n;i++)
#define foro(i,n) for(int i=1;i<=n;i++)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define lli long long int
using namespace std;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
     faster
     string s,t;
     cin>>s;
     cin>>t;
     int n1=s.length();
     int n2=t.length();
     int dp[n1+1][n2+1];
     for(int i=0;i<=n1;i++)
     {
          dp[i][0]=0;
     }
     for(int i=0;i<=n2;i++)
     {
          dp[0][i]=0;
     }
     for(int i=1;i<=n1;i++)
     {
          for(int j=1;j<=n2;j++)
          {
               if(s[i-1]==t[j-1])
               {
                    dp[i][j]=1+dp[i-1][j-1];
               }
               else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
               }
          }
     }
     string ans;
  int i=n1,j=n2;
  while(i!=0)
  {
       if(dp[i][j]==1+dp[i-1][j-1])
       {
         ans.pb(s[i-1]);
         i=i-1;
         j=j-1;   
       }
       else{
            i=i-1;

       }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<'\n';
 
}
return 0;
}

Compiler output:
a.cc:60:1: error: expected unqualified-id before 'return'
   60 | return 0;
      | ^~~~~~
a.cc:61:1: error: expected declaration before '}' token
   61 | }
      | ^
Language: C++

s1 = list(input())
s2 = list(input())
n = len(s1)
m = len(s2)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1, m+1):
        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])
res = []
i, j = n, m
while i > 0 and j > 0:
    if s1[i-1] == s2[j-1]:
        res.append(s1[i-1])
        i -= 1
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        j -= 1
print(''.join(res[::-1]))
        

Compiler output:
a.cc:23:7: error: empty character constant
   23 | print(''.join(res[::-1]))
      |       ^~
a.cc:1:1: error: 's1' does not name a type
    1 | s1 = list(input())
      | ^~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
int dp[3001][3001];

int f(string s1,string s2,int i,int j,int n,int m){
  if(i==n || j==m){return 0;}
  if(dp[i][j]!=-1){return dp[i][j];} 
  int ans;
  if(s1[i]==s2[j]){ ans = 1 + f(s1,s2,i+1,j+1,n,m);}
  else{
      ans = max(f(s1,s2,i+1,j,n,m),f(s1,s2,i,j+1,n,m));
  }
  dp[i][j] = ans;
  return ans;
}

void print_f(string s1,string s2,int i,int j,int n,int m,string &t){
    if(i==n || j==m){}
    else{
        if(s1[i]==s2[j]){t.pb(s1[i]); print_f(s1,s2,i+1,j+1,n,m,t);}
        else if(f(s1,s2,i+1,j,n,m)==f(s1,s2,i,j,n,m){ print_f(s1,s2,i+1,j,n,m,t);}
        else if(f(s1,s2,i,j+1,n,m)==f(s1,s2,i,j,n,m)){print_f(s1,s2,i,j+1,n,m,t);}
}
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
     memset(dp,-1,sizeof(dp));
     string s1,s2; cin>>s1>>s2;
     int n,m;
     n = s1.length(); m = s2.length();
     f(s1,s2,0,0,n,m);
     string t;
     print_f(s1,s2,0,0,n,m,t);
     cout<<t;
}


Compiler output:
a.cc: In function 'void print_f(std::string, std::string, int, int, int, int, std::string&)':
a.cc:68:53: error: expected ')' before '{' token
   68 |         else if(f(s1,s2,i+1,j,n,m)==f(s1,s2,i,j,n,m){ print_f(s1,s2,i+1,j,n,m,t);}
      |                ~                                    ^
      |                                                     )
a.cc:70:1: error: expected primary-expression before '}' token
   70 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void LCS(vector<char> s1,vector<char> s2){
	vector<vector<int>> ll(s2.size()+1);
	for(int i=0;i<s2.size()+1;i++){
		ll[i]=vector<int>(s1.size()+1);
		for(int j=0;j<s1.size()+1;j++){
			ll[i][j]=0;
		}		
	}
	for(int i=0;i<ll.size();i++){
		for(int j=0;j<ll[0].size();j++){
			cout<<ll[i][j]<<" ";
		}
		cout<<endl;
	}
	for(int i=1;i<ll.size();i++){
		for(int j=1;j<ll[0].size();j++){
			if(s1[j-1]==s2[i-1]){
				ll[i][j]=ll[i-1][j-1]+1;
			}
			else{
				ll[i][j]=max(ll[i-1][j],ll[i][j-1]);
			}
		}
	}
	vector<char> pt;
	int n=ll.size()-1;
	for(int i=0;i<ll[0].size()-1;i++){
		if(ll[n][i]!=ll[n][i+1]){
			cout<<s1[i]<<;
			pt.push_back(s1[i]);
		}
	}	
}
int main(){
	string s,t;
	cin>>s;
	cin>>t;
	vector<char> s1(s.begin(),s.end());
	vector<char> t1(t.begin(),t.end());	
	LCS(s1,t1);
	
}

Compiler output:
a.cc: In function 'void LCS(std::vector<char>, std::vector<char>)':
a.cc:31:38: error: expected primary-expression before ';' token
   31 |                         cout<<s1[i]<<;
      |                                      ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
int dp[3001][3001];

int f(string s1,string s2,int i,int j,int n,int m){
  if(i==n || j==m){return 0;}
  if(dp[i][j]!=-1){return dp[i][j];} 
  int ans;
  if(s1[i]==s2[j]){ ans = 1 + f(s1,s2,i+1,j+1,n,m);}
  else{
      ans = max(f(s1,s2,i+1,j,n,m),f(s1,s2,i,j+1,n,m));
  }
  dp[i][j] = ans;
  return ans;
}

void print_f(string s1,string s2,int i,int j,int n,int m,string &t){
    if(i==n || j==m){}
    else{
        if(dp[i+1][j]==dp[i][j]){ print_f(s1,s2,i+1,j,n,m,t);}
        else if(dp[i][j+1]==dp[i][j]){print_f(s1,s2,i,j+1,n,m,t);
        else{ t.pb(s1[i]); print_f(s1,s2,i+1,j+1,n,m,t); }
    }
}
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t; 
    // cin>>t;
    t=1;
    while(t--){
     memset(dp,-1,sizeof(dp));
     string s1,s2; cin>>s1>>s2;
     int n,m;
     n = s1.length(); m = s2.length();
     int q = f(s1,s2,0,0,n,m);
     string t;
     print_f(s1,s2,0,0,n,m,t);
     cout<<t;
    }
}


Compiler output:
a.cc: In function 'void print_f(std::string, std::string, int, int, int, int, std::string&)':
a.cc:69:9: error: expected '}' before 'else'
   69 |         else{ t.pb(s1[i]); print_f(s1,s2,i+1,j+1,n,m,t); }
      |         ^~~~
a.cc:68:38: note: to match this '{'
   68 |         else if(dp[i][j+1]==dp[i][j]){print_f(s1,s2,i,j+1,n,m,t);
      |                                      ^
a.cc: At global scope:
a.cc:72:1: error: expected declaration before '}' token
   72 | }
      | ^
Language: Java

import java.util.Scanner;
import java.util.*;
public class Main {



public static int LCS_DP(String s , String t) {
		int m = s.length();
		int n = t.length();
		int storage[][] = new int[m+1][n+1];
		storage[0][0] = 0;
		for (int i=0; i<=n; i++) {
			storage[0][i] = 0;
		}
		for (int j=0; j<=m; j++) {
			storage[j][0] = 0;
		}
		for (int i=1; i<=m;i++) {
			for (int j =1; j<=n;j++) {
				if(s.charAt(m-i) == t.charAt(m-j)) {
					storage[i][j] = 1+storage[i-1][j-1];
				}else {
					storage[i][j] = Math.max(storage[i][j-1], storage[i-1][j]);
				}
			}
		}
		return storage[m][n];
	}

public static void main(String[] args) {
		Scanner s= new Scanner(System.in);   
  
  		String s = s.next();
		String t = s.next();		
		System.out.println(LCS_DP(s,t));
	}
}

Compiler output:
Main.java:33: error: variable s is already defined in method main(String[])
  		String s = s.next();
  		       ^
Main.java:33: error: cannot find symbol
  		String s = s.next();
  		            ^
  symbol:   method next()
  location: variable s of type String
Main.java:34: error: cannot find symbol
		String t = s.next();		
		            ^
  symbol:   method next()
  location: variable s of type String
3 errors
Language: C++


dp =  [[-1 for i in range(3005)] for j in range(3005)]
s=''
t=''
k=0

def fun(iss,itt):

    if ((iss==len(s)) or (itt==len(t))):
        dp[iss][itt]=0
        return dp[iss][itt]

    elif dp[iss][itt]!=-1:
        return dp[iss][itt]

    ans=0
    if(s[iss]==t[itt]):
        ans=1+fun(iss+1,itt+1)
    ans = max(ans,fun(iss+1,itt))
    ans = max(ans, fun(iss , itt+1))
    dp[iss][itt] = ans
    return dp[iss][itt]

s=input()
t=input()
val=fun(0,0)
ans=''
idx_s=0
idx_t=0

while idx_s<len(s) and idx_t<len(t):
    if (dp[idx_s+1][idx_t+1]==dp[idx_s][idx_t]-1) and s[idx_s]==t[idx_t] and dp[idx_s][idx_t]!=0:
        ans+=s[idx_s]
        idx_s+=1
        idx_t+=1
    elif dp[idx_s][idx_t]==dp[idx_s+1][idx_t]:
        idx_s+=1
    else:
        idx_t+=1

print(ans)


Compiler output:
a.cc:3:3: error: empty character constant
    3 | s=''
      |   ^~
a.cc:4:3: error: empty character constant
    4 | t=''
      |   ^~
a.cc:27:5: error: empty character constant
   27 | ans=''
      |     ^~
a.cc:2:1: error: 'dp' does not name a type
    2 | dp =  [[-1 for i in range(3005)] for j in range(3005)]
      | ^~
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf 1e9 + 1
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
//#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
/*#define MAX 3000
void mayank()
{
    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
}*/
int dp[MAX + 1][MAX + 1];
string getLCS(string& s, string& t, int len)
{
    string LCS;
    int i = 0, j = 0;
    while (len > 0)
    {
        if (s[i] == t[j])
        {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else
        {
            if (dp[i][j + 1] > dp[i + 1][j])
                j++;
            else i++;
        }
    }
    return LCS;
}

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] == t[j])
        return dp[i][j] = 1 + lenLCS(s, t, i + 1, j + 1);
    else
    {
        return dp[i][j] = max(lenLCS(s, t, i, j + 1), lenLCS(s, t, i + 1, j));
    }
}

string solve(string s, string t)
{
    memset(dp, -1, sizeof dp);
    int len = lenLCS(s, t, 0, 0);
    return getLCS(s, t, len);
}

int main() {
   // mayank();
    string s, t;
    cin >> s >> t;
    cout << solve(s, t);
}

Compiler output:
a.cc:21:8: error: 'MAX' was not declared in this scope
   21 | int dp[MAX + 1][MAX + 1];
      |        ^~~
a.cc:21:17: error: 'MAX' was not declared in this scope
   21 | int dp[MAX + 1][MAX + 1];
      |                 ^~~
a.cc: In function 'std::string getLCS(std::string&, std::string&, int)':
a.cc:37:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   37 |             if (dp[i][j + 1] > dp[i + 1][j])
      |                 ^~
      |                 dup
a.cc: In function 'int lenLCS(std::string&, std::string&, int, int)':
a.cc:50:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   50 |     if (dp[i][j] != -1)
      |         ^~
      |         dup
a.cc:54:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   54 |         return dp[i][j] = 1 + lenLCS(s, t, i + 1, j + 1);
      |                ^~
      |                dup
a.cc:57:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   57 |         return dp[i][j] = max(lenLCS(s, t, i, j + 1), lenLCS(s, t, i + 1, j));
      |                ^~
      |                dup
a.cc: In function 'std::string solve(std::string, std::string)':
a.cc:63:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
   63 |     memset(dp, -1, sizeof dp);
      |            ^~
      |            dup
Language: C++

#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);

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

    ll dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));

    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]);
        }
    }
    
    string ans="";
    int len=dp[n][m]-1;
    int i=n, j=m;

    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans += s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }

    int str=0;
    while(str<len){
        swap(ans[str], ans[len]);
        str++;
        len--;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'memset' was not declared in this scope
   15 |     memset(dp, 0, sizeof(dp));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<vector>
  +++ |+#include <cstring>
    3 | using namespace std;