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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/

int n, m;
string s, t;
string an = "";
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    cin>>s>>t;
    n = s.length();
    m = t.length();
    int dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    int i = n, j = m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1])){
            an += s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>=dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(an.begin(), an.end());
    cout<<an<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:118:27: error: expected primary-expression before ')' token
  118 |         if(s[i-1]==t[j-1])){
      |                           ^
Language: C++

#include<iostream>
using namespace std;
int dp[3005][3005];
#include<vector>
int main()
{
    
    string s,t;
    cin>>s>>t;
    int x=s.length(),y=t.length();
    for(int i=1;i<=x;i++){
    for(int j=1;j<=y;j++){
    if(s[i-1]!=t[j-1])
    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    else
    dp[i][j]=1+dp[i-1][j-1];
    }}
    vector<char>v;
    int i=x,j=y;
    while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j])i--;
    else if(dp[i][j]==dp[i][j-1])j--;
    else if(dp[i][j]!=dp[i-1][j-1]){
    v.push_back(t[j-1]);
    i--;j--;}
    }
    reverse(v.begin(),v.end());
    for(int i=0;i<dp[x][y];i++)
    cout<<v[i];
    
    return 0;
}

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:39:17: error: invalid types 'int[int]' for array subscript
   39 |     cout<<lcs[i][j];
      |                 ^
Language: C++

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

int dp[ma+1][ma+1]={0};

string getLCS(string x,string y,int len)
{
    string lcss;
    int i=x.length();
    int j=y.length();
    while(len>0)
    {
        if(x[i-1]==y[j-1])
        {
            lcss.push_back(x[i-1]);
            i--;
            j--;
            len--;
        }
        else
        {
            if(dp[i][j-1]>dp[i-1][j])
            {
                j--;
            }
            else
            {
                i--;
            }
        }
    }
    reverse(lcss.begin(),lcss.end());
    return lcss;
}


int lcs(int i,int j,string x,string y)
{
    if(i==0 || j==0)
    {
        return 0;
    }
    if(dp[i][j]!=0)
    {
        return dp[i][j];
    }

    if(x[i-1] == y[j-1])
    {
        dp[i][j] = 1 + lcs(i-1,j-1,x,y);
    }
    else{
        dp[i][j] = max(lcs(i-1,j,x,y),lcs(i,j-1,x,y));
    }
    return dp[i][j];
}

int main()
{
    string a,b;
    cin>>a>>b;
    setDP();
    int length = lcs(a.length(),b.length(),a,b);
    cout<<getLCS(a,b,length);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:5: error: 'setDP' was not declared in this scope
   63 |     setDP();
      |     ^~~~~
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      String n = sc.next();
      String m = sc.next();
      
      String dp[][] =  new String[n.length()][m.length()];
      System.out.println(sub(n, m , 0, 0, dp));
      
    }
  
  public static String sub(String n, String m, int pos1, int pos2, String dp[][]){
    
    dp[n.length() -1][m.length() -1] = n.charAt(n.length() -1) == m.charAt(m.length() -1)? n.charAt(n.length() -1)+"" : "";
    
    
  	for(int i=m.length-2;i>=0; i--)
      dp[n.length()-1][i] = n.charAt(n.length() -1) == m.charAt(i) ? n.charAt(n.length() -1) + ""  : dp[n.length()-1][i+1];
    
    for(int i=n.length-2;i>=0; i--)
      dp[i][m.length()-1] = n.charAt(i) == m.charAt(m.length()-1)? n.charAt(i) + ""  : dp[i+1][m.length()-1];
    
    for(int i=n.length()-2; i>=0; i--){
      for(int j = m.length()-2; j>=0; j--){
        dp[i][j] = n.charAt(i) == m.charAt(j)? n.charAt(i)+dp[i+1][j+1] : (dp[i+1][j].length() > dp[i][j+1].length())? dp[i+1][j] : dp[i][j+1];
      }
  }
}


Compiler output:
Main.java:31: error: reached end of file while parsing
}
 ^
1 error
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      String n = sc.next();
      String m = sc.next();
      
      String dp[][] =  new String[n.length()][m.length()];
      System.out.println(sub(n, m , 0, 0, dp));
      
    }
  
  public static String sub(String n, String m, int pos1, int pos2, String dp[][]){
    
    dp[n.length() -1][m.length() -1] = n.charAt(n.length() -1) == m.charAt(m.length() -1)? n.charAt(n.length() -1)+"" : "";
    
    
  	for(int i=m.length-2;i>=0; i--)
      dp[n.length()-1][i] = n.charAt(n.length() -1) == m.charAt(i)? n.charAt(n.length() -1) + "" ? : dp[n.length() -1][i+1];
    
    for(int i=n.length-2;i>=0; i--)
      dp[i][m.length()-1] = n.charAt(i) == m.charAt(m.length()-1)? n.charAt(i) + "" ? : dp[i+1][m.length()-1];
    
    for(int i=n.length()-2; i>=0; i--){
      for(int j = m.length()-2; j>=0; j--){
        dp[i][j] = n.charAt(i) == m.charAt(j)? n.charAt(i)+dp[i+1][j+1] : dp[i+1][j].length() > dp[i][j+1].length()? dp[i+1][j] : dp[i][j+1];
      }
  }
}


