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

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

const int max_len = 3010;
char s[max_len];
char t[max_len];
int dp[max_len][max_len];
int chmax(int a, int b)
{
	if (a > b)
		return a;
	return b;
}
int main(int argc, char const *argv[])
{
	scanf("%s%s", s, t);
	int lens = strlen(s);
	int lent = strlen(t);
	for (int i = 0; i < lens; i++)
	{
		for (int j = 0; j < lent; j++)
		{
			if(s[i]==t[j])
				dp[i+1][j+1] = chmax(dp[i+1][j+1], dp[i][j] + 1);
			dp[i+1][j+1] = chmax(dp[i+1][j+1], dp[i+1][j]);
			dp[i+1][j+1] = chmax(dp[i+1][j+1], dp[i][j+1]);
		}
	}
	int i = dp[lens][lent];
	char res[i];
	res[i] = '\0';
	while(lens > 0 && lent > 0)
	{
		if(dp[lens][lent] == dp[lens-1][lent])
			--lens;
		else if(dp[lens][lent] == dp[lens][lent-1])
			--lent;
		else
		{
			--i;
			res[i] = s[lens - 1];
			--lens;
			--lent;
		}
	}
	printf("%s\n", res);
	return 0;
}


Compiler output:
main.c:5:6: error: variably modified 's' at file scope
    5 | char s[max_len];
      |      ^
main.c:6:6: error: variably modified 't' at file scope
    6 | char t[max_len];
      |      ^
main.c:7:5: error: variably modified 'dp' at file scope
    7 | int dp[max_len][max_len];
      |     ^~
main.c:7:5: error: variably modified 'dp' at file scope
Language: Java

import java.util.*;
public class Main
{
   int l1,l2;
   String str;
   String s1,s2;
   String memo[][];
   memok(String s1,String s2)
   {
       this.s1=s1+"";
       this.s2=s2+"";
       l1=s1.length();
        l2=s2.length();
       memo=new String[l1][l2];
       for(int i=0;i<l1;i++)
       {
           for(int j=0;j<l2;j++)
           memo[i][j]="";
        }
       
    }
    String lcs(int i,int j)
    {String ans;
        if(i==l1||j==l2)
            {
                return "";
            }
                
        if(memo[i][j]!="")
        {
            return(memo[i][j]);
        }
        else
        {
            if(s1.charAt(i)==s2.charAt(j))
            {
                ans=s1.charAt(i)+lcs(i+1,j+1);
                memo[i][j]=ans;
              }
              else
              {
               if(lcs(i+1,j).length()>lcs(i,j+1).length())
               {
                   ans=lcs(i+1,j);
                }
                   else
                   {
                   ans=lcs(i,j+1);
                }
                 memo[i][j]=ans;
                }
               return(memo[i][j]);
         }
        }
    
        public static void main (String arge[])
        {
            String s1,s2;
            Scanner sc=new Scanner(System.in);
            s1=sc.nextLine();
            s2=sc.nextLine();
            Main obj=new Main(s1,s2);
            String s;
            s=obj.lcs(0,0);
            System.out.print(s);
        }
    }
            
            
        
    


Compiler output:
Main.java:8: error: invalid method declaration; return type required
   memok(String s1,String s2)
   ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
vector <char> v;
int dp[3005][3005];
void lcs(string s1,string s2,int m,int n)
{
  if(dp[i][j]!=-1)
    return dp[i][j];
  if(s1[i-1]==s2[j-1])
  {
    v.push_back(s1[i-1]);
    return dp[i][j]=lcs(s1,s2,i-1,j-1)+1;
  }
  return dp[i][j]=max(lcs(s1,s2,i-1,j),lcs(s1,s2,i,j-1));
}
int main()
{
  string s1;
  string s2;
  cin>>s1>>s2;
  int m=s1.length();
  int n=s2.length();
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<m;i++)
    dp[0][i]=1;
  for(int j=0;j<n;j++)
    dp[j][0]=0;
  lcs(s1,s2,m-1,n-1);
}

Compiler output:
a.cc: In function 'void lcs(std::string, std::string, int, int)':
a.cc:7:9: error: 'i' was not declared in this scope
    7 |   if(dp[i][j]!=-1)
      |         ^
a.cc:7:12: error: 'j' was not declared in this scope
    7 |   if(dp[i][j]!=-1)
      |            ^
a.cc:9:9: error: 'i' was not declared in this scope
    9 |   if(s1[i-1]==s2[j-1])
      |         ^
a.cc:9:18: error: 'j' was not declared in this scope
    9 |   if(s1[i-1]==s2[j-1])
      |                  ^
a.cc:14:13: error: 'i' was not declared in this scope
   14 |   return dp[i][j]=max(lcs(s1,s2,i-1,j),lcs(s1,s2,i,j-1));
      |             ^
a.cc:14:16: error: 'j' was not declared in this scope
   14 |   return dp[i][j]=max(lcs(s1,s2,i-1,j),lcs(s1,s2,i,j-1));
      |                ^
Language: C++

#include<bits/stdc++.h>
#define int long long

using namespace std;

