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

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



int main(){
	string s, t;
	cin >> s >> t;
	int ss = s.size(), ts = t.size();
	vector<vector<pair<string,int> > > res = new vector<vector<pair<string,int> > >(ss + 1, vector<pair<string, int> >(ts + 1, make_pair("", 0)));
	for(int i = 1; i <= ss; i++){
		for(int j = 1; j <=ts; j++){
			if(s[i - 1] ==  t[j - 1]){
				res[i][j].second = res[i-1][j-1].second + 1;
				res[i][j].first = res[i-1][j-1].first + s[i-1];
			}else{
				if(res[i-1][j].second >= res[i][j-1].second){
					res[i][j].second = res[i-1][j].second;
					res[i][j].first = res[i-1][j].first;
				}else{
					res[i][j].second = res[i][j-1].second;
					res[i][j].first = res[i][j-1].first;				
				}
			}
		}
	}
	
	cout << res[ss][ts].first << endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:50: error: conversion from 'std::vector<std::vector<std::pair<std::__cxx11::basic_string<char>, int> > >*' to non-scalar type 'std::vector<std::vector<std::pair<std::__cxx11::basic_string<char>, int> > >' requested
   10 |         vector<vector<pair<string,int> > > res = new vector<vector<pair<string,int> > >(ss + 1, vector<pair<string, int> >(ts + 1, make_pair("", 0)));
      |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int lcs[3005][3005];
string a, b;

int main() {
  cin >> a >> b;
  int la = a.length(), lb = b.length();
  for (int i = 0; i < la; i++) for (int j = 0; j < lb; j++) {
   	lcs[i][j] = max(lcs[i - 1][j - 1] + a[i] == a[j], max(lcs[i - 1][j], lcs[i][j - 1])); 
  }
  cout << lcs[la - 1][lb - 1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: no matching function for call to 'max(bool, const int&)'
   11 |         lcs[i][j] = max(lcs[i - 1][j - 1] + a[i] == a[j], max(lcs[i - 1][j], lcs[i][j - 1]));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:11:24: note:   deduced conflicting types for parameter 'const _Tp' ('bool' and 'int')
   11 |         lcs[i][j] = max(lcs[i - 1][j - 1] + a[i] == a[j], max(lcs[i - 1][j], lcs[i][j - 1]));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:11:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'bool'
   11 |         lcs[i][j] = max(lcs[i - 1][j - 1] + a[i] == a[j], max(lcs[i - 1][j], lcs[i][j - 1]));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

string func(string x,string y){
  
  long long n=x.length(),m=y.length();
  
  long long 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(x[i-1]==y[j-1])
          dp[i][j]=1+dp[i-1][j-1];
        else
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        
      }
            
    }
  int i=n,j=m;
  string xx="";
  while(i>0&&j>0){
   
    if(x[i-1]==y[j-1]){
      xx+=x[i-1];
      i--;
      j--;
    }else{
     
      if(dp[i-1][j]<dp[i][j-1])
        j--;
      else
        i--;
      
    }
    
  }
  return reverse(xx.begin(),xx.end());
}

int main(){
  
  string x,y;
  cin>>x>>y;
  
  cout<<func(x,y)<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'std::string func(std::string, std::string)':
a.cc:43:17: error: could not convert 'std::reverse<__gnu_cxx::__normal_iterator<char*, __cxx11::basic_string<char> > >(xx.std::__cxx11::basic_string<char>::begin(), xx.std::__cxx11::basic_string<char>::end())' from 'void' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   43 |   return reverse(xx.begin(),xx.end());
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 void
Language: Java


import java.util.Scanner;

public class F {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int x = s.length()+1;
        int y = t.length()+1;
        int[][] dp = new int[x][y];
        for(int i = 0; i<x;i++){
            for(int j = 0; j<y;j++){
                if(i==0||j==0){
                    dp[i][j] = 0;
                } else if (s.charAt(i-1)==t.charAt(j-1)){
                    dp[i][j]=dp[i-1][j-1]+1;
                } else {
                    dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
                }
            }
        }
        StringBuilder sol = new StringBuilder();
        int i = x-1;
        int j = y-1;
        while(true){
            if(i<=0||j<=0)
                break;
            if(s.charAt(i-1)==t.charAt(j-1)){
                sol.insert(0, Character.toString(s.charAt(i-1)));
                i--;
                j--;
            } else if(dp[i][j]==dp[i][j-1]){
                j--;
            } else if(dp[i][j]==dp[i-1][j]){
                i--;
            }

        }
        System.out.println(sol.toString());

    }
}


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

#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
string s,t,ans="";
int f[3003][3003];
pair <int,int> g[3003][3003];

int main(){
	cin>>s>>t;
	int sl=s.size(),tl=t.size();
	for (int i=0;i<sl;i++){
		f[i][0]=0;
	}
	for (int i=0;i<tl;i++){
		f[0][i]=0;
	}
	for (int i=0;i<sl;i++){
		for (int j=0;j<tl;j++){
			if (s[i]==t[j]){
				if (i-1<0 || j-1<0) f[i][j]=1;
				else f[i][j]= f[i-1][j-1]+1;
				g[i][j]=make_pair<int, int>(i,j);
			}
//			f[i][j]=max(f[i-1][j],f[i][j-1]);
			if (i>0)
				if (f[i-1][j] > f[i][j]) {
					f[i][j]=f[i-1][j];
					g[i][j]=g[i-1][j];
				}
			if (j>0)
				if (f[i][j-1] > f[i][j]) {
					f[i][j]=f[i][j-1];
					g[i][j]=g[i][j-1];
				}
		}
	}
//	cout<<endl<<f[0][0]<<endl;
	int i=sl-1,j=tl-1;
	while (f[i][j]>0){
		ans+=s[g[i][j].first];
		int i1=i;
		if (g[i1][j].first-1<0 || g[i1][j].second-1<0) break;
		i=g[i1][j].first-1;
		j=g[i1][j].second-1;
	}
	if (ans==""){
		cout<<" "<<endl;
		return 0;
	}
	for (int i=ans.size()-1;i>=0;i--){
		cout<<ans[i];
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:61: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   23 |                                 g[i][j]=make_pair<int, int>(i,j);
      |                                                             ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~
Language: C++

#include <iostream>
#include <string>
using namespace std;
string s,t,ans="";
int f[3003][3003];
pair <int,int> g[3003][3003];

int main(){
	cin>>s>>t;
	int sl=s.size(),tl=t.size();
	for (int i=0;i<sl;i++){
		f[i][0]=0;
	}
	for (int i=0;i<tl;i++){
		f[0][i]=0;
	}
	for (int i=0;i<sl;i++){
		for (int j=0;j<tl;j++){
			if (s[i]==t[j]){
				if (i-1<0 || j-1<0) f[i][j]=1;
				else f[i][j]= f[i-1][j-1]+1;
				g[i][j]=make_pair<int, int>(i,j);
			}
//			f[i][j]=max(f[i-1][j],f[i][j-1]);
			if (i>0)
				if (f[i-1][j] > f[i][j]) {
					f[i][j]=f[i-1][j];
					g[i][j]=g[i-1][j];
				}
			if (j>0)
				if (f[i][j-1] > f[i][j]) {
					f[i][j]=f[i][j-1];
					g[i][j]=g[i][j-1];
				}
		}
	}
//	cout<<endl<<f[0][0]<<endl;
	int i=sl-1,j=tl-1;
	while (f[i][j]>0){
		ans+=s[g[i][j].first];
		int i1=i;
		if (g[i1][j].first-1<0 || g[i1][j].second-1<0) break;
		i=g[i1][j].first-1;
		j=g[i1][j].second-1;
	}
	if (ans==""){
		cout<<" "<<endl;
		return 0;
	}
	for (int i=ans.size()-1;i>=0;i--){
		cout<<ans[i];
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:61: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   22 |                                 g[i][j]=make_pair<int, int>(i,j);
      |                                                             ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// get longest common subsequence, O(s.length() * t.length())
struct LCS {
    vvi dp;
    string s, t;
    LCS(string s, string t) : s(s), t(t) {
        dp.assign(s.size() + 1, vi(t.size() + 1, 0));
        for (int i = 1; i <= s.size(); ++i) {
            for (int j = 1; j <= t.size(); ++j) {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                chmax(dp[i][j], dp[i][j - 1]);
                chmax(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    int length() { return dp[s.size()][t.size()]; }
    string restore() {
        string ret　＝ "";
        int sidx = s.size();
        int tidx = t.size();
        int retidx = length() - 1;
        while (sidx > 0 && tidx > 0) {
            if (s[sidx - 1] == t[tidx - 1]) {
                ret = s[sidx - 1] + ret;
                --retidx;
                --sidx;
                --tidx;
            } else if (dp[sidx][tidx] == dp[sidx - 1][tidx])
                --sidx;
            else
                --tidx;
        }
        return ret;
    }
};

int main() {
    string s, t;
    cin >> s >> t;
    LCS lcs(s, t);
    cout << lcs.restore() << "\n";
    return 0;
}

Compiler output:
a.cc:39:16: error: extended character 　 is not valid in an identifier
   39 |         string ret　＝ "";
      |                ^
a.cc: In member function 'std::string LCS::restore()':
a.cc:39:24: error: expected initializer before string constant
   39 |         string ret　＝ "";
      |                        ^~
a.cc:45:17: error: 'ret' was not declared in this scope
   45 |                 ret = s[sidx - 1] + ret;
      |                 ^~~
a.cc:54:16: error: 'ret' was not declared in this scope
   54 |         return ret;
      |                ^~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// get longest common subsequence, O(s.length() * t.length())
struct LCS {
    vvi dp;
    string s, t;
    LCS(string s, string t) : s(s), t(t) {
        dp.assign(s.size() + 1, vi(t.size() + 1, 0));
        for (int i = 1; i <= s.size(); ++i) {
            for (int j = 1; j <= t.size(); ++j) {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                chmax(dp[i][j], dp[i][j - 1]);
                chmax(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    int length() { return dp[s.size()][t.size()]; }
    string restore() {
        string ret = "";
        deque<char> temp;
        temp.reserve(length());
        int sidx = s.size();
        int tidx = t.size();
        while (sidx > 0 && tidx > 0) {
            if (s[sidx - 1] == t[tidx - 1]) {
                temp.push_front(s[sidx - 1]);
                --sidx;
                --tidx;
            } else if (dp[sidx][tidx] == dp[sidx - 1][tidx])
                --sidx;
            else
                --tidx;
        }
        for (auto &ch : temp) {
            ret += ch;
        }
        return ret;
    }
};

int main() {
    string s, t;
    cin >> s >> t;
    LCS lcs(s, t);
    cout << lcs.restore() << "\n";
    return 0;
}

Compiler output:
a.cc: In member function 'std::string LCS::restore()':
a.cc:41:14: error: 'class std::deque<char>' has no member named 'reserve'
   41 |         temp.reserve(length());
      |              ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 1000003
#define INF 1e9
void lcs(int m, int n, char *s , char *d){
    int i,j;
	int dp[m+1][n+1];
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			if(i==0 or j==0)
			dp[i][j]=0;
			else if(s[i-1]==d[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[m][n];
	i =m;
	j=n;
	char ans[index+1];
	ans[index] = '\0';
	while(i>0 or j>0){
		if(s[i-1] == d[j-1]){
			ans[index-1]=s[i-1];
			i--;
			j--;
			index--;
		}else{
			if(dp[i-1][j]>dp[i][j-1]) i--;
			else j--;
		}
	}	
	cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,w,i,j,t,k,l,r;
   	char s[3001],d[3001];
   	gets(s);
   	gets(d);
   	lcs(strlen(s),strlen(d),s,d);
   	
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   45 |         gets(s);
      |         ^~~~
      |         getw
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<<"\n"; 
} 

/* Driver program to test above function */
int main() 
{ 
char X[] = "AGGTAB"; 
char Y[] = "GXTXAYB"; 
int m = strlen(X); 
int n = strlen(Y); 
string s, t;
  cin>>s>>t;
  m = s.length();
  n = t.length();
lcs(s, t, m, n); 
return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:70:5: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
   70 | lcs(s, t, 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++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:40: error: expected ']' before ';' token
   19 |         cout<<dp[s.length()][t.length();
      |                                        ^
      |                                        ]
Language: C++

#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << "=" << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 3001;
const int MD = 1e9 + 7;

void solve() {
    std::string s, t;
    in(s); in(t);

    int n = (int) s.size();
    int m = (int) t.size();

    int dp[n][m];
    dp[0][0] = (s[0] == t[0]);
    repr(i, 1, n) dp[i][0] = (s[i] == t[0]) or dp[i - 1][0];
    repr(j, 1, m) dp[0][j] = (s[0] == t[j]) or dp[0][j - 1];

    repr(i, 1, n) repr(j, 1, m) {
        int t = std::max(dp[i - 1][j], dp[i][j - 1]);
        if (s[i] == t[j]) t = dp[i - 1][j - 1] + 1;

        dp[i][j] = t;
    }

    std::string ans;
    int i = n - 1, j = m - 1;
    while (1) {
        if (s[i] == t[j]) {
            ans = s[i] + ans;
            --i, --j;
        } else {
            if (dp[i][j] == dp[i - 1][j]) --i;
            else --j;
        }
    }

    assert((int) ans.size() == dp[n - 1][m - 1]);
    out(ans);

}

int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:48:22: error: invalid types 'int[int]' for array subscript
   48 |         if (s[i] == t[j]) t = dp[i - 1][j - 1] + 1;
      |                      ^
Language: C++

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



int main()
{
  using PII = pair<int, int>;
  string s,t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  vector<vector<int>> lcs(n + 1, vector<int>(m + 1));
  vector<vector<PII>> parent(n + 1, vector<PII>(m + 1));
  for (int i = 1; i <= s.size(); ++i) {
    for (int j = 1; j <= t.size(); ++j) {
      lcs[i][j] = lcs[i-1][j];
      parent[i][j] = {i-1, j};
      if (lcs[i][j-1] > lcs[i-1][j]) {
        lcs[i][j] = lcs[i][j-1];
        parent[i][j] = {i, j-1};
      }
      if (s[i-1] == t[j-1]) {
        lcs[i][j] = lcs[i-1][j-1] + 1;
        parent[i][j] = {i - 1, j - 1};
      }
    }
  }

  string res;
  int i = n, j = m;
  while (i > 0 and j > 0) {
    if (parent[i][j] == make_pair(i-1, j-1))
      res += s[i-1];
    i = parent[i][j].first;
    j = parent[i][j].second;
  }
  reverse(res.begin(), res.end());
  cout << res << '\n';


  return 0;
}


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

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

int main()
{
    string s1, t1;
    cin>>s1>>t1;
    char s[s1.length()],t[t1.length()];
    int dp[s1.length()+1][t1.length()+1];
    strcpy(s,s1.c_str());
    strcpy(t,t1.c_str());
    for(int i=0;i<=t1.length();i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=s1.length();i++)
    {
        for(int j=1;j<=t1.length();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+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[s1.length()][t1.length()]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:31: error: request for member 'length' in 'dp[(i - 1)][j]', which is of non-class type 'int'
   27 |                 if(dp[i-1][j].length()>=dp[i][j-1].length())
      |                               ^~~~~~
a.cc:27:52: error: request for member 'length' in 'dp[i][(j - 1)]', which is of non-class type 'int'
   27 |                 if(dp[i-1][j].length()>=dp[i][j-1].length())
      |                                                    ^~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s,t;
    cin>>s>>t;
    vector<vector<int> > dp(s.length()+10,vector<int> (t.length()+10));
    rep(i,s.length()+10)rep(j,t.length()+10)dp[i][j]=0;
    for(int i=0;i<s.length();i++){
        for(int j=0;j<t.length();j++){
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string ans="";
    int i=s.length(),j=t.length();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout<<dp[s.length()][t.length()]<<endl;
//////////////////////////////////////////////////////
return 0;}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:13: error: 'res' was not declared in this scope; did you mean 'rep'?
   72 |             res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
      |             ^~~
      |             rep
Language: C++

#include<bits/stdc++.h>
 
#define ll long long
ll mod = 1e9+7;
const int MAX = 1e5+5;
using namespace std;
 
ll dp[3003][3003]; //represents length LCS between substring ending at ith index of s1 and jth index of s2
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.size(); int m=s2.size();
 
    for(int i=0;i<=n;i++) {
        for (int j = 0; j <= m; j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
                continue;
            }
 
            if (s1[i-1] == s2[j-1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = dp[i][j - 1];
                }
            }
        }
    }

    for (int i = 0; i < m; ++i) cout << "\t" << s2[i];
    cout << endl;
    for (int i = 0; i <= n; ++i) {
        cout << s1[i-1] << "\t";
        for (int j = 0; j <= m; ++j) {
            cout << dp[i][j] << "\t";
        }
        cout << endl;
    }

    string ans="";
    int tot=dp[n][m];
    int i=n; int j=m;
 
    for(int len=tot;len>0;){
        if(s1[i-1]==s2[j-1]){
            ans+=s1[i-1];
            i--; j--;
            len--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(all(ans));
    cout<<ans;
    return 0;
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:13: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   67 |     reverse(all(ans));
      |             ^~~
      |             std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

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

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

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

Compiler output:
a.cc:31:17: error: empty character constant
   31 |    lcs[index] = ''; // Set the terminating character
      |                 ^~
a.cc: In function 'int main()':
a.cc:65:7: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int'
   65 |   lcs(X, Y, m, n);
      |       ^
      |       |
      |       std::string {aka std::__cxx11::basic_string<char>}
a.cc:7:14: note:   initializing argument 1 of 'void lcs(int, int)'
    7 | void lcs(int m, int n )
      |          ~~~~^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  string s,t;cin>>s>>t;
  int ssz=s.size();
  int tsz=t.size();
  P b[ssz+1][tsz+1];
  rep(i,ssz+1) rep(j,tsz+1) b[i][j]=P(-1,-1);

  int dp[ssz+1][tsz+1]={};
  rep(i,ssz){
    rep(j,tsz){
      if(s[i]==t[j]){
        dp[i+1][j+1]=dp[i][j]+1;
        b[i+1][j+1]=P(i,j);
      }
      else{
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
        if(dp[i+1][j]>dp[i][j+1]){
          b[i+1][j+1]=P(i+1,j);
        }
        else b[i+1][j+1]=P(i,j+1);
      }
    }
  }
  int p=ssz;int q=tsz;
  string ans;
  while(ans.size()!=dp[ssz][tsz]){
    if(dp[p][q]!=dp[b[p][q].first][b[p][q].second]){
      ans.push_back(s[p-1]);
    }
    p=b[p][q].first;
    q=b[p][q].second;
  }
  rep(i,ans.size()){
    int j=ans.size()-1-i;
    cout<<ans[j];
  }
  cout<<endl;
  if(ans.size==dp[ssz][tsz])exit(1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:10: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   51 |   if(ans.size==dp[ssz][tsz])exit(1);
      |      ~~~~^~~~
      |              ()
Language: C++

    /* Dynamic Programming C/C++ implementation of LCS problem */
    #include<bits/stdc++.h> 
       
    int max(int a, int b); 
       
    /* Returns length of LCS for X[0..m-1], Y[0..n-1] */
    int lcs( char *X, char *Y, int m, int n ) 
    { 
       int L[m+1][n+1]; 
       int i, j; 
       
       /* 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 (i=0; i<=m; i++) 
       { 
         for (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]); 
         } 
       } 
         
       /* L[m][n] contains length of LCS for X[0..n-1] and Y[0..m-1] */
       return L[m][n]; 
    } 
       
    /* Utility function to get max of 2 integers */
    int max(int a, int b) 
    { 
        return (a > b)? a : b; 
    } 
       
    /* Driver program to test above function */
    int main() 
    { 
      char[3005] X;
      char[3005] Y;
      
      scanf("%s",X);
      scanf("%s",Y);
       
      int m = strlen(X); 
      int n = strlen(Y); 
       
      printf("%d\n", lcs( X, Y, m, n ) ); 
      
      return 0; 
    } 

Compiler output:
a.cc: In function 'int main()':
a.cc:42:12: error: expected identifier before numeric constant
   42 |       char[3005] X;
      |            ^~~~
a.cc:42:12: error: expected ']' before numeric constant
   42 |       char[3005] X;
      |            ^~~~
      |            ]
a.cc:42:11: error: structured binding declaration cannot have type 'char'
   42 |       char[3005] X;
      |           ^
a.cc:42:11: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:42:11: error: empty structured binding declaration
a.cc:42:18: error: expected initializer before 'X'
   42 |       char[3005] X;
      |                  ^
a.cc:43:12: error: expected identifier before numeric constant
   43 |       char[3005] Y;
      |            ^~~~
a.cc:43:12: error: expected ']' before numeric constant
   43 |       char[3005] Y;
      |            ^~~~
      |            ]
a.cc:43:11: error: structured binding declaration cannot have type 'char'
   43 |       char[3005] Y;
      |           ^
a.cc:43:11: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:43:11: error: empty structured binding declaration
a.cc:43:18: error: expected initializer before 'Y'
   43 |       char[3005] Y;
      |                  ^
a.cc:45:18: error: 'X' was not declared in this scope
   45 |       scanf("%s",X);
      |                  ^
a.cc:46:18: error: 'Y' was not declared in this scope
   46 |       scanf("%s",Y);
      |                  ^
Language: C++

    /* Dynamic Programming C/C++ implementation of LCS problem */
    #include<bits/stdc++.h> 
       
    int max(int a, int b); 
       
    /* Returns length of LCS for X[0..m-1], Y[0..n-1] */
    int lcs( char *X, char *Y, int m, int n ) 
    { 
       int L[m+1][n+1]; 
       int i, j; 
       
       /* 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 (i=0; i<=m; i++) 
       { 
         for (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]); 
         } 
       } 
         
       /* L[m][n] contains length of LCS for X[0..n-1] and Y[0..m-1] */
       return L[m][n]; 
    } 
       
    /* Utility function to get max of 2 integers */
    int max(int a, int b) 
    { 
        return (a > b)? a : b; 
    } 
       
    /* Driver program to test above function */
    int main() 
    { 
      string X;
      string Y;
      
      cin >> X >> Y;
       
      int m = X.size(); 
      int n = Y.size(); 
       
      printf("%d\n", lcs( X, Y, m, n ) ); 
      
      return 0; 
    } 

Compiler output:
a.cc: In function 'int main()':
a.cc:42:7: error: 'string' was not declared in this scope
   42 |       string X;
      |       ^~~~~~
a.cc:42:7: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:2:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:43:13: error: expected ';' before 'Y'
   43 |       string Y;
      |             ^~
      |             ;
a.cc:45:7: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   45 |       cin >> X >> Y;
      |       ^~~
      |       std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:45:14: error: 'X' was not declared in this scope
   45 |       cin >> X >> Y;
      |              ^
a.cc:45:19: error: 'Y' was not declared in this scope
   45 |       cin >> X >> Y;
      |                   ^
Language: C++


/* Dynamic Programming C/C++ implementation of LCS problem */
#include<bits/stdc++.h> 
   
int max(int a, int b); 
   
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
int lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   int i, j; 
   
   /* 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 (i=0; i<=m; i++) 
   { 
     for (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]); 
     } 
   } 
     
   /* L[m][n] contains length of LCS for X[0..n-1] and Y[0..m-1] */
   return L[m][n]; 
} 
   
/* Utility function to get max of 2 integers */
int max(int a, int b) 
{ 
    return (a > b)? a : b; 
} 
   
/* Driver program to test above function */
int main() 
{ 
  string X;
  string Y;
  
  cin >> X >> Y;
   
  int m = strlen(X); 
  int n = strlen(Y); 
   
  printf("%d\n", lcs( X, Y, m, n ) ); 
  
  return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:43:3: error: 'string' was not declared in this scope
   43 |   string X;
      |   ^~~~~~
a.cc:43:3: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:44:9: error: expected ';' before 'Y'
   44 |   string Y;
      |         ^~
      |         ;
a.cc:46:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   46 |   cin >> X >> Y;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:46:10: error: 'X' was not declared in this scope
   46 |   cin >> X >> Y;
      |          ^
a.cc:46:15: error: 'Y' was not declared in this scope
   46 |   cin >> X >> Y;
      |               ^
Language: Java

import java.util.Scanner;

public class LCS {

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

    String[][] dp = new String[s.length() + 1][t.length() + 1];
    for (int i = 0; i <= s.length(); i++) {
      for (int j = 0; j <= t.length(); j++) {
        dp[i][j] = "";
      }
    }

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

    System.out.println(dp[s.length()][t.length()]);
  }
}

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: 'elif' was not declared in this scope
   35 |     elif(dp[n][m] == dp[n][m-1])
      |     ^~~~
a.cc:37:5: error: 'else' without a previous 'if'
   37 |     else{
      |     ^~~~
a.cc:42:21: error: expected ';' before 'cout'
   42 |   }while(n!=0&&m!=0)
      |                     ^
      |                     ;
   43 |   cout<<res<<endl;
      |   ~~~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: 'elif' was not declared in this scope
   35 |     elif(dp[n][m] == dp[n][m-1])
      |     ^~~~
a.cc:42:21: error: expected ';' before 'cout'
   42 |   }while(n!=0&&m!=0)
      |                     ^
      |                     ;
   43 |   cout<<res<<endl;
      |   ~~~~