Compiler output:
Main.java:21: error: illegal start of expression
      dp[n.length()-1][i] = n.charAt(n.length() -1) == m.charAt(i)? n.charAt(n.length() -1) + "" ? : dp[n.length() -1][i+1];
                                                                                                   ^
Main.java:21: error: : expected
      dp[n.length()-1][i] = n.charAt(n.length() -1) == m.charAt(i)? n.charAt(n.length() -1) + "" ? : dp[n.length() -1][i+1];
                                                                                                                           ^
Main.java:24: error: illegal start of expression
      dp[i][m.length()-1] = n.charAt(i) == m.charAt(m.length()-1)? n.charAt(i) + "" ? : dp[i+1][m.length()-1];
                                                                                      ^
Main.java:24: error: : expected
      dp[i][m.length()-1] = n.charAt(i) == m.charAt(m.length()-1)? n.charAt(i) + "" ? : dp[i+1][m.length()-1];
                                                                                                             ^
Main.java:31: error: reached end of file while parsing
}
 ^
5 errors
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      String n = sc.next();
      String m = sc.next();
      
      String dp[][] =  new String[n.length()][m.length()];
      
      for(int i=0;i<n.length(); i++)
      	dp[i] = new String[m.length()];
       
      
      System.out.println(sub(n, m , 0, 0, dp));
      
    }
  
  public static String sub(String n, String m, int pos1, int pos2, string dp[][]){
    
  	if(pos1 >= n.length() || pos2 >= m.length())
      return "";
    
    if(dp[pos1][pos2] != null){
     return  dp[pos1][pos2];
    }
    
    if(n.charAt(pos1) == m.charAt(pos2)){
    	return dp[pos1][pos2]  = n.charAt(pos1) + sub(n,m,pos1+1, pos2+1, dp);
    }
    
     String sub1 = sub(n,m,pos1+1, pos2+1, dp);
     String sub2 = sub(n,m,pos1, pos2+1, dp);
     String sub3 = sub(n,m,pos1+1, pos2, dp);
    
    return dp[pos1][pos2] = sub1.length() > sub2.length() ? (sub1.length() > sub3.length() ? sub1: sub3) : (sub2.length() > sub3.length() ? sub2: sub3);
    
  }
}


Compiler output:
Main.java:20: error: cannot find symbol
  public static String sub(String n, String m, int pos1, int pos2, string dp[][]){
                                                                   ^
  symbol:   class string
  location: class Main
1 error
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      String n = sc.next();
      String m = sc.next();
      /*
      long dp[][] =  new long[n][W+1];
      
      for(int i=0;i<n; i++)
      	Arrays.fill(dp[i], -1);
       */
      
      System.out.println(sub(n, m , 0, 0));
      
    }
  
  public static String sub(String n, String m, int pos1, int pos2){
    
  	if(pos1 >= n.length || pos2 >= m.length)
      return "";
    
    if(n.charAt(pos1) == m.charAt(pos2)){
    	return n.charAt(pos1) + sub(n,m,pos1+1, pos2+1);
    }
    
     String sub1 = sub(n,m,pos1+1, pos2+1);
     String sub2 = sub(n,m,pos1, pos2+1);
     String sub3 = sub(n,m,pos1+1, pos2);
    
    return sub1.length > sub2.length ? (sub1.length > sub3.length ? sub1: sub3) : (sub2.length > sub3.length ? sub2: sub3);
    
  }
}


Compiler output:
Main.java:22: error: cannot find symbol
  	if(pos1 >= n.length || pos2 >= m.length)
  	            ^
  symbol:   variable length
  location: variable n of type String
Main.java:22: error: cannot find symbol
  	if(pos1 >= n.length || pos2 >= m.length)
  	                                ^
  symbol:   variable length
  location: variable m of type String
Main.java:33: error: cannot find symbol
    return sub1.length > sub2.length ? (sub1.length > sub3.length ? sub1: sub3) : (sub2.length > sub3.length ? sub2: sub3);
               ^
  symbol:   variable length
  location: variable sub1 of type String
Main.java:33: error: cannot find symbol
    return sub1.length > sub2.length ? (sub1.length > sub3.length ? sub1: sub3) : (sub2.length > sub3.length ? sub2: sub3);
                             ^
  symbol:   variable length
  location: variable sub2 of type String
Main.java:33: error: cannot find symbol
    return sub1.length > sub2.length ? (sub1.length > sub3.length ? sub1: sub3) : (sub2.length > sub3.length ? sub2: sub3);
                                            ^
  symbol:   variable length
  location: variable sub1 of type String
Main.java:33: error: cannot find symbol
    return sub1.length > sub2.length ? (sub1.length > sub3.length ? sub1: sub3) : (sub2.length > sub3.length ? sub2: sub3);
                                                          ^
  symbol:   variable length
  location: variable sub3 of type String
Main.java:33: error: cannot find symbol
    return sub1.length > sub2.length ? (sub1.length > sub3.length ? sub1: sub3) : (sub2.length > sub3.length ? sub2: sub3);
                                                                                       ^
  symbol:   variable length
  location: variable sub2 of type String