string lcs(string s, string t)
{
	int n = s.size(), m = t.size(), i, j;
    int d[n+1][m+1];
    for(i=0 ; i<=n ; i++)
    	for(j=0 ; j<=m ; j++)
    		d[i][j] = 0;
    for(i=1 ; i<=n ; i++)
    {
    	for(j=1 ; j<=m ; j++)
		{
			d[i][j] = max(d[i-1][j] , d[i][j-1]);
			if(s[i-1] == t[j-1])
				d[i][j] = max(d[i][j] , d[i-1][j-1]+1);
		}
    }
    int x=n, y=m;
    string ans;
    while(x>0 && y>0)
    {
    	if(x==0 || y==0) break;
    	while(d[x][y-1] == d[x][y] && y>0)//go left till end
    		y = y-1;
    	while(d[x-1][y] == d[x][y] && x>0)//go up
    		x = x-1;
    	if(x<=0 || y<=0) break;
    	if(d[x][y] == 0) break;
    	ans.pb(s[x-1]);
    	x = x-1;
    	y = y-1;
    }
    reverse(ans.begin() , ans.end());
    return ans;
}

signed main()
{
    string s,t;
    cin >> s >> t;
    string ans = lcs(s, t);
    cout << ans <<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'std::string lcs(std::string, std::string)':
a.cc:33:13: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'pb'
   33 |         ans.pb(s[x-1]);
      |             ^~
Language: C++

// https://atcoder.jp/contests/dp/tasks/dp_f
#include <bits/stdc++.h>
using namespace std;

string longer(string const& a, string const& b) {
  if (a.length() < b.length())
    return b;
  return a;
}

int main() {
  string a, b;
  cin >> a >> b;
  string lcs[2][t.length() + 1];

  for (int i = 1; i <= s.length() + 1; ++i)
    for (int j = 1; j <= t.length(); ++j) {
      lcs[i % 2][j] = longer(lcs[i % 2][j - 1], lcs[(i + 1) % 2][j]); 
      if (s[i - 1] == t[j - 1])
        lcs[i % 2][j] = lcs[(i + 1) % 2][j - 1] + s[i - 1];
    }
      
  cout << lcs[1][t.length()] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 't' was not declared in this scope
   14 |   string lcs[2][t.length() + 1];
      |                 ^
a.cc:16:24: error: 's' was not declared in this scope
   16 |   for (int i = 1; i <= s.length() + 1; ++i)
      |                        ^
a.cc:18:7: error: 'lcs' was not declared in this scope
   18 |       lcs[i % 2][j] = longer(lcs[i % 2][j - 1], lcs[(i + 1) % 2][j]);
      |       ^~~
a.cc:23:11: error: 'lcs' was not declared in this scope
   23 |   cout << lcs[1][t.length()] << endl;
      |           ^~~
Language: Java

import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
  String s=sc.next();
  String t=sc.next();
  String arr[][]=new String[s.length+1][t.length+1];
  for(int i=1;i<=t.length;i++){
  for(int j=1;j<=s.length;j++){
  if(arr[i-1][j].length()<j&&s.charAt(i)==t.charAt(j)){
  arr[i][j]=arr[i-1][j]+Character.toString(s.charAt(i));
  }
  }
  }
  System.out.println(arr[s.length][t.length]);
}
}

Compiler output:
Main.java:7: error: cannot find symbol
  String arr[][]=new String[s.length+1][t.length+1];
                             ^
  symbol:   variable length
  location: variable s of type String
Main.java:7: error: cannot find symbol
  String arr[][]=new String[s.length+1][t.length+1];
                                         ^
  symbol:   variable length
  location: variable t of type String
Main.java:8: error: cannot find symbol
  for(int i=1;i<=t.length;i++){
                  ^
  symbol:   variable length
  location: variable t of type String
Main.java:9: error: cannot find symbol
  for(int j=1;j<=s.length;j++){
                  ^
  symbol:   variable length
  location: variable s of type String
Main.java:15: error: cannot find symbol
  System.out.println(arr[s.length][t.length]);
                          ^
  symbol:   variable length
  location: variable s of type String
Main.java:15: error: cannot find symbol
  System.out.println(arr[s.length][t.length]);
                                    ^
  symbol:   variable length
  location: variable t of type String
6 errors
Language: C++

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

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;

#define trav(a, A) for (auto & a : A)

const int INF = 1e9;
const ll INFLL = 1e18;

int main ()
{
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    int i, j, n, w;
    string s, t;
    cin >> s >> t;
    vector <vi> dp (s.size () + 1, vi (t.size () + 1, 0));
    for (i = 1; i <= s.size (); ++i)
    {
        for (j = 1; j <= t.size (); ++j)
        {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = max (dp[i][j], dp[i - 1][j - 1] + 1);
            else
                dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
        }
    }
    for (i = s.size (), j = t.size (); i > 0 && j > 0;)
        if (dp[i-1][j] == dp[i][j]) --i;
        else if (dp[i][j - 1] == dp[i][j]) --j;
        else pilha.push_back (s[--i]), --j;
    while (pilha.size ())
    {
        cout << pilha.back ();
        pilha.pop_back ();
    }
    cout << '\n';

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: error: 'pilha' was not declared in this scope
   34 |         else pilha.push_back (s[--i]), --j;
      |              ^~~~~
a.cc:35:12: error: 'pilha' was not declared in this scope
   35 |     while (pilha.size ())
      |            ^~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

int  main()
{
    string a, b;
    cin>>a>>b;
    int la = a.length() , lb = b.length();
    vector<vector<int> > LCS(la, vector<int> (lb,0));
    int len =0;
    int row, col;
    for(int i=0; i<la; i++)
    {
        for(int j=0; j<lb; j++)
        {
            if(i==0 || j==0)
                LCS[i][j] = 0;
            else if (a[i] == b[j])
            {
                LCS[i][j] = 1 + LCS[i-1][j-1];
                if (len < LCS[i][j])
                {
                    len = LCS[i][j];
                    row=i;
                    col =j;
                }
            }
            else
                LCS[i][j] = 0;

        }
    }
    string s;
    while(LCS[row][col] != 0)
    {
        s+=a[row];
        row--;
        col-- }
    cout<<s;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:14: error: expected ';' before '}' token
   39 |         col-- }
      |              ^~
      |              ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
//ll min(ll a, ll b){
//    if(a>b){
//        return b;
//    }
//    return a;
//}
// 
//ll max(ll a, ll b){
//    if(a>b){
//        return a;
//    }
//    return b;
//}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);
const int pN=1e9 +7;
int main()
{	
	string a,b;
	cin>>a>>b;
	int n=a.len;
	int m=b.len;
	string dp[n][m];
	int ch=n;
	forl(i,0,n)
	{
		if(a[i]==b[0])
		{
			ch=i;
			break;	
		}

	}
	forl(i,0,n)
	{
		string s(1,b[0]);
		if(i>=ch)dp[i][0]=s;
		else dp[i][0]="";
	}
	ch=m;
	forl(j,0,m)
	{
		if(b[j]==a[0])
		{
			ch=j;	
			break;
		}
	}
	forl(j,0,m)
	{
		string s(1,a[0]);
		if(j>=ch)dp[0][j]=s;
		else dp[0][j]="";
		
	}
	forl(i,1,n)
	{
		forl(j,1,m)
		{
			if(a[i]==b[j])
			{
				string x;
				x=dp[i-1][j-1];
				x.pb(a[i]);
				dp[i][j]=x;
			 } 
			else
			{
				string y;
				if(dp[i-1][j].len>=dp[i][j-1].len)
				{
					dp[i][j]=dp[i-1][j];
				}else{
					dp[i][j]=dp[i][j-1];
				}
			 } 
		}
	}
//	forl(i,0,n)
//	{
//		forl(j,0,m) cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
abracadabra
avadakedavra	cout<<dp[n-1][m-1]<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:173:1: error: 'abracadabra' was not declared in this scope
  173 | abracadabra
      | ^~~~~~~~~~~
Language: Java

/*
    Those who cannot remember the past are condemned to repeat it.
                                            - Dynamic Programming
    
    I never lose, I either win or I learn.
                - Competitive Programming

*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        char[] c1 = br.readLine().toCharArray();
        char[] c2 = br.readLine().toCharArray();
        int n1 = c1.length;
        int n2 = c2.length;

        int[][] dp = new int[n1+1][n2+1];

        for(int i=1 ; i<=n1 ; i++) {
            for(int j=1 ; j<=n2 ; j++) {
                if(c1[i-1] == c2[j-1]) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                }
                else {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }

        char[] lcs = new char[dp[n1][n2]];

        int x = n1;
        int y = n2;
        int ind = lcs.length-1;
        while(x > 0 && y > 0) {
            if(c1[x-1] == c2[y-1]) {
                lcs[ind--] = c1[x-1];
                x--;
                y--;
            }
            else {
                if(dp[x][y] == dp[x-1][y]) {
                    x--;
                }
                else {
                    y--;
                }
            }
        }

        pw.println(lcs);

        
        
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}


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

#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    string s, t;
    cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    int maxi = -1;
    string res = "";
    vector<vector<int>> dp(n+1, vector<int>(m+1));
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            if (s.at(i) == t.at(j)) {
                dp.at(i+1).at(j+1) = dp.at(i).at(j) + 1;
                if (chmax(maxi, dp.at(i+1).at(j+1))) string.push_back(res.at(i));
            } else {
                dp.at(i+1).at(j+1) = max(dp.at(i).at(j), max(dp.at(i+1).at(j), dp.at(i).at(j+1)));
            }
        }
    }
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:31:60: error: expected unqualified-id before '.' token
   31 |                 if (chmax(maxi, dp.at(i+1).at(j+1))) string.push_back(res.at(i));
      |                                                            ^
Language: Java

/**
 * lcs
 */
import java.util.*;

import java.io.*;

import java.io.*;
public class lcs {
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    // for refrence
    //this is the recursive solution of lcs comparing from starting
 /*   public static int lcss(String s,String t,int i,int j){
        if(i==s.length()||j==t.length())
        return 0;
        if(s.charAt(i)==t.charAt(j))
        {
            return 1+lcss(s,t,i+1,j+1);
        }
        else{
            return Math.max(lcss(s,t,i,j+1),lcss(s,t,i+1,j));
        }
    }*/
    public static void main(String[] args) {
        FastReader sc=new FastReader();
        String s=sc.nextLine();
        String t=sc.nextLine();
       // System.out.println(lcss(s, t, 0,0));
       int n=s.length();
       int m=t.length();
        int dp[][]=new int[n+1][m+1];
        String res=new String();
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                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-1][j],dp[i][j-1]);
            }
        }
//////System.out.println(dp[n][m]);
        int i=n,j=m;
        while(i!=0&&j!=0){
            if(dp[i][j]==dp[i-1][j-1]+1&&dp[i-1][j]==dp[i][j-1]){
            res=s.charAt(i-1)+res;
            i--;
            j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
            i=i-1;
            else if(dp[i][j-1]>dp[i-1][j])
            j=j-1;
            else i=i-1;
        }
        System.out.println(res);
    }
}

Compiler output:
Main.java:9: error: class lcs is public, should be declared in a file named lcs.java
public class lcs {
       ^
1 error
Language: Java


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

public class LCS {
	static int[][] memo;
	static String s, t;
	static HashMap<String, String> hs = new HashMap<String, String>();
	static void trace(int i, int j){
		if(i > s.length() || j > t.length())
			return ;
		if(dp(i,j) == 1+dp(i+1,j+1))
		{
			System.out.print(s.charAt(i));
			trace(i+1,j+1);
		}
		else if(dp(i,j) == dp(i+1,j))
			trace(i+1,j);
		else if(dp(i,j) == dp(i,j+1))
			trace(i,j+1);
	}

	static int dp(int i, int j) {
		if (i == s.length() && j == t.length()) {
			return 0;
		}
		if(i>=s.length()||j>=t.length())
			return (int) -1e9;
		if (i < s.length() && j < t.length() && memo[i][j] != -1)
			return memo[i][j];

		if (i < s.length() && j < t.length() && s.charAt(i) == t.charAt(j))
			return memo[i][j] = 1 + dp(i + 1, j + 1);

		int iPlus = 0, jPlus = 0;

		if (i < s.length())
			iPlus = dp(i + 1, j);

		if (j < t.length())
			jPlus = dp(i, j + 1);

		int ret = Math.max(iPlus, jPlus);
		return memo[i][j] = ret;

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		t = sc.next();
		memo = new int[s.length() + 5][t.length() + 5];
		for (int[] a : memo)
			Arrays.fill(a, -1);
		trace(0,0);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

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

	}
}


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

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

string s = "", t = "", ans = "";
int sz1 = 0, sz2 = 0;

int mem[3010][3010];
int DP(long long i, long long j){

	if(i == sz1 || j == sz2)	return 0;
	if(mem[i][j] != -1)	return mem[i][j];

	long long opt1 = (s[i] == t[j]) ? 1+ DP(i+1, j+1) : 0;
	long long opt2 = DP(i, j+1);
	long long opt3 = DP(i+1, j);

	int mx = 0;
	mx = (mx > opt1) ? mx : opt1;
	mx = (mx > opt2) ? mx : opt2;
	mx = (mx > opt3) ? mx : opt3;

	return mem[i][j] = mx;
}

void trace(long long i, long long j){

	if(i == sz1 || j == sz2)	return;

	long long opt1 = (s[i] == t[j]) ? 1+ mem[i+1][j+1] : 0;
	long long opt2 = mem[i][j+1];
	long long opt3 = mem[i+1][j];

	int mx = 0;
	mx = (mx > opt1) ? mx : opt1;
	mx = (mx > opt2) ? mx : opt2;
	mx = (mx > opt3) ? mx : opt3;

	if(mx == opt1)	{
		if(s[i] == t[j]){
					ans += s[i]; trace(i+1, j+1);
		}
	}
	else if(mx == opt2) {trace(i, j+1);}
	else if(mx == opt3)	{trace(i+1, j);}

	return;
}


int main(){

	freopen("input", "r", stdin);
	freopen("output", "w", stdout);
	memset(mem, -1, sizeof mem);

	cin >> s >> t;
	sz1 = s.length();
	sz2 = t.length();

	DP(0,0);
	trace(0,0);

	else				cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:9: error: 'else' without a previous 'if'
   63 |         else                            cout << ans;
      |         ^~~~
Language: C++

/* Dynamic Programming C++ implementation of LCS problem */
#include<bits/stdc++.h> 
using namespace std; 

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 Code 
int main() 
{ 
	string X,Y;
  	cin >> X >> Y;
  	int m = X.length();
  	int n = Y.length();
	
	cout << lcs( X, Y, m, n )<<endl; 
	
	return 0; 
} 

// This code is contributed by rathbhupendra 


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

#include<bits/stdc++.h>
using namespace std;
int lcslen(string x,string y,int m,int n)
{
	if(m==0||n==0)
	return 0;
	if(x[m-1]==y[n-1])
	{
		return (lcslen(x,y,m-1,n-1)+1);
	}
		return max(lcslen(x,y,m,n-1),lcslen(x,y,m-1,n));
}
void printlcs(string s1,string s2,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(s1[i-1]==s2[j-1])
			L[i][j] = L[i-1][j-1]+1;
			else
			L[i][j] = max(L[i][j-1],L[i-1][j]);
		}
	}
	int l = L[m][n];
	int i=m,j=n;
	char r[l+1];
	r[l] = '\0';
	while(i>0&&j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			r[--l] = s1[i-1];
			i--;
			j--; 
		}
		else if(L[i-1][j]>L[i][j-1])
		{
			i--;
		}
		else 
		j--;
	}
	coutr<<endl;
}
int main()
{
	string a,b;
	cout<<"enter the two strings: ";
	cin>>a>>b;
	//int k=lcslen(a,b,a.length(),b.length());
	//cout<<k<<endl;
	printlcs(a,b,a.length(),b.length());
	return 0;
}