Main.java:33: error: cannot find symbol
    return sub1.length > sub2.length ? (sub1.length > sub3.length ? sub1: sub3) : (sub2.length > sub3.length ? sub2: sub3);
                                                                                                     ^
  symbol:   variable length
  location: variable sub3 of type String
8 errors
Language: Java


import java.io.IOException;
import java.util.Scanner;

/**
 *
 * @author luiscastillo
 */
public class LCS {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();
        String t = sc.nextLine();

        int[][] memo = new int[s.length() + 1][t.length() + 1];
        int max = 0;
        StringBuilder result = new StringBuilder();
        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)) {
                    memo[i][j] = memo[i - 1][j - 1] + 1;
                } else {
                    memo[i][j] = Math.max(memo[i - 1][j], memo[i][j - 1]);
                }
                max = Math.max(max, memo[i][j]);
            }
        }

        int i = s.length(), j = t.length();
        while (i > 0 && j > 0) {
            if (s.charAt(i - 1) == t.charAt(j - 1)) {
                result.append(s.charAt(i - 1));
                i--;
                j--;
            } else {
                if (memo[i][j] == memo[i - 1][j]) {
                    i--;
                } else {
                    j--;
                }
            }
        }
        System.out.println(result.reverse());

    }

}


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

//----------------------------------------------------------------
//F

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

const long long INF = 1LL<<60;

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

int main() {
    cin >> s >> t;

    // DPループ
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    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 << res << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:31: error: 'chmax' was not declared in this scope
   22 |             if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
      |                               ^~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;
 
// Find a longest Subsequence b/w 2 strings using memoization
pair<int, string> LCSstring(string x, string y,pair<int, string> **dp){
    int n = x.size();
  	int m = y.size();
  	if(n==0 || m==0){
        
        return make_pair(0, "");
    }
    if(dp[n][m].first != -1){
        return dp[n][m];
    }
    if(x[0] == y[0]){
        auto p = LCSstring(x.substr(1), y.substr(1), dp);
        p.first +=1;
        p.second += x[0];
        dp[n][m] = p;
        return dp[n][m];
    }
    else{
        auto p1 = LCSstring(x.substr(1), y, dp);
        auto p2 = LCSstring(x, y.substr(1), dp);
 
        if(p1.first >= p2.first){
            dp[n][m] = p1;
            return dp[n][m];
        }
        else{
            dp[n][m] = p2;
            return dp[n][m];
        }
    }
    return dp[n-1][m-1];
}
 
 
int main() {
    string x, y;
  	cin >> x >> y;
    pair<int, string> **dp = new pair<int, string>*[x.size()+1];
    for(int i=0;i<=x.size();i++){
        dp[i] = new pair<int, string>[y.size()+1];
        for(int j=0;j<=y.size();j++){
            dp[i][j].first = -1;
            dp[i][j].second = "";
        }
    }
    auto p = LCSstring(x, x.size(), y, y.size(), dp);
    cout << p.second<< endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:33: error: could not convert 'x.std::__cxx11::basic_string<char>::size()' from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   53 |     auto p = LCSstring(x, x.size(), y, y.size(), dp);
      |                           ~~~~~~^~
      |                                 |
      |                                 std::__cxx11::basic_string<char>::size_type {aka long unsigned int}
Language: Java

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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str1 = br.readLine();
    String str2 = br.readLine();
    int[][] lcs = new int[str1.length()+1][str2.length()+1];
    int max = 0;
    StringBuilder res = "";
    for(int i=0;i<=str1.length();i++){
      for(int j=0;j<=str2.length();j++){
        if(i==0 || j==0)
          lcs[i][j] = 0;
        else if(str1.charAt(i-1) == str2.charAt(j-1)){
          lcs[i][j] = lcs[i-1][j-1]+1;
          //res += str1.charAt(i-1);
        }
        else
          lcs[i][j] = Math.max(lcs[i-1][j],lcs[i][j-1]);
        max = Math.max(max,lcs[i][j]);
      }
    }
    
    int i=str1.length(),j=str2.length();
    while(i>0 && j>0){
      char a = str1.charAt(i);
      char b = str2.charAt(j);
      if(a==b){
        res.append(a);
        i--;
        j--;
      }
      else{
        if(lcs[i][j] == lcs[i-1][j]) i--;
        else j--;
      }
    }
   System.out.println(res.reverse().toString());
  }
}


Compiler output:
Main.java:11: error: incompatible types: String cannot be converted to StringBuilder
    StringBuilder res = "";
                        ^
1 error
Language: Java

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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str1 = br.readLine();
    String str2 = br.readLine();
    int[][] lcs = new int[str1.length()+1][str2.length()+1];
    int max = 0;
    String res = "";
    for(int i=0;i<=str1.length();i++){
      for(int j=0;j<=str2.length();j++){
        if(i==0 || j==0)
          lcs[i][j] = 0;
        else if(str1.charAt(i-1) == str2.charAt(j-1)){
          lcs[i][j] = lcs[i-1][j-1]+1;
          //res += str1.charAt(i-1);
        }
        else
          lcs[i][j] = Math.max(lcs[i-1][j],lcs[i][j-1]);
        max = Math.max(max,lcs[i][j]);
      }
    }
    
    int i=str1.length(),j=str2.length();
    while(i>0 && j>0){
      char a = str1.charAt(i);
      char b = str2.charAt(j);
      if(a==b){
        res += a;
        i--;
        j--;
      }
      else{
        if(lcs[i][j] == lcs[i-1][j]) i--;
        else j--;
      }
    }
   System.out.println(res.reverse());
  }
}