Compiler output:
a.cc: In function 'void printlcs(std::string, std::string, int, int)':
a.cc:47:9: error: 'coutr' was not declared in this scope
   47 |         coutr<<endl;
      |         ^~~~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
// #include <unordered_map>
#define vi vector <ull>
#define ii pair<ull,ull>
#define vii vector<ii>

#define seti set<ull>
#define mii map<ull,ull>
#define um unordered_map
#define ll long long
#define ull  long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100100
#define _ << " " <<

using namespace std;




void solve(){


	cin >> s >> t;

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

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

	dp[0][0] = "";

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			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];
				}
			}
		}
	}

	cout << dp[n][m];
}


int main(){
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ull q;
	// cin >> q;
	q = 1;
	for(ull i = 0; i < q; i++){
		// cout << "Case #" << i+1 << ":" << endl;

		solve();
		// cout << endl;
	}

	

	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:28:16: error: 's' was not declared in this scope; did you mean 'se'?
   28 |         cin >> s >> t;
      |                ^
      |                se
a.cc:28:21: error: 't' was not declared in this scope; did you mean 'tm'?
   28 |         cin >> s >> t;
      |                     ^
      |                     tm
a.cc:32:24: error: 'm' was not declared in this scope
   32 |         string dp[n+1][m+1];
      |                        ^
a.cc:34:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   34 |         dp[0][0] = "";
      |         ^~
      |         dup
Language: Java

import java.io.*;
import java.util.*;
public class tr7 {
static long[][] memo;
static int I,J;
static String h,s;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   h=sc.nextLine();
	   s=sc.nextLine();
	   I=h.length();
	   J=s.length();
	   memo=new long[3003][3003];
	   for(long []a:memo)
		   Arrays.fill(a,-1);
	   solve(0,0);
	 //  System.out.println(memo[0][0]);
	   trace(0,0);
	}
	static long solve(int i, int j)
	{
		if(i >= I || j >= J)
		{
			return 0;
		}
		if(memo[i][j] != -1)	return memo[i][j];
		long opt1 = solve(i + 1, j);
		long opt2 = solve(i, j + 1);
		long opt3 = s.charAt(j) == h.charAt(i) ? solve(i + 1, j + 1) + 1 : 0;
		return memo[i][j] =(long) Math.max(opt1, Math.max(opt2, opt3));
	}
//	static void trace(int i, int j)
//	{
//		if(i >= I || j >= J)	return;
//	 
//		long opt1 = solve(i + 1, j);
//		long opt2 = solve(i, j + 1);
//		if(s.charAt(i) == h.charAt(i))
//		{
//			System.out.println(s.charAt(j));
//			trace(i + 1, j + 1);
//			return; 
//		}
//		else if(opt2 > opt1)
//			trace(i, j + 1);
//		else
//			trace(i + 1, j);
//	 
//	}
	static void trace(int i,int j) {
		if(i==I || j==J)
			return;
		if(h.charAt(i)==s.charAt(j)) {
			System.out.print(s.charAt(j));
			trace(i+1,j+1);
			return;
		}
		if(solve(i+1,j)>solve(i,j+1))
			trace(i+1,j);
		else
			trace(i,j+1);
	}
//	static long dp(int i,int j) {
//		if(i==I || j==J)
//			return 0;
//		if(memo[i][j]!=-1)
//			return memo[i][j];
//		long v=0;
//		if(h.charAt(i)==s.charAt(j))
//	        	v=1+dp(i+1,j+1);
//		return memo[i][j]=Math.max(v, Math.max(dp(i,j+1),dp(i+1,j)));
//	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

import java.io.*;
import java.util.*;
public class tr7 {
static long[][] memo;
static int I,J;
static String h,s;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   h=sc.nextLine();
	   s=sc.nextLine();
	   I=h.length();
	   J=s.length();
	   memo=new long[I][J];
	   for(long []a:memo)
		   Arrays.fill(a,-1);
	   dp(0,0);
	   long max=0; int im=0; int jm=0;
	   for(int i=0;i<I;i++) {
		   for(int j=0;j<J;j++)
			   if(memo[i][j]>=max) {
				   max=memo[i][j];
				   im=i;
				   jm=j;
			   }
	   }
	   if(max==0) {
		   System.out.println(" ");
		   return;
	   }
	   trace(0,0);
	}
	static void trace(int i,int j) {
		if(i==I || j==J)
			return;
		if(h.charAt(i)==s.charAt(j)) {
			System.out.print(s.charAt(j));
			trace(i+1,j+1);
			return;
		}
		if(dp(i+1,j)>dp(i,j+1))
			trace(i+1,j);
		else
			trace(i,j+1);
	}
	static long dp(int i,int j) {
		if(i==I || j==J)
			return 0;
		if(memo[i][j]!=-1)
			return memo[i][j];
		long v=0;
		if(h.charAt(i)==s.charAt(j))
		v=1+dp(i+1,j+1);
		return memo[i][j]=Math.max(v, Math.max(dp(i,j+1),dp(i+1,j)));
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

#include<iostream>
#include<cmath>
#include<cstring> 
#include<stdio.h>
using namespace std;
int dp[3010][3010],fx[3010][3010];
char a[3010],b[3010];
int flag;
void printlcs(int x,int y){
	if(x<0||y<0) {
		return;
	}
	if(fx[x][y]==-1){
		printlcs(x-1,y-1);
		cout<<a[x];
	}
	else if(fx[x][y]==1){
		printlcs(x-1,y);
	}
	else if(fx[x][y]==2){
		printlcs(x,y-1);
	}
}
int main(){
	gets(a);
	gets(b);
	int lena=strlen(a);
	int lenb=strlen(b);
	for(int i=0;i<lena;i++){
		for(int j=0;j<lenb;j++){
			if(a[i]==b[j]) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1),fx[i][j]=-1;
			else if(dp[i-1][j]>=dp[i][j-1]) dp[i][j]=dp[i-1][j],fx[i][j]=1;
			else dp[i][j]=dp[i][j-1],fx[i][j]=2; 
		}
	}
	for(int i=0;i<lena;i++){
		for(int j=0;j<lenb;j++){		
		//	cout<<fx[i][j];
		}
		//cout<<endl;
	}
	printlcs(lena-1,lenb-1);
}
//https://atcoder.jp/contests/dp/tasks/dp_f

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

#include<cstdio>
#include<cstring>
#define maxn 3005
using namespace std;
int dp[maxn][maxn],last[maxn][maxn];
char s[maxn],t[maxn],w[maxn];
int main(){
    scanf("%s%s",s+1,t+1);
    int n=strlen(s+1),m=strlen(t+1);
    for (int i=1;i<=n;i++)
    for (int j=1;j<=m;j++){
        if (s[i]==t[j]) {
            if (dp[i][j]<dp[i-1][j-1]+1) dp[i][j]=dp[i-1][j-1]+1,last[i][j]=1;
        }
        if (dp[i-1][j]>dp[i][j]) dp[i][j]=dp[i-1][j],last[i][j]=2;
        if (dp[i][j-1]>dp[i][j]) dp[i][j]=dp[i][j-1],last[i][j]=3; 
    }
    int x=n,y=m;
    while (dp[x][y]){
        if (last[x][y]==1) w[dp[x][y]]=s[x],x--,y--;else
        if (last[x][y]==2) x--;else y--;
    }
    for (int i=1;i<=dp[n][m];i++)
    printf("%c",w[i]);
    printf("\n");
    return 0;
}

F

Compiler output:
a.cc:29:1: error: 'F' does not name a type
   29 | F
      | ^
Language: Java


import java.util.Scanner;

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

        int[][] dp = new int[s.length()+1][t.length()+1];


        for(int i = 1 ; i <= s.length();i++)
        {
            for(int j = 1 ; j <= t.length() ;j++)
            {
                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-1][j],dp[i][j-1]);
                }
            }
        }
        int i = s.length();
        int j = t.length();
        char[] lcs = new char[dp[i][j]];
        int index = lcs.length;
        while (i > 0 && j > 0)
        {
            // If current character in X[] and Y are same, then
            // current character is part of LCS
            if (s.charAt(i-1) == t.charAt(j-1))
            {
                // Put current character in result
                lcs[index-1] = s.charAt(i-1);

                // reduce values of i, j and index
                i--;
                j--;
                index--;
            }
            // If not same, then find the larger of two and
            // go in the direction of larger value
            else if (dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }
        StringBuilder b = new StringBuilder();
        for(i  = 0 ; i < lcs.length ;i++)
        {
            b.append(lcs[i]);
        }
        System.out.println(b);

    }
}


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

#include<bits/stdc++.h>
#include<string.h>

using namespace std;

int main(){

    char s[3000],p[3000];

    cin>>s>>p;

    long int l1=strlen(s),l2=strlen(p),l3=0;

    long int i,j,k,a[l1][l2]={0};

    for(i=0;i<l1;i++){
        for(j=0;j<l2;j++){

            a[i][j]=0;

            if(i==0 && j==0){
                if(s[i]==p[j])
                    a[i][j]=1;
            }
            else if(i==0){
                if(s[i]==p[j])
                    a[i][j]=1;
                else
                    a[i][j]=a[i][j-1];
            }
            else if(j==0){

                if(s[i]==p[j])
                    a[i][j]=1;
                else
                    a[i][j]=a[i-1][j];
            }
            else{

                if(s[i]==p[j])
                    a[i][j]=max((a[i][j-1]),(a[i-1][j-1]+1));
                else
                    a[i][j]=max(a[i][j-1],a[i-1][j]);
            }
        }
    }

    char s1[4000];

    i=(l1-1);

    for(j=(l2-1);j>0;j--){

        if(a[i][j]!=a[i][j-1]){
            s1[l3]=p[j];
            l3++;
            i--;
        }
    }

    if(a[i][j]!=0){

        s1[l3]=p[0];
        l3++;
    }

    s1[l3]=NULL;

    cout<<strrev(s1)<<"\n";

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:12: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
   67 |     s1[l3]=NULL;
      |            ^~~~
a.cc:69:11: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   69 |     cout<<strrev(s1)<<"\n";
      |           ^~~~~~
      |           strsep
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){

    char s[3000],p[3000];

    cin>>s>>p;

    long int l1=strlen(s),l2=strlen(p),l3=0;

    long int i,j,k,a[l1][l2]={0};

    for(i=0;i<l1;i++){
        for(j=0;j<l2;j++){

            a[i][j]=0;

            if(i==0 && j==0){
                if(s[i]==p[j])
                    a[i][j]=1;
            }
            else if(i==0){
                if(s[i]==p[j])
                    a[i][j]=1;
                else
                    a[i][j]=a[i][j-1];
            }
            else if(j==0){

                if(s[i]==p[j])
                    a[i][j]=1;
                else
                    a[i][j]=a[i-1][j];
            }
            else{

                if(s[i]==p[j])
                    a[i][j]=max((a[i][j-1]),(a[i-1][j-1]+1));
                else
                    a[i][j]=max(a[i][j-1],a[i-1][j]);
            }
        }
    }

    char s1[4000];

    i=(l1-1);

    for(j=(l2-1);j>0;j--){

        if(a[i][j]!=a[i][j-1]){
            s1[l3]=p[j];
            l3++;
            i--;
        }
    }

    if(a[i][j]!=0){

        s1[l3]=p[0];
        l3++;
    }

    s1[l3]=NULL;

    cout<<strrev(s1)<<"\n";

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:12: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
   66 |     s1[l3]=NULL;
      |            ^~~~
a.cc:68:11: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   68 |     cout<<strrev(s1)<<"\n";
      |           ^~~~~~
      |           strsep
Language: C++

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

int main()
{
	string a,b,s;
    int na
    z,m,i,j,f[100][100];
    cin>>a;
    cin>>b;
    s="";
    n=a.length();
    m=b.length();
    for(i=1;i<=n;i++)
        f[i][0]=0;
    for(j=1;j<=m;j++)
        f[0][j]=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(int(a[i])==int(b[j]))
            {
                f[i][j]=f[i-1][j-1]+1;
            }
            else
                f[i][j]=max(f[i-1][j],f[i][j-1]);
        }
    }
    i=n;j=m;
    while((i>=0)and(j>=0))
    {

        if(int(a[i])==int(b[j]))
        {
            s.push_back(a[i]);
            i--;
            j--;
        }
        else
            if(f[i-1][j]==f[i][j])
                i--;
            else
                j--;

    }
    cout<<s;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: expected initializer before 'z'
    9 |     z,m,i,j,f[100][100];
      |     ^