Compiler output:
Main.java:40: error: cannot find symbol
   System.out.println(res.reverse());
                         ^
  symbol:   method reverse()
  location: variable res of type String
1 error
Language: Java

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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str1 = br.readLine();
    String str2 = br.readLine();
    int[][] lcs = new int[str1.length()+1][str2.length()+1];
    int max = 0;
    //String res = "";
    for(int i=0;i<=str1.length();i++){
      for(int j=0;j<=str2.length();j++){
        if(i==0 || j==0)
          lcs[i][j] = 0;
        else if(str1.charAt(i-1) == str2.charAt(j-1)){
          lcs[i][j] = lcs[i-1][j-1]+1;
          //res += str1.charAt(i-1);
        }
        else
          lcs[i][j] = Math.max(lcs[i-1][j],lcs[i][j-1]);
        max = Math.max(max,lcs[i][j]);
      }
    }
    
    int i=0,j=0;
    while(i<=str1.length() && j<=str2.length()){
      char a = str1.charAt(i);
      char b = str2.charAt(j);
      if(a==b){
        System.out.printf("%c",a);
        i++;
        j++;
      }
      else{
        if(dp[i+1][j]>=dp[i][j+1]) i++;
        else j++;
      }
    }
   // System.out.println(res);
  }
}


Compiler output:
Main.java:36: error: cannot find symbol
        if(dp[i+1][j]>=dp[i][j+1]) i++;
           ^
  symbol:   variable dp
  location: class Main
Main.java:36: error: cannot find symbol
        if(dp[i+1][j]>=dp[i][j+1]) i++;
                       ^
  symbol:   variable dp
  location: class Main
2 errors
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define str string
#define fori(i,N) for(long long i=1;i<=N;++i)
#define forj(j,m) for(long long j=1;j<=m;++j)
#define fork(k,n) for(long long k=1;k<=n;++k)
#define fors(i,ssz) for(long long i=0;i<s.size();++i)
#define Need_for_Speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s,t;
    getline(cin,s);
    getline(cin,t);
    int m = s.length(),n = t.length() ;
    int dp[m+1][n+1],i,j;
    for(i=0;i<=m;i++) {
        for(j=0;j<=n;j++){
            if(i==0||j==0)
            dp[i][j]=0;
            else {
                if(s[i-1]==t[j-1])
                    dp[i][j] = dp[i-1][j-1]+1;
                else
                    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    i=m;
    j=n;
    string st;
    while(i>0&&j>0){
            if(s[i-1]==t[j-1]){
                st=s[i-1]+st;
                i--;
                j--;
            }
            else if (dp[i-1][j] > dp[i][j-1]) 
                i--; 
            else
             j--; 
        }
        cout<<st;
}

Compiler output:
a.cc:2:12: error: expected nested-name-specifier before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:12:7: note: in expansion of macro 'll'
   12 | using ll = long long;
      |       ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
	string s,t,x="";
  	cin>>s>>t;
  	int n=s.length(),m=t.length();
  	dp[n+1][m+1];
  	for(int i=0;i<=n;i++) {
    	for(int j=0;j<=m;j++) {
        	if(i==0 || j==0) {dp[i][j]=0;}
          	else if(s[i-1]==t[j-1]) {dp[i][j]=dp[i-1][j-1]+1;}
          	else {dp[i][j]=max(dp[i-1][j],dp[i][j-1]);}
        }
    }
  	int i=n,j=m;
  	while(i>0 && j>0) {
    	if(s[i-1]==t[j-1]) {x.push_back(s[i-1]); i--; j--;}
      	else {
          	if(dp[i-1][j]>dp[i][j-1]) {i--;}
      		else {j--;}
        }
    }
  	reverse(x.begin(),x.end());
  	cout<<x<<endl;
}

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

/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
//cout << "LCS of " << X << " and " << Y << " is " << lcs; 
	cout<<lcs<<endl;
} 