a.cc:13:5: error: 'n' was not declared in this scope
   13 |     n=a.length();
      |     ^
a.cc:14:5: error: 'm' was not declared in this scope
   14 |     m=b.length();
      |     ^
a.cc:15:9: error: 'i' was not declared in this scope
   15 |     for(i=1;i<=n;i++)
      |         ^
a.cc:16:9: error: 'f' was not declared in this scope
   16 |         f[i][0]=0;
      |         ^
a.cc:17:9: error: 'j' was not declared in this scope
   17 |     for(j=1;j<=m;j++)
      |         ^
a.cc:18:9: error: 'f' was not declared in this scope
   18 |         f[0][j]=0;
      |         ^
a.cc:19:9: error: 'i' was not declared in this scope
   19 |     for(i=1;i<=n;i++)
      |         ^
a.cc:21:13: error: 'j' was not declared in this scope
   21 |         for(j=1;j<=m;j++)
      |             ^
a.cc:25:17: error: 'f' was not declared in this scope
   25 |                 f[i][j]=f[i-1][j-1]+1;
      |                 ^
a.cc:28:17: error: 'f' was not declared in this scope
   28 |                 f[i][j]=max(f[i-1][j],f[i][j-1]);
      |                 ^
a.cc:31:5: error: 'i' was not declared in this scope
   31 |     i=n;j=m;
      |     ^
a.cc:31:9: error: 'j' was not declared in this scope
   31 |     i=n;j=m;
      |         ^
a.cc:42:16: error: 'f' was not declared in this scope
   42 |             if(f[i-1][j]==f[i][j])
      |                ^
Language: C++

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

string s, t;
int len_s, len_t;
string dp[3001][3001];
int main()
{
  cin >> s >> t;
  len_s = s.size();
  len_t = t.size();
  
  rep(i, 0, len_s){
    rep(j, 0, len_t){
      if (s[i] == t[j]){
        if (dp[i][j].size() + 1 > dp[i+1][j].size() && dp[i][j].size() + 1 > dp[i][j+1].size()){
          dp[i+1][j+1] = dp[i][j] + t[j];
        }else if (dp[i][j+1].size() < dp[i+1][j].size()){
          dp[i+1][j+1] = dp[i+1][j];
        }else{
          dp[i+1][j+1] = dp[i][j+1];
        }
      }else{
        if (dp[i][j+1].size() < dp[i+1][j].size()){
          dp[i+1][j+1] = dp[i+1][j];
        }else{
          dp[i+1][j+1] = dp[i][j+1];
        }
      }
    }
  }
  cout << dp[len_s][len_t] << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   rep(i, 0, len_s){
      |       ^
a.cc:14:3: error: 'rep' was not declared in this scope
   14 |   rep(i, 0, len_s){
      |   ^~~
Language: C++

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

const ll INF =100000000009;
string dp[3005][3005]; //sのi番目までとtのj番目までの部分列

template<class T> inline bool chmax(T &x, T y){
	if(x < y){x = y; return true;}
	else return false;
}

int main(){
	string s,t; cin >> s >> t; 
	if(s.size() < t.size()){
		string num = s;
		s = t;
		t = num;
	}
	rep(i,3005)rep(j,3005)dp[i][j] = "";
	rep(i,s.size()){
		rep(j,t.size()){
			if(dp[i+1][j].size() <= dp[i][j].size())dp[i+1][j] = dp[i][j];
			if(dp[i][j].size() <= dp[i+1][j].size())dp[i][j+1] = dp[i][j];
			if(s[i] == t[j] && dp[i+1][j+1].size() <= dp[i][j].size())dp[i+1][j+1] = dp[i][j]+s[i];
			else dp[i+1][j+1] = dp[i][j];
		}
	}
	cout  << dp[s.size()][t.size()] << endl;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:34: error: 'i' was not declared in this scope
   22 |         rep(i,3005)rep(j,3005)dp[i][j] = "";
      |                                  ^
Language: C++

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

using namespace std;

const int Nmax = 3001;
int max(int a, int b,int c) { return a>b&&a>c?a:(b>c?b:c);}

vector< vector<int> > lcs(Nmax);

void lon_comm_seqs(string s,string t){
	int s_size=s.size(),t_size=t.size();
  	lcs[0] = vector<int>(Nmax);
  	lcs[0][0] = (s[0]==t[0])?1:0;
  	for(int i=1;i<t_size;i++)	lcs[0][i] = (s[0]==t[i])?1:lcs[0][i-1];
  	for(int i=1;i<s_size;i++)	{ lcs[i] = vector<int>(Nmax);lcs[i][0] = (s[i]==t[0])?1:lcs[i-1][0];}
  
  	for(int i=1;i<s_size();i++){
    	for(int j=1;j<t_size;j++){
        	if(s[i]==t[j]) lcs[i][j] = lcs[i-1][j-1]+1;
			else lcs[i][j] = lcs[i-1][j-1];
          	
          	lcs[i][j] = max(lcs[i][j],lcs[i-1][j],lcs[i][j-1]);
     }
     stack<char> ans;
     for(int i=s_size;i>=0;i--){
    	for(int j=t_size;j>0;j--){
        	if(s[i]==t[j] && lcs[i][j] = lcs[i-1][j-1]+1) { ans.push_back(s[i--]); }
			else if(lcs[i][j] == lcs[i-1][j]) {j++;i--;}
     }
     while(!ans.empty()) { cout << ans.top();ans.pop(); }
}
  
int main(){
	string s,t;cin>>s>>t;
  	lon_comm_seqs(s,t);
  	return 0;
}


Compiler output:
a.cc: In function 'void lon_comm_seqs(std::string, std::string)':
a.cc:20:29: error: 's_size' cannot be used as a function
   20 |         for(int i=1;i<s_size();i++){
      |                       ~~~~~~^~
a.cc:30:31: error: lvalue required as left operand of assignment
   30 |                 if(s[i]==t[j] && lcs[i][j] = lcs[i-1][j-1]+1) { ans.push_back(s[i--]); }
a.cc:30:69: error: 'class std::stack<char>' has no member named 'push_back'
   30 |                 if(s[i]==t[j] && lcs[i][j] = lcs[i-1][j-1]+1) { ans.push_back(s[i--]); }
      |                                                                     ^~~~~~~~~
a.cc:36:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   36 | int main(){
      |         ^~
a.cc:36:9: note: remove parentheses to default-initialize a variable
   36 | int main(){
      |         ^~
      |         --
a.cc:36:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:36:11: error: a function-definition is not allowed here before '{' token
   36 | int main(){
      |           ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:20:36: note: to match this '{'
   20 |         for(int i=1;i<s_size();i++){
      |                                    ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:13:38: note: to match this '{'
   13 | void lon_comm_seqs(string s,string t){
      |                                      ^
Language: C++

#include <iostream>
#include <string>
#include <unistd.h>
#include <cmath>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s,t; cin >> s >> t;
    //DPtable
    const int maxlen = 3000+10;
    vector<vector<int> >dp(maxlen, vector<int>(maxlen));
    rep(i, s.size()){
        rep(j, t.size()){
            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]);
            }
        }
    }
    //restor
    string ans; 
    int i = s.size(), j = t.size();
    while(i>0 && j>0){
        if(dp[i][j] == dp[i][j-1])  --j;
        else if(dp[i][j] == dp[i-1][j]) --i;
        else{
            ans += s[i-1];
            --i;    --j;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


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