/* Driver program to test above function */
int main() 
{ 
  string x,y;
  cin>>x>>y;
char X[] =x
char Y[] = y; 
int m = strlen(X); 
int n = strlen(Y); 
lcs(X, Y, m, n); 
return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:65:11: error: initializer fails to determine size of 'X'
   65 | char X[] =x
      |           ^
a.cc:65:11: error: array must be initialized with a brace-enclosed initializer
a.cc:68:16: error: 'Y' was not declared in this scope
   68 | int n = strlen(Y);
      |                ^
Language: C

#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100025;
const int inf=0x3f3f3f3f;
int n,m;
int w[maxn];
char str[maxn],str_[maxn];
ll v[maxn];
ll val[maxn];
ll dp[maxn][maxn];
int main()
{
    scanf("%s",str+1);
    scanf("%s",str_+1);
    int len = strlen(str+1),len_ = strlen(str_+1);
    for(int i = len;i>=1;--i)
    {
        for(int j = len_;j>=1;--j)
        {
            if(str[i]==str_[j])  dp[i][j] = dp[i+1][j+1]+1;
            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    int l = 1,r = 1;
    while(l<=len&&r<=len_)
    {

        if(str[l]==str_[r])
        {
            printf("%c",str[l]);
            l++,r++;
        }
        else if(dp[l][r]==dp[l+1][r]) l++;
        else r++;
    }
    printf("\n");
    return 0;
}


Compiler output:
main.c:2:9: fatal error: algorithm: No such file or directory
    2 | #include<algorithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C

#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100025;
const int inf=0x3f3f3f3f;
int n,m;
int w[maxn];
char str[maxn],str_[maxn];
ll v[maxn];
ll val[maxn];
ll dp[maxn][maxn];
int main()
{
    scanf("%s",str+1);
    scanf("%s",str_+1);
    int len = strlen(str+1),len_ = strlen(str_+1);
    for(int i = len;i>=1;--i)
    {
        for(int j = len_;j>=1;--j)
        {
            if(str[i]==str_[j])  dp[i][j] = dp[i+1][j+1]+1;
            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    int l = 1,r = 1;
    while(l<=len&&r<=len_)
    {

        if(str[l]==str_[r])
        {
            printf("%c",str[l]);
            l++,r++;
        }
        else if(dp[l][r]==dp[l+1][r]) l++;
        else r++;
    }
    printf("\n");
    return 0;
}


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

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100025;
const int inf=0x3f3f3f3f;
int n,m;
int w[maxn];
char str[maxn],str_[maxn];
ll v[maxn];
ll val[maxn];
ll dp[maxn][maxn];
int main()
{
    scanf("%s",str+1);
    scanf("%s",str_+1);
    int len = strlen(str+1),len_ = strlen(str_+1);
    for(int i = len;i>=1;--i)
    {
        for(int j = len_;j>=1;--j)
        {
            if(str[i]==str_[j])  dp[i][j] = dp[i+1][j+1]+1;
            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    int l = 1,r = 1;
    while(l<=len&&r<=len_)
    {

        if(str[l]==str_[r])
        {
            printf("%c",str[l]);
            l++,r++;
        }
        else if(dp[l][r]==dp[l+1][r]) l++;
        else r++;
    }
    printf("\n");
    return 0;
}


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

#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
int dp[3005][3005];
char s[3005],t[305];
int main()
{
    gets(s+1);
    gets(t+1);
	int d1=strlen(s+1),d2=strlen(t+1);
	
	for(int i=d1;i>0;i--){
        for(int j=d2;j>0;j--){
            if(s[i]==t[j])
                dp[i][j]=dp[i+1][j+1]+1;
            else
                dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
        }
    }

    int flag=0;
	for(int i=1,j=1;i<=d1&&j<=d2;i++,j++){
		if(s[i]==t[j])
			cout<<s[i],flag=1;
		else if(dp[i][j]==dp[i+1][j])
		    j--;
		else 
		    i--;
    }
    
	if(!flag)
	cout<<"The answer is (an empty string).\n";
}

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

//LCS但是得记录序列：https://blog.csdn.net/pjqooo/article/details/38425159
//涉及正逆序问题 
#include<bits/stdc++.h>
using namespace std;

int dp[3005][3005];//s1在i长度下和s2[j]在j长度最长序列长度 

signed main()
{
	string s1,s2;
	while(cin>>s1>>s2){
		int len1=s1.length(),len2=s2.length();
		
		for(int i=0;i<=len1;i++)dp[i][0]=0;
		for(int i=0;i<=len2;i++)dp[0][i]=0;
		
		for(int i=len1;i>=1;i--)
			for(int j=len2;j>=1;j--){
				if(s1[i]==s2[j])dp[i][j]=dp[i+1][j+1]+1;
				else dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
			}
		
		//关键:用上面的dp去优化查找过程 
		int i=0,j=0;
		while(i<len1&&j<len2){
			if(s1[i]==s2[j]){
				cout<<s1[i];
				i++;j++;
				flag=1;
			}//不一样得看往后移动哪一个指针,没重复往后走 
			else if(dp[i+1][j+1]==dp[i+1+1][j+1])i++;
			else j++;
		} 
		cout<<endl;
	}
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:29:33: error: 'flag' was not declared in this scope
   29 |                                 flag=1;
      |                                 ^~~~
Language: C++

#include <iostream>
#include<vector>
using namespace std;
#define MAX 3001
int dp[MAX][MAX];
string getLCS(string& s,string& t,int len)
{
    string LCS;
    int i = 0,j = 0;
    while(len > 0)
    {
        if(s[i] == t[j])
        {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else
        {
            if(dp[i][j+1] > dp[i+1][j])
                j++;
            else
                i++;
        }
    }
    return LCS;
}
int lenLCS(string& s,string& t,int i,int j)
{
    if(i >= s.length() || j >= t.length())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(s[i] == t[j])
        return dp[i][j] = 1 + lenLCS(s,t,i+1,j+1);
    else
    {
        return dp[i][j] = max(lenLCS(s,t,i+1,j),lenLCS(s,t,i,j+1));
    }
}
string solve(string& s,string& t)
{
    memset(dp,-1,sizeof dp);
    int len = lenLCS(s,t,0,0);
    return getLCS(s,t,len);
}
int main() {
    string s,t;
    cin>>s>>t;
    cout<<solve(s,t);
}

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

#include <iostream>
#include<vector>
using namespace std;
int dp[3001][3001];
string getLCS(string& s,string& t,int len)
{
    string LCS;
    int i = 0,j = 0;
    while(len > 0)
    {
        if(s[i] == t[j])
        {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else
        {
            if(dp[i][j+1] > dp[i+1][j])
                j++;
            else
                i++;
        }
    }
    return LCS;
}
int lenLCS(string& s,string& t,int i,int j)
{
    if(i >= s.length() || j >= t.length())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(s[i] == t[j])
        return dp[i][j] = 1 + lenLCS(s,t,i+1,j+1);
    else
    {
        return dp[i][j] = max(lenLCS(s,t,i+1,j),lenLCS(s,t,i,j+1));
    }
}
string solve(string& s,string& t)
{
    memset(dp,-1,sizeof dp);
    int len = lenLCS(s,t,0,0);
    return getLCS(s,t,len);
}
int main() {
    string s,t;
    cin>>s>>t;
    cout<<solve(s,t);
}


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

#include <iostream>
#include<vector>
using namespace std;
int dp[3001][3001];
string getLCS(string& s,string& t,int len)
{
    string LCS;
    int i = 0,j = 0;
    while(len > 0)
    {
        if(s[i] == t[j])
        {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else
        {
            if(dp[i][j+1] > dp[i+1][j])
                j++;
            else
                i++;
        }
    }
    return LCS;
}
int lenLCS(string& s,string& t,int i,int j)
{
    if(i >= s.length() || j >= t.length())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(s[i] == t[j])
        return dp[i][j] = 1 + lenLCS(s,t,i+1,j+1);
    else
    {
        return dp[i][j] = max(lenLCS(s,t,i+1,j),lenLCS(s,t,i,j+1));
    }
}
string solve(string& s,string& t)
{
    memset(dp,-1,sizeof dp);
    int len = lenLCS(s,t,0,0);
    return getLCS(s,t,len);
}
int main() {
    string s,t;
    cin>>s>>t;
    cout<<solve(s,t);
}

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

import java.util.Collections;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) {
		
		Reader rd = new Reader();
		
		String str1 = rd.next();
		String str2 = rd.next();
		int m = str1.length();
		int n = str2.length();
		String[][] str = new String[m+1][n+1];
		for(String[] stri : str){
			Arrays.fill(stri,"");
		}
		boolean matched = false;
		
		for(int i=1; i<=m; i++){
			for(int j=1; j<=n; j++){
				//System.out.println(str1.charAt(i-1) + " " + str2.charAt(j-1) + " " + matched);
				if(str1.charAt(i-1) == str2.charAt(j-1)){
					//matched = true;
					char c = str1.charAt(i-1);
					str[i][j] = str[i-1][j-1] + String.valueOf(c);
				}
				else{
					set_min(str, i, j);
				}
				
				//for(String[] stri : str){
					//System.out.println(Arrays.toString(stri));
				}
			
			}
		}
		System.out.println(str[m][n]);
	}
	public static void set_min(String[][] str, int i, int j){
		if(str[i-1][j].length() < str[i][j-1].length()){
			str[i][j] = str[i][j-1];
		}
		else{
			str[i][j] = str[i-1][j];
		}
	}

	static void sort(int[] ar){
		ArrayList<Integer> ls = new ArrayList<>();
		for(int i=0; i<ar.length; i++) ls.add(ar[i]);
		Collections.sort(ls);
		for(int i =0; i<ls.size(); i++) ar[i] = ls.get(i);
	}
}

class Reader { 
	static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer tok = new StringTokenizer("");
	static String next() {
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(bf.readLine());
			}
			catch(IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	} 
	static int nextInt() {
		return Integer.parseInt(next());
	}
}


Compiler output:
Main.java:42: error: <identifier> expected
		System.out.println(str[m][n]);
		                  ^
Main.java:42: error: ']' expected
		System.out.println(str[m][n]);
		                       ^
Main.java:42: error: ',', ')', or '[' expected
		System.out.println(str[m][n]);
		                        ^
Main.java:44: error: unnamed classes are a preview feature and are disabled by default.
	public static void set_min(String[][] str, int i, int j){
	              ^
  (use --enable-preview to enable unnamed classes)
Main.java:59: error: class, interface, enum, or record expected
}
^
5 errors
Language: Java

import java.util.Collections;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class lcs{
	public static void main(String[] args) {
		
		Reader rd = new Reader();
		
		String str1 = rd.next();
		String str2 = rd.next();
		int m = str1.length();
		int n = str2.length();
		String[][] str = new String[m+1][n+1];
		for(String[] stri : str){
			Arrays.fill(stri,"");
		}
		boolean matched = false;
		
		for(int i=1; i<=m; i++){
			for(int j=1; j<=n; j++){
				//System.out.println(str1.charAt(i-1) + " " + str2.charAt(j-1) + " " + matched);
				if(str1.charAt(i-1) == str2.charAt(j-1)){
					//matched = true;
					char c = str1.charAt(i-1);
					str[i][j] = str[i-1][j-1] + String.valueOf(c);
				}
				else{
					set_min(str, i, j);
				}
				
				//for(String[] stri : str){
					//System.out.println(Arrays.toString(stri));
				}
			
			}
		}
		System.out.println(str[m][n]);
	}
	public static void set_min(String[][] str, int i, int j){
		if(str[i-1][j].length() < str[i][j-1].length()){
			str[i][j] = str[i][j-1];
		}
		else{
			str[i][j] = str[i-1][j];
		}
	}

	static void sort(int[] ar){
		ArrayList<Integer> ls = new ArrayList<>();
		for(int i=0; i<ar.length; i++) ls.add(ar[i]);
		Collections.sort(ls);
		for(int i =0; i<ls.size(); i++) ar[i] = ls.get(i);
	}
}

class Reader { 
	static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer tok = new StringTokenizer("");
	static String next() {
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(bf.readLine());
			}
			catch(IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	} 
	static int nextInt() {
		return Integer.parseInt(next());
	}
}


Compiler output:
Main.java:42: error: <identifier> expected
		System.out.println(str[m][n]);
		                  ^
Main.java:42: error: ']' expected
		System.out.println(str[m][n]);
		                       ^
Main.java:42: error: ',', ')', or '[' expected
		System.out.println(str[m][n]);
		                        ^
Main.java:44: error: unnamed classes are a preview feature and are disabled by default.
	public static void set_min(String[][] str, int i, int j){
	              ^
  (use --enable-preview to enable unnamed classes)
Main.java:59: error: class, interface, enum, or record expected
}
^
5 errors
Language: C++

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

void lcs(string s, string t){
  ll n = s.length();
  ll m = t.length();
  ll i=0; j=0;
  ll dp[n+1][m+1];
  for(ll i=0; i<n; i++){
    for(ll j=0; j<m; j++){
      if(i==0 || j==0){
        dp[i][j] =0;
      }
      else if(s[i]==t[j]){
        dp[i][j] = 1+dp[i-1][j-1];
      }
      else{
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  ll ind= dp[n][m];
  char ans[ind+1];
  ans[ind] = '\0';
  ll i=n, j =m;
  while(i>0 && j>0){
    if(dp[i-1][j] == dp[i][j-1]){
      ans[ind-1] = s[i-1];
      i--; j--; ind--;
    }
    else if(dp[i-1][j] > dp[i][j-1]){
      i--;
    }
    else{
      j--;
    }
  
  }
  cout<<ans<<"\n";

}
int main(){
  string s,t;
  cin>>s>>t;
  lcs(s,t);
  return 0;
}

Compiler output:
a.cc: In function 'void lcs(std::string, std::string)':
a.cc:8:11: error: 'j' was not declared in this scope
    8 |   ll i=0; j=0;
      |           ^
a.cc:26:6: error: redeclaration of 'll i'
   26 |   ll i=n, j =m;
      |      ^
a.cc:8:6: note: 'll i' previously declared here
    8 |   ll i=0; j=0;
      |      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<long long int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vb vector<bool>
#define vvl vector<vector<ll> >
#define vvi vector<vector<int> >
#define pl pair<ll,ll>
#define pb push_back
#define PI 3.14159265
#define mod 998244353
#define pb push_back
#define mp make_pair
#define fri(s,n) for(int i=s;i<n;i++)
#define frj(s,n) for(int j=s;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define vsi vector<set<int> >
#define pii pair<int,int>
#define inf 1e9
#define vpii vector<pair<int,int> >


ll power(ll a,ll b){
    if(b==0)
        return 1;
    if(b&1)
        return a*power(a,b-1);
    ll temp=power(a,b/2);
    return temp*temp;
    }
ll mycompare(ll a,ll b){
    return a>b;
    }
string maximum(string &s1,string &s2){
    if(s1.length()>s2.length())
        return s1;
    return s2;
    }
vector<vector<string> > dp;
string LCS(string &s1,string &s2,int i,int j){
    if(i==-1 || j==-1)
        return "";
    if(dp[i][j]!=".")
        return dp[i][j];
    if(s1[i]==s2[j])
        return dp[i][j]=LCS(s1,s2,i-1,j-1)+s1[i];
    return dp[i][j]=maximum(LCS(s1,s2,i-1,j),LCS(s1,s2,i,j-1));
    }

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast;
    string s1,s2;
    cin>>s1>>s2;
    dp.resize(s1.length(),vector<string>(s2.length(),"."));
    cout<<LCS(s1,s2,s1.length()-1,s2.length()-1);
    }


Compiler output:
a.cc: In function 'std::string LCS(std::string&, std::string&, int, int)':
a.cc:50:32: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   50 |     return dp[i][j]=maximum(LCS(s1,s2,i-1,j),LCS(s1,s2,i,j-1));
      |                             ~~~^~~~~~~~~~~~~
a.cc:37:24: note:   initializing argument 1 of 'std::string maximum(std::string&, std::string&)'
   37 | string maximum(string &s1,string &s2){
      |                ~~~~~~~~^~
Language: Java

public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String a,b;
		a = s.next();
		b = s.next();
		StringBuilder sb = new StringBuilder("");
		int [][] dp = new int[a.length()+1][b.length()+1];
		for(int i=0;i<dp.length;i++) {
			for(int j=0;j<dp[i].length;j++) {
				if(i==0||j==0) {
					dp[i][j] = 0;
				}
				else if(a.charAt(i-1)==b.charAt(j-1)) {
					dp[i][j] = 1 + dp[i-1][j-1];
				}
				else {
					dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
				}
			}
		}
		int index = dp[a.length()][b.length()];
		int x = a.length();
		int y = b.length();
		while(index>0) {
			if(dp[x][y]-1==dp[x-1][y-1]) {
				sb.insert(0,a.charAt(x-1));
				index--;
				x--; 
				y--;
			}
			else if(dp[x][y] == dp[x-1][y]) {
				x--;
			}
			else if(dp[x][y] == dp[x][y-1]) {
				y--;
			}
			
		}
//		for(int i=0;i<dp.length;i++) {
//			for(int j=0;j<dp[i].length;j++) {
//				System.out.print(dp[i][j] + " ");
//			}
//			System.out.println();
//		}
//		System.out.println(dp[a.length()][b.length()]);
		System.out.println(sb.toString());

	}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
              ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: Java

import java.util.Scanner;
public class LCS {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String a,b;
		a = s.next();
		b = s.next();
		StringBuilder sb = new StringBuilder("");
		int [][] dp = new int[a.length()+1][b.length()+1];
		for(int i=0;i<dp.length;i++) {
			for(int j=0;j<dp[i].length;j++) {
				if(i==0||j==0) {
					dp[i][j] = 0;
				}
				else if(a.charAt(i-1)==b.charAt(j-1)) {
					dp[i][j] = 1 + dp[i-1][j-1];
				}
				else {
					dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
				}
			}
		}
		int index = dp[a.length()][b.length()];
		int x = a.length();
		int y = b.length();
		while(index>0) {
			if(dp[x][y]-1==dp[x-1][y-1]) {
				sb.insert(0,a.charAt(x-1));
				index--;
				x--; 
				y--;
			}
			else if(dp[x][y] == dp[x-1][y]) {
				x--;
			}
			else if(dp[x][y] == dp[x][y-1]) {
				y--;
			}
			
		}
//		for(int i=0;i<dp.length;i++) {
//			for(int j=0;j<dp[i].length;j++) {
//				System.out.print(dp[i][j] + " ");
//			}
//			System.out.println();
//		}
//		System.out.println(dp[a.length()][b.length()]);
		System.out.println(sb.toString());

	}

}


Compiler output:
Main.java:2: 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>
#define int long long int
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL);
#define fr(i,a,b)  for(int i=a;i<=b;i++)
#define rf(j,b,a)  for(int j=b;j>=a;j--)
#define frr(k,a,b) for(int k=a;k<=b;k++)
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define ss second
#define ff first

using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
#define E 2000 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
     if(a.first==b.first)
     {
     return (a.second < b.second); 
     }
     else
     {
       return (a.first > b.first); 
     }
     
} 
bool sortin(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
     return (a.second < b.second);   
} 
signed main()
{   
  IOS


string s,t;
cin>>s;
cin>>t;
int s1 = s.size();
int t1 = t.size();
int dp[s1+1][t1+1];
for(int i=0;i<=s1;i++)
{
  for(int j=0;j<=t1;j++)
{
if(i==0||j==0)
{
  dp[i][j]=0;
  continue;
}
if(s[i-1]==t[j-1])
{
  dp[i][j]= 1 + dp[i-1][j-1];
}
else
{   
  dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
}
}
}
int len = dp[s1][t1];
int val =0;
int tmp1=s1;
int tmp2=s2;
string ans;
while(val!=len&&tmp2>=1&&tmp1>=1)
{
if(s[tmp1-1]==t[tmp2-1])
{
ans = s[tmp1-1] + ans;
tmp2--;
tmp1--;
val++;
}
else if(dp[tmp1][tmp2]==dp[tmp1-1][tmp2])
{
tmp1--;
}
else
{
  tmp2--;
}
}
}




 

Compiler output:
a.cc: In function 'int main()':
a.cc:68:10: error: 's2' was not declared in this scope; did you mean 's1'?
   68 | int tmp2=s2;
      |          ^~
      |          s1
Language: C++

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

int main()
{
	string str1,str2;
	cin>>str1>>str2;

	int m=str1.length(),n=str2.length();
	int dp[m+1][n+1];

	memset(dp,0,sizeof(dp));

	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(str1[i-1]==str2[j-1])
				dp[i][j]=1+dp[i-1][j-1];

			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}

	string ans="";

	int i=m,j=n;
	while(i>0 && j>0)
	{
		if(str1[i-1]==str2[j-1])
		{
			ans=str1[i-1]+ans;;
			i--;
			j--;a
		}

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

			else
				j--;
		}
	}

	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:29: error: 'a' was not declared in this scope
   36 |                         j--;a
      |                             ^