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

#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
typedef long long ll;
using namespace std;
const double pi = (2 * acos(0));


struct point
{
	long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double a = (x2*y3) - (x3*y2) - (x1*y3) + (x3*y1) + (x1*y2) - (x2*y1);
	a /= 2;
	return fabs(a);
}

long double anyarea(point p[], int n)
{
	long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += p[i].x * p[i + 1].y;
		sum2 += p[i].y * p[i + 1].x;
	}
	return  fabs((sum1 - sum2) * 0.5);
}

ll fastpow(ll base, ll p, ll m)
{
	if (p == 0)
		return 1;
	ll ans = fastpow(base, p / 2, m);
	ans = ((ans%m)*(ans%m)) % m;
	if (p % 2)
		ans = ((base%m)*ans) % m;
	return ans;
}
ll GCD(ll M, ll m)
{
	if (M%m == 0)
		return m;
	M %= m;
	ll x1 = M, x2 = m;
	m = min(x1, x2);
	M = max(x1, x2);
	return GCD(M, m);


}
ll lcm(ll M, ll m)
{	
	return (M*m) / GCD(max(M, m), min(M, m));

}


	
int n, n2, k;
string s, s2;
int dp[3005][3005];
int solve(int i,int j)
{
	if (dp[i][j] != -1)
	{
		return dp[i][j];
	}
	if (i >= n||j>=n2)
		return 0;
	if (s[i] == s2[j])
	{
		return dp[i][j] = 1 + solve(i + 1, j + 1);
	}
	int m = 0, im = -1;
	

	return dp[i][j] = max(solve(i,j+1),solve(i+1,j));

}
void fun(int i, int j)
{
	if (i >= n || j >= n2)
		return;
	if (s[i] == s2[j])
	{
		cout << s[i] ;
		fun(i+1, j + 1);
	}


	else if (dp[i][j] == (solve(i, j + 1)))
	{
		fun(i, j + 1);
	}
	else if (dp[i][j] == solve(i + 1, j))
	{
		fun(i+1, j);

	}

}

int main()
	{
	cin >> s >> s2;
	memset(dp, -1, sizeof dp);
	n = s.size(); n2 = s2.size();
	int x=solve(0, 0);
	fun(0, 0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:118:9: error: 'memset' was not declared in this scope
  118 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:13:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   12 | #include<queue> //priority_queue
  +++ |+#include <cstring>
   13 | #include<vector>
Language: C++

#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
typedef long long ll;
using namespace std;
const double pi = (2 * acos(0));


struct point
{
	long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double a = (x2*y3) - (x3*y2) - (x1*y3) + (x3*y1) + (x1*y2) - (x2*y1);
	a /= 2;
	return fabs(a);
}

long double anyarea(point p[], int n)
{
	long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += p[i].x * p[i + 1].y;
		sum2 += p[i].y * p[i + 1].x;
	}
	return  fabs((sum1 - sum2) * 0.5);
}

ll fastpow(ll base, ll p, ll m)
{
	if (p == 0)
		return 1;
	ll ans = fastpow(base, p / 2, m);
	ans = ((ans%m)*(ans%m)) % m;
	if (p % 2)
		ans = ((base%m)*ans) % m;
	return ans;
}
ll GCD(ll M, ll m)
{
	if (M%m == 0)
		return m;
	M %= m;
	ll x1 = M, x2 = m;
	m = min(x1, x2);
	M = max(x1, x2);
	return GCD(M, m);


}
ll lcm(ll M, ll m)
{	
	return (M*m) / GCD(max(M, m), min(M, m));

}


	
int n, n2, k;
string s, s2;
int dp[2005][2005];
int solve(int i,int j)
{
	if (dp[i][j] != -1)
	{
		return dp[i][j];
	}
	if (i >= n||j>=n2)
		return 0;
	if (s[i] == s2[j])
	{
		return dp[i][j] = 1 + solve(i + 1, j + 1);
	}
	int m = 0, im = -1;
	

	return dp[i][j] = max(solve(i,j+1),solve(i+1,j));

}
void fun(int i, int j)
{
	if (i >= n || j >= n2)
		return;
	if (s[i] == s2[j])
	{
		cout << s[i] ;
		fun(i+1, j + 1);
	}


	else if (dp[i][j] == (solve(i, j + 1)))
	{
		fun(i, j + 1);
	}
	else if (dp[i][j] == solve(i + 1, j))
	{
		fun(i+1, j);

	}

}




int main()
	{
	cin >> s >> s2;
	memset(dp, -1, sizeof dp);
	n = s.size(); n2 = s2.size();
	int x=solve(0, 0);
	fun(0, 0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:121:9: error: 'memset' was not declared in this scope
  121 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:13:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   12 | #include<queue> //priority_queue
  +++ |+#include <cstring>
   13 | #include<vector>
Language: C++

s = input()
t = input()

ls = len(s)
lt = len(t)

dp = [[0]*(lt+1) for i in range(ls+1)]

for i in range(1,ls+1):
    for j in range(1,lt+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i][j-1], dp[i-1][j])

max_len = dp[-1][-1]
#print(max_len)

prev = max_len

ans = ""

i = ls
j = lt

for l in range(max_len):
    while dp[i-1][j] == max_len - l:
        i -= 1
    while dp[i][j-1] == max_len - l:
        j -= 1
    ans += s[i-1]
    i -= 1
    j -= 1
print(ans[::-1])


Compiler output:
a.cc:17:2: error: invalid preprocessing directive #print
   17 | #print(max_len)
      |  ^~~~~
a.cc:1:1: error: 's' does not name a type
    1 | s = input()
      | ^
Language: Java

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int queens[][]=new int[n][n];
		for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)a[i][j]=0;
		setboard(queens,n);
		for(int i=0;i<n;i++){
		    for(int j=0;j<n;j++)System.out.println(queens[i][j]+" ");
		    System.out.println("");
		}
	}
    boolean setboard(int[][] a,int n){
        
    }
}


Compiler output:
Main.java:16: error: cannot find symbol
		for(int j=0;j<n;j++)a[i][j]=0;
		                    ^
  symbol:   variable a
  location: class Main
Main.java:17: error: non-static method setboard(int[][],int) cannot be referenced from a static context
		setboard(queens,n);
		^
2 errors
Language: Java

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner in=new Scanner(System.in);
	    String s1=in.next();
	    String s2=in.next();
	    int l1=s1.length();
	    int l2=s2.length();
	    String a[][]=new String[l1][l2];
	    for(int i=0;i<l1;i++){
	        for(int j=0;j<l2;j++)a[i][j]="#";
	    }
	    System.out.println(lcs(a,s1,s2,l1-1,l2-1));
	}
	public static String lcs(String[][] a,String s1,String s2,int n1,int n2){
	    if(s1.charAt(n1)==s2.charAt(n2)){
	        String t=Character.toString(s1.charAt(n1));
	        if(n1==0||n2==0)a[n1][n2]=t;
	        else {if(a[n1-1][n2-1].equals("#"))a[n1][n2]=lcs(a,s1,s2,n1-1,n2-1)+t;
	        else a[n1][n2]=a[n1-1][n2-1]+t;}
	        return a[n1][n2];
	    }
	    if(n1==0&&n2!=0){
	        a[n1][n2]= (a[n1][n2-1].equals("#"))?lcs(a,s1,s2,n1,n2-1):a[n1][n2-1];
	        return a[n1][n2];
	    }
	    if(n1!=0&&n2==0){
	        a[n1][n2]= (a[n1-1][n2].equals("#"))?lcs(a,s1,s2,n1-1,n2):a[n1-1][n2];
	        return a[n1][n2];
	    }
	    if(n1==0&&n2==0){
            a[n1][n2]="";
	        return a[n1][n2];
	    }
	    String t1=(a[n1-1][n2].equals("#"))?lcs(a,s1,s2,n1-1,n2):a[n1-1][n2];
	    String t2=(a[n1][n2-1].equals("#"))?lcs(a,s1,s2,n1,n2-1):a[n1][n2-1];
	    a[n1][n2]=(t1.length()>t2.length())?t1:t2;
	    return a[n1][n2];
	}
}


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

import java.lang.Math;

public class Solution {
  public static String LCS(String s1, String s2) {
    if (s1.isEmpty() || s2.isEmpty()) {
      return "";
    }
    int l1 = s1.length();
    int l2 = s2.length();

    // memorization
    int[][] m = new int[l1][l2];
    int maxLen = 0;

    // fill the 0th row
    boolean isFound = false;
    for (int i = 0; i < l1; i++) {
        if (isFound || s1.charAt(i) == s2.charAt(0)) {
            m[i][0] = 1;
            isFound = true;
        } else {
            m[i][0] = 0;
        }
    }

    // fill the 0th column
    isFound = false;
    for (int j = 0; j < l2; j++) {
        if (isFound || s2.charAt(j) == s1.charAt(0)) {
            m[0][j] = 1;
            isFound = true;
        } else {
            m[0][j] = 0;
        }
    }

    // m[i][j] stores the maximum length of subsequence until s1.subString(0, i+1), s2.subString(0, j+1)
    for (int i = 1; i < l1; i++) {
        for (int j = 1; j < l2; j++) {
            if (s1.charAt(i) == s2.charAt(j)) {
                m[i][j] = m[i-1][j-1] + 1;
                maxLen = Math.max(m[i][j], maxLen);
        }   else {
                m[i][j] = Math.max(m[i-1][j], m[i][j-1]);
            }
        }
    }

    // If you want to know just the length of the lcs, return maxLen.
    // Here we'll try to print the lcs.
    StringBuilder sb = new StringBuilder();
    int i = l1 - 1, j = l2 - 1;
    while (i > 0 && j > 0) {
      if (s1.charAt(i) != s2.charAt(j)) {
        if (m[i-1][j] > m[i][j-1]) i--;
        else j--;
      } else {
        sb.append(s1.charAt(i)); // or s2.charAt(j-1)
        i--; j--;
      }
    }

    return sb.reverse().toString();
  }
}

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

#include <bits/stdc++.h>
#include<limits.h>
using namespace  std;
typedef long long int ll;
typedef long double ld;
ll dp[3003][3003];
int main()
{
	string a;
	string b;
	cin>>a;
	cin>>b;
	ll n=a.length();
	ll m=b.length();
	//fillv(dp,0);
	for (ll i=0;i<=n;i++)
		dp[i][0]=0;
	for (ll i=0;i<=m;i++)
		dp[0][i]=0;
	 stack <char> s;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)
		{
			if(a[i-1]==b[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	ll i=n;
	ll j=m;
	if(dp[n][m]==0)
	{
		cout<<"";
		return;
	}
	// cout<<dp[n][m];
	while(i>=1&&j>=1)
	{
		if(dp[i-1][j-1]+1==dp[i][j])
		{
			s.push(a[i-1]);
			i--;
			j--;
		}
		else
		{
		if(dp[i-1][j]>dp[i][j-1])
			i--;
		else 
			j--;
		}
		
	}
	while(!s.empty())
	{
		cout<<s.top();
		s.pop();
	}
	cout<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   38 |                 return;
      |                 ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define n 3000
int max(int a,int b)
{
	if(a>b) return a;
	else return b;
}
void reverseStr(string& str) 
{ 
    int k = str.length(); 
  
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < k / 2; i++) 
        swap(str[i], str[k - i - 1]); 
} 
char* dp(char *str1,char *str2)
{
	int i,j;
	int n1=strlen(str1);
	int n2=strlen(str2);
	int a[n1+1][n2+1];
	for(i=0;i<=n1;i++)
	{
		for(j=0;j<=n2;j++)
		{
			if(i==0||j==0)
			{
				a[i][j]=0;
			}
			else if(str1[i-1]==str2[j-1])
			{
				a[i][j]=1+a[i-1][j-1];	
			}
			else
			{
				a[i][j]=max(a[i-1][j],a[i][j-1]);
			}
	
		}
	}
	char res[n];
	int k=0;
	 i = n1; j = n2; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (str1[i-1] == str2[j-1]) 
      { 
         res[k]=str1[i-1] ;  // reduce values of i, j and index 
         i--;
         j--;
         k++;
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (a[i-1][j] > a[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   res[k]='\0';
   strrev(res);
   cout<<res;
   

} 
int main()
{
	char str1[n],str2[n],*res;
	cin>>str1;
	cin>>str2;
	if(strlen(str1)>strlen(str2))
	{
		res=dp(str1,str2);
	}
	else
	{
		res=dp(str2,str1);	
	}
	}

Compiler output:
a.cc: In function 'char* dp(char*, char*)':
a.cc:66:4: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   66 |    strrev(res);
      |    ^~~~~~
      |    strsep
a.cc:70:1: warning: no return statement in function returning non-void [-Wreturn-type]
   70 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define n 3000
int max(int a,int b)
{
	if(a>b) return a;
	else return b;
}
char* dp(char *str1,char *str2)
{
	int i,j;
	int n1=strlen(str1);
	int n2=strlen(str2);
	int a[n1+1][n2+1];
	for(i=0;i<=n1;i++)
	{
		for(j=0;j<=n2;j++)
		{
			if(i==0||j==0)
			{
				a[i][j]=0;
			}
			else if(str1[i-1]==str2[j-1])
			{
				a[i][j]=1+a[i-1][j-1];	
			}
			else
			{
				a[i][j]=max(a[i-1][j],a[i][j-1]);
			}
	
		}
	}
	char res[n];
	int k=0;
	 i = n1; j = n2; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (str1[i-1] == str2[j-1]) 
      { 
         res[k]=str1[i-1] ;  // reduce values of i, j and index 
         i--;
         j--;
         k++;
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (a[i-1][j] > a[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   res[k]='\0';
   strrev(res);
   cout<<res;
   

} 
int main()
{
	char str1[n],str2[n],*res;
	cin>>str1;
	cin>>str2;
	if(strlen(str1)>strlen(str2))
	{
		res=dp(str1,str2);
	}
	else
	{
		res=dp(str2,str1);	
	}
	}

Compiler output:
a.cc: In function 'char* dp(char*, char*)':
a.cc:58:4: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   58 |    strrev(res);
      |    ^~~~~~
      |    strsep
a.cc:62:1: warning: no return statement in function returning non-void [-Wreturn-type]
   62 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define n 3000
int max(int a,int b)
{
	if(a>b) return a;
	else return b;
}
char* dp(char *str1,char *str2)
{
	int i,j;
	int n1=strlen(str1);
	int n2=strlen(str2);
	int a[n1+1][n2+1];
	for(i=0;i<=n1;i++)
	{
		for(j=0;j<=n2;j++)
		{
			if(i==0||j==0)
			{
				a[i][j]=0;
			}
			else if(str1[i-1]==str2[j-1])
			{
				a[i][j]=1+a[i-1][j-1];	
			}
			else
			{
				a[i][j]=max(a[i-1][j],a[i][j-1]);
			}
	
		}
	}
	char res[n];
	int k=0;
	 i = n1; j = n2; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (str1[i-1] == str2[j-1]) 
      { 
         res[k]=str1[i-1] ;  // reduce values of i, j and index 
         i--;
         j--;
         k++;
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (a[i-1][j] > a[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   res[k]='\0';
   strrev(res);
   cout<<res;
   

} 
int main()
{
	char str1[n],str2[n],*res;
	cin>>str1;
	cin>>str2;
	if(strlen(str1)>strlen(str2))
	{
		res=dp(str1,str2);
	}
	else
	{
		res=dp(str2,str1);	
	}
	}

Compiler output:
a.cc: In function 'char* dp(char*, char*)':
a.cc:57:4: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   57 |    strrev(res);
      |    ^~~~~~
      |    strsep
a.cc:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
   61 | }
      | ^
Language: C++

using namespace std;

int memo[3009][3009];
 
int main(){
  string s,t;
  cin >> s >> t;
  int S=s.size(),T=t.size();
  for(int i=0;i<S;i++){memo[i][0]=0;}
  for(int j=0;j<T;j++){memo[0][j]=0;}
  for(int i=0;i<S;i++){
    for(int j=0;j<T;j++){
      if(s[i]==t[j]){memo[i+1][j+1]=memo[i][j]+1;}
      else{memo[i+1][j+1]=max(memo[i][j+1],memo[i+1][j]);}
    }
  }
  //cout << memo[S][T] << endl;
  int l=memo[S][T];
  string ans="";
  int i=0,j=0;
  while(l>0){
    if(s[i]==t[j]){
      ans+=s[i];
      i++; j++; l--;
    }
    else if(memo[i][j]==memo[i+1][j]){i++;}
    else{j++;}
  }
  cout << ans << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'string' was not declared in this scope
    6 |   string s,t;
      |   ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> s >> t;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:7:10: error: 's' was not declared in this scope
    7 |   cin >> s >> t;
      |          ^
a.cc:7:15: error: 't' was not declared in this scope
    7 |   cin >> s >> t;
      |               ^
a.cc:10:17: error: 'T' was not declared in this scope
   10 |   for(int j=0;j<T;j++){memo[0][j]=0;}
      |                 ^
a.cc:12:19: error: 'T' was not declared in this scope
   12 |     for(int j=0;j<T;j++){
      |                   ^
a.cc:14:27: error: 'max' was not declared in this scope
   14 |       else{memo[i+1][j+1]=max(memo[i][j+1],memo[i+1][j]);}
      |                           ^~~
a.cc:18:17: error: 'T' was not declared in this scope
   18 |   int l=memo[S][T];
      |                 ^
a.cc:19:9: error: expected ';' before 'ans'
   19 |   string ans="";
      |         ^~~~
      |         ;
a.cc:23:7: error: 'ans' was not declared in this scope
   23 |       ans+=s[i];
      |       ^~~
a.cc:29:3: error: 'cout' was not declared in this scope
   29 |   cout << ans << endl;
      |   ^~~~
a.cc:29:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:29:11: error: 'ans' was not declared in this scope
   29 |   cout << ans << endl;
      |           ^~~
a.cc:29:18: error: 'endl' was not declared in this scope
   29 |   cout << ans << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:29:23: error: expected '}' at end of input
   29 |   cout << ans << endl;
      |                       ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: Java


/*
USER: caoash3
LANG: JAVA
TASK: 
*/

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

public class LCS {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			
			String s = br.nextToken();
			String t = br.nextToken();
			
			int N = s.length();
			int M = t.length();
			
			String[][] dp = new String[N+1][M+1];
			
			dp[0][0] = "";
			
			for(int i = 1; i <= N; i++) {
				dp[i][0] = "";
			}
			
			for(int i = 1; i <= M; i++) {
				dp[0][i] = "";	
			}
			
			for(int i = 1; i <= N; i++) {
				for(int j = 1; j <= M; j++) {
					String s1 = dp[i-1][j];
					String s2 = dp[i][j-1];
					String s3 = dp[i-1][j-1];	
					
					
					int c = (s.charAt(i-1) == t.charAt(j-1) ? 1 : 0);
					
					//check if the ith equals the jth, only +1 then
					
					if(s1.length() > (s3.length()+c) && (s1.length() > s2.length())) {
						dp[i][j] = dp[i-1][j];
					}
					else if(s3.length()+c > s1.length() && s3.length()+c > s2.length()) {
						dp[i][j] = dp[i-1][j-1] + (c == 1 ? s.charAt(i-1) : "");
					}
					else {
						dp[i][j] = dp[i][j-1];
					}
					
				}
			}
			
			pw.println(dp[N][M]);
			
			pw.close();
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



Compiler output:
Main.java:11: 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;
int main()
{
    
    string s;
    string t;
    string str;
    //cin.ignore();
    long long int i,j;
    vector<vector<long long int> >a(4001);
    for(i=0;i<=4000;i++) a[i]=vector<long long int>(4001,0);
   // cout<<-1;
   // cout<<-1;
   cin>>s>>t; 
    //cout<<s<<endl;
    //cout<<-1<<endl;
    for(i=0;i<=s.length();i++)
    {
        for(j=0;j<=t.length();j++)
        {
            if(j==0||i==0)
            {
                a[i][j]=0;
                continue;
            }
            else
            {
                if(s[i-1]==t[j-1])
                {
                    a[i][j]=a[i-1][j-1]+1;
                    //if(a[i][j]!=a[i-1][j]);
                   // cout<<t[j-1];
                    
                }
                else
                {
                    a[i][j]=max(a[i-1][j],a[i][j-1]);
                }
            }
        }
    }
    //int len;
    //len=a[i-1][j-1];
     i=s.length();
     j=t.length();
     string ans;
    while(i!=0&&j!=0)
    {
    	if(s[i-1]==t[j-1])
    	{
    		ans=ans+s[i-1];
    		i=i-1;
    		j=j-1;
    		len--;
    		
		}
		else if(a[i-1][j]>a[i][j-1])
		{
			i=i-1;
		}
		else
		{
			j=j-1;
		}
	}
	for(i=ans.length()-1;i>=0;i--)
	cout<<ans[i];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:17: error: 'len' was not declared in this scope
   55 |                 len--;
      |                 ^~~
Language: C++

#include <bits/stdc++.h>
#define Im using
#define Too_Stupid_To namespace
#define Solve_This_Problem std
Im Too_Stupid_To Solve_This_Problem;
string a,b;
int dp[3005][3005];
string f(int n,int m){
  if (n==-1 || m==-1) return "";
  if (dp[n][m]!=-1)return ret;
  if (a[n]==b[m]) return f(n-1,m-1)+a[n];
  else{
    string val=f(n-1,m);
    string val2=f(n,m-1);
    if (val.size()>val2.size()){
      return val;
    }
    else return val2;
  }


}
int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> a >> b;
  memset(dp,-1,sizeof dp);
  cout << f(a.size()-1,b.size()-1) << '\n';
}

Compiler output:
a.cc: In function 'std::string f(int, int)':
a.cc:10:27: error: 'ret' was not declared in this scope
   10 |   if (dp[n][m]!=-1)return ret;
      |                           ^~~
Language: C++

#include<cstdio>
bool v[3000][3000][3];
int l[3001][3001];
char s[3002],t[3002],u[3000];
int main(){
  scanf("%s%s",s+1,t+1);
  int sl=1,tl=1;
  while(s[sl]!='\0')sl++;
  while(t[tl]!='\0')tl++;
  for(int i=0;i<sl;i++){
    for(int j=0;j<tl;j++){
      for(int k=0;k<3;k++)v[i][j][k]=false;
      if(i==0||j==0)l[i][j]=0;
      if(s[i]==t[j]){
        v[i][j][0]=true;
        l[i][j]=l[i-1][j-1]+1;
      }else{
        if(l[i-1][j]<=l[i][j-1]){
          v[i][j][1]=true;
          l[i][j]=l[i][j-1];
        }
        if(l[i-1][j]>=l[i][j-1]){
          v[i][j][2]=true;
          l[i][j]=l[i-1][j];
        }
      }
    }
  }
  int wl=0,nowi=sl-1,nowj=tl-1;
  while(nowi>0&&nowj>0){
    if(v[nowi][nowj][0]){
      w[wl]=s[nowi];
      nowi--;
      nowj--;
      wl++;
    }else if(v[nowi][nowj][1])nowj--;
    else if(v[nowi][nowj][2])nowi--;
  }
  for(int i=wl-1;i>=0;i--)printf("%c",w[i]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:7: error: 'w' was not declared in this scope; did you mean 'wl'?
   32 |       w[wl]=s[nowi];
      |       ^
      |       wl
a.cc:39:39: error: 'w' was not declared in this scope
   39 |   for(int i=wl-1;i>=0;i--)printf("%c",w[i]);
      |                                       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,t,k,dp[5000][5000],a[200001],b[200001],ans,B;
string s,s1,o;
int main () {
    cin>>s>>s1;
    for (i=1;i<=s.size();i++) {
        for (j=1;j<=s1.size();j++) {
            if (s[i-1]==s1[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ans=dp[s.size()][s1.size()];#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,t,k,dp[5000][5000],a[200001],b[200001],ans,B;
string s,s1,o;
int main () {
    cin>>s>>s1;
    for (i=1;i<=s.size();i++) {
        for (j=1;j<=s1.size();j++) {
            if (s[i-1]==s1[j-1]) dp[i][j]=max(dp[i-1][j-1]+1,max(dp[i-1][j],dp[i][j-1]));
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ans=dp[s.size()][s1.size()];
    i=s.size();
    j=s1.size();
    if (ans==0) return 0;
    while(ans>0) {
        if (dp[i][j]==dp[i-1][j-1]+1) {o=o+s[i-1];i--;j--;ans--;continue;}
        if (dp[i][j]==dp[i-1][j]) {i--;continue;}
        if (dp[i][j]==dp[i][j-1]) {j--;continue;}
    }
    for (i=o.size()-1;i>=0;i--) {
        cout<<o[i];
    }
    cout<<endl;
    return 0;
}
    i=s.size();
    j=s1.size();
    if (ans==0) return 0;
    while(ans>0) {
        if (dp[i][j]==dp[i-1][j-1]+1) {o=o+s[i-1];i--;j--;ans--;continue;}
        if (dp[i][j]==dp[i-1][j]) {i--;continue;}
        if (dp[i][j]==dp[i][j-1]) {j--;continue;}
    }
    for (i=o.size()-1;i>=0;i--) {
        cout<<o[i];
    }
    cout<<endl;
    return 0;
}

Compiler output:
a.cc:14:33: error: stray '#' in program
   14 |     ans=dp[s.size()][s1.size()];#include <bits/stdc++.h>
      |                                 ^
a.cc: In function 'int main()':
a.cc:14:34: error: 'include' was not declared in this scope
   14 |     ans=dp[s.size()][s1.size()];#include <bits/stdc++.h>
      |                                  ^~~~~~~
a.cc:14:43: error: 'bits' was not declared in this scope
   14 |     ans=dp[s.size()][s1.size()];#include <bits/stdc++.h>
      |                                           ^~~~
a.cc:14:48: error: 'stdc' was not declared in this scope; did you mean 'std'?
   14 |     ans=dp[s.size()][s1.size()];#include <bits/stdc++.h>
      |                                                ^~~~
      |                                                std
a.cc:15:1: error: expected primary-expression before 'using'
   15 | using namespace std;
      | ^~~~~
a.cc:18:10: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   18 | int main () {
      |          ^~
a.cc:18:10: note: remove parentheses to default-initialize a variable
   18 | int main () {
      |          ^~
      |          --
a.cc:18:10: note: or replace parentheses with braces to value-initialize a variable
a.cc:18:13: error: a function-definition is not allowed here before '{' token
   18 | int main () {
      |             ^
Language: C++

#include <bits/stdc++.h>

#define MAX_L 3000

int dp[MAX_L + 1][MAX_L + 1];
std::pair<int, int> hist[MAX_L + 1][MAX_L + 1];

int main() {
  std::string s, t;
  int ls, lt;

  std::cin >> s >> t;
  ls = (int) s.size();
  lt = (int) t.size();

  hist[0][0] = std::make_pair(0, 0);
  for(int i = 0; i < ls; ++i) {
    for(int j = 0; j < lt; ++j) {
      if(s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
        hist[i + 1][j + 1] = std::make_pair(i, j);
      } else {
        dp[i + 1][j + 1] = std::max(dp[i + 1][j], dp[i][j + 1]);
        if(dp[i + 1][j + 1] == dp[i + 1][j]) hist[i + 1][j + 1] = std::make_pair(i + 1, j);
        else hist[i + 1][j + 1] = std::make_pair(i, j + 1);
      }
    }
  }

  std::string ans = "";
  int i = ls, j = lt;
  while(i >= 0 && j >= 0) {
    auto p = hist[i][j];
    i = p.first, j = p.second;
    if(s[i] == t[j]) ans = s[i] + ans;
    if(i == 0 && j == 0) break;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:37:4: error: expected '}' at end of input
   37 |   }
      |    ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
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] = ''; // 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; 
} 



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s>>t;
    int m=s.length();
    int n=t.length();
    
    lcs(s,t,m,n);
    //cout<<dp[2][3]<<endl;

}

Compiler output:
a.cc:32:17: error: empty character constant
   32 |    lcs[index] = ''; // Set the terminating character
      |                 ^~
a.cc: In function 'int main()':
a.cc:65:10: error: 's' was not declared in this scope
   65 |     cin>>s>>t;
      |          ^
a.cc:65:13: error: 't' was not declared in this scope; did you mean 'tm'?
   65 |     cin>>s>>t;
      |             ^
      |             tm
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int depth[100100];
int par[100100];

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    void init(int n) { par.assign(n,-1);}
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    string s,t; cin >> s >> t;
    int ns = s.size(); int nt = t.size();
    dp[3030][3030] = {0};
    for(int i = 0; i < ns; i++){
        for(int j = 0; j < nt; j++){
            if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }
    string res = "";
    while(ns > 0 && nt > 0){
        if(dp[ns][nt] == dp[ns-1][nt]) ns--;
        else if(dp[ns][nt] == dp[ns][nt-1]) nt--;
        else {
            res = s[ns-1] + res;
            ns--; nt--;
        }
    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:5: error: 'dp' was not declared in this scope; did you mean 'dy'?
   45 |     dp[3030][3030] = {0};
      |     ^~
      |     dy
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s,t;
int dp[3001][3001];
int solve(int l, int r){
	if(l<0||r<0) return 0;
	int& ret=dp[l+1][r+1];
	if(s[l]==t[r])
		return ret=1+solve(l-1,r-1);
	if(ret!=-1) return ret;
	int tmp=solve(l-1,r);
	ret=solve(l,r-1);
	if(ret<tmp)
		ret=tmp;
	return ret;
}
int main(){
	cin>>s>>t;
	for(int i=0;i<s.length();i++)
		for(int j=0;j<t.length();j++)
			dp[i][j]=-1;
	int sl=s.length();
	int tl=t.length();
	solve(sl-1,tl-1);
	vector<char> ans;
	while(sl>0&&tl>0){
		if(s[sl-1]==t[tl-1]){ 
			ans.push_back(s[sl-1]);
			sl--;
			tl--;
			continue;
		}
		if(dp[sl-1][tl]>dp[sl][tl-1])
			sl--;
		else
			tl--;
	}
	reverse(ans.begin(),ans.end());
	for(char a:ans)
		cout<<a;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'vector' was not declared in this scope
   27 |         vector<char> ans;
      |         ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:27:16: error: expected primary-expression before 'char'
   27 |         vector<char> ans;
      |                ^~~~
a.cc:30:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |                         ans.push_back(s[sl-1]);
      |                         ^~~
      |                         abs
a.cc:40:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |         reverse(ans.begin(),ans.end());
      |                 ^~~
      |                 abs
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s,t;
vector<char> dp[3001][3001];

vector<char> solve(int i,int j){
    if(i<0||j<0) return {};
    vector<char> &ret=dp[i][j];
    if(!ret.empty())
    return ret;
    if(s[i]==t[j]){
		ret=solve(i-1,j-1);
        ret.push_back(s[i]);
        return ret;
    }
    vector<char> o=solve(i-1,j);
    ret=solve(i,j-1);
    if(ret.size()<o.size())
    ret=o;
    return ret;

}
int main(){
	cin>>s>>t;
	vector<char> ans=solve(s.length()-1,t.length());
	for(auto i:ans)
		cout<<i;
	return 0;
}

Compiler output:
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<char> dp[3001][3001];
      | ^~~~~~
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<char> solve(int i,int j){
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:27:9: error: 'vector' was not declared in this scope
   27 |         vector<char> ans=solve(s.length()-1,t.length());
      |         ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:27:16: error: expected primary-expression before 'char'
   27 |         vector<char> ans=solve(s.length()-1,t.length());
      |                ^~~~
a.cc:28:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |         for(auto i:ans)
      |                    ^~~
      |                    abs
Language: Java

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


public class code{
	public static int max(int a,int b){
		if(a>b)return a;
		else return b;
	}
	public static double max(double a,double b){
		if(a>b)return a;
		else return b;
	}
	public static String fun(String a,String b){
				int n=a.length();
				int m=b.length();


				int [][]dp=new int[n+1][m+1] ;
				for(int i=1;i<=n;i++){
					for(int j=1;j<=m;j++){
						if(a.charAt(i-1)==b.charAt(j-1)){
							dp[i][j]=1+dp[i-1][j-1];
						}
						else{
							dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
						}
					}
				}
				//System.out.println(dp[n][m]);

String ans="";
int i=n;
int j=m;
try{
while(i>0&&j>0){
	if(a.charAt(i-1)==b.charAt(j-1)){
		ans+=a.charAt(i-1);
		i--;
		j--;
	}
	else{
		if(dp[i][j-1]<dp[i-1][j]){
			i--;
		}
		else{
			j--;
		}
	}
}}
catch(Exception e){
	System.out.println(i+" "+j);
}
StringBuilder sb =new StringBuilder();
for(int ii=ans.length()-1;ii>=0;ii--){
	sb.append(ans.charAt(ii));
}

return sb.toString();

	} 
	public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		System.out.println(fun(a,b));
	}
}

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

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


public class code{
	public static int max(int a,int b){
		if(a>b)return a;
		else return b;
	}
	public static double max(double a,double b){
		if(a>b)return a;
		else return b;
	}
	public static String fun(String a,String b){
				int n=a.length();
				int m=b.length();


				int [][]dp=new int[n+1][m+1] ;
				for(int i=1;i<=n;i++){
					for(int j=1;j<=m;j++){
						if(a.charAt(i-1)==b.charAt(j-1)){
							dp[i][j]=1+dp[i-1][j-1];
						}
						else{
							dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
						}
					}
				}
				System.out.println(dp[n][m]);

String ans="";
int i=n;
int j=m;
try{
while(i>0&&j>0){
	if(a.charAt(i-1)==b.charAt(j-1)){
		ans+=a.charAt(i-1);
		i--;
		j--;
	}
	else{
		if(dp[i][j-1]<dp[i-1][j]){
			i--;
		}
		else{
			j--;
		}
	}
}}
catch(Exception e){
	System.out.println(i+" "+j);
}
StringBuilder sb =new StringBuilder();
for(int ii=ans.length()-1;ii>=0;ii--){
	sb.append(ans.charAt(ii));
}

return sb.toString();

	} 
	public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		System.out.println(fun(a,b));
	}
}

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

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


public class code{
	public static int max(int a,int b){
		if(a>b)return a;
		else return b;
	}
	public static double max(double a,double b){
		if(a>b)return a;
		else return b;
	}
	public static String fun(String a,String b){
				int n=a.length();
				int m=b.length();


				int [][]dp=new int[n+1][m+1] ;
				for(int i=1;i<=n;i++){
					for(int j=1;j<=m;j++){
						if(a.charAt(i-1)==b.charAt(j-1)){
							dp[i][j]=1+dp[i-1][j-1];
						}
						else{
							dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
						}
					}
				}
				System.out.println(dp[n][m]);

String ans="";
int i=n;
int j=m;
try{
while(i>0&&j>0){
	if(a.charAt(i-1)==b.charAt(j-1)){
		ans+=a.charAt(i-1);
		i--;
		j--;
	}
	else{
		if(dp[i][j-1]<dp[i-1][j]){
			i--;
		}
		else{
			j--;
		}
	}
}}
catch(Exception e){
	System.out.println(i+" "+j);
}
StringBuilder sb =new StringBuilder();
for(int ii=ans.length()-1;ii>=0;ii--){
	sb.append(ans.charAt(ii));
}

return sb.toString();

	} 
	public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		System.out.println(fun(a,b));
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class code{
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int par[100];
int depth[100];
string s, t;
int dp[3030][3030] = {0};

template<class T> inline bool chmax(T& a, T b){ if(a < b) {a = b; return true;}
return false;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) {a = b; return true;}
return false;}
int main(){
    cin >> s >> t;
    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);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string res = "";
    int i = s.size(); int j = t.size();
    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 {
            res = s[i-1] + res;
            i--; j--;
        }
    }
    cout << res << endl;
}

Compiler output:
a.cc:20:38: error: expected ')' before '&' token
   20 | template<class T> inline bool chmax(T& a, T b){ if(a < b) {a = b; return true;}
      |                                      ^
a.cc:10:21: note: in definition of macro 'chmax'
   10 | #define chmax(a,b) (a<b ? a=b:0)
      |                     ^
a.cc:10:20: note: to match this '('
   10 | #define chmax(a,b) (a<b ? a=b:0)
      |                    ^
a.cc:20:31: note: in expansion of macro 'chmax'
   20 | template<class T> inline bool chmax(T& a, T b){ if(a < b) {a = b; return true;}
      |                               ^~~~~
a.cc:22:38: error: expected ')' before '&' token
   22 | template<class T> inline bool chmin(T& a, T b){ if(a > b) {a = b; return true;}
      |                                      ^
a.cc:11:21: note: in definition of macro 'chmin'
   11 | #define chmin(a,b) (a>b ? a=b:0)
      |                     ^
a.cc:11:20: note: to match this '('
   11 | #define chmin(a,b) (a>b ? a=b:0)
      |                    ^
a.cc:22:31: note: in expansion of macro 'chmin'
   22 | template<class T> inline bool chmin(T& a, T b){ if(a > b) {a = b; return true;}
      |                               ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
void DP(string s,string b,int i,int j, int l1,int lb)
{
  
 	if(i==l1 || i==lb)
      	return ;
  
  if(s[i]==s[j]){
    cout<<s[i];
    	DP(s,b,i+1,j+1,l1.lb);
  	}
  	else
    {
      DP(s,b,i+1,j,l1,lb);DP(s,b,i,j+1,l1,lb);}
  
  }

int main(){
  
  string a,b;
  cin>>a>>b;
  
  DP(a,b,a,0,0,length(),b.length());
  return 0;
}

Compiler output:
a.cc: In function 'void DP(std::string, std::string, int, int, int, int)':
a.cc:11:27: error: request for member 'lb' in 'l1', which is of non-class type 'int'
   11 |         DP(s,b,i+1,j+1,l1.lb);
      |                           ^~
a.cc: In function 'int main()':
a.cc:24:16: error: 'length' was not declared in this scope
   24 |   DP(a,b,a,0,0,length(),b.length());
      |                ^~~~~~
Language: Java

import java.util.Scanner;

public class AtCoder {

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

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

        for(int i=1 ; i<= s.length() ; i++ ){
            char ci = s.charAt(i-1);
            for(int j=1 ; j<= t.length() ; j++ ){
                char cj = t.charAt(j-1);
                if(ci == cj){
                    dp[i][j]=dp[i-1][j-1]+ci+"";
                }else{
                    if(dp[i][j-1].length()>=dp[i-1][j].length()){
                        dp[i][j]=dp[i][j-1];
                    }else{
                        dp[i][j]=dp[i-1][j];
                    }
                }
            }
        }

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



    }
}


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

#include <bits/stdc++.h>

using namespace std;

string s, t;
string DP[3005][3005];

string smax(string a, string b)
{
	return a.size() > b.size() ? a : b;
}

int main()
{
	cin >> s >> t;
	if(s[0] == t[0])
		DP[0][0] = s[0];
	for(int i = 1; i < s.size(); i++)
	{
		if(s[i] == t[0])
			DP[i][0] = s[i];
		else
			DP[i][0] = DP[i - 1][0];
	}
	for(int i = 1; i < t.size(); i++)
	{
		if(t[i] == s[0])
			DP[0][i] = s[i];
		else
			DP[0][i] = DP[0][i - 1];
	}
	for(int i = 1; i < s.size(); i++)
	{
		for(int k = 1; k < t.size(); k++)
		{
			if(s[i] == t[k])
				DP[i][k] = DP[i - 1][k - 1] + s[i];
			else
				DP[i][k] = smax(DP[i - 1][k], DP[i][k - 1]);
		}
	}
	cout << DP[s.size() - 1][t.size() - 1];
	return 0;
}


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

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

#define MAXN 3010

string s,t;
string ans;

int dp[MAXN][MAXN];

void dfs(int i, int j) {
  int val = dp[i][j];
  if (val == 0) return;
  if (i == 0 && j == 0) {
    ans += s[0];
    return;
  }
  if (i == 0) {
    ans += s[0];
    return;
  }
  if (j == 0) {
    ans += t[j];
  }
  if (val == dp[i-1][j]) {
    dfs(i-1,j);
  } else if (val == dp[i][j-1]) {
    dfs(i,j-1);
  } else {
	ans += s[i];
    dfs(i-1,j-1);
  }
}

int main() {
	cin >> s >> t;
  	int n = (int)s.length(), m = (int)t.length();
  	for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        dp[i][j] = -1;
      }
    }
  	if (s[0] == t[0]) {
      dp[0][0] = 1;
    } else {
      dp[0][0] = 0;
    }
  	for (int i = 1; i < n; i++) {
      dp[i][0] = max(dp[i-1][0],(s[i]==t[0]?1:0));
    } 
  	for (int i = 1; i < m; i++) {
      dp[0][i] = max(dp[0][i-1],(s[0]==t[i]?1:0));
    }
  	for (int i = 1; i < n; i++) {
      for (int j = 1; j < m; j++) {
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        if (s[i] == t[j]) dp[i][j] = max(dp[i][j],1+dp[i-1][j-1]);
      }
    }
  	dfs(n-1,m-1);
  	for (int i = ans.length()-1; i >= 0; i--) {
      cout << ans[i];
    }
  cout << endl;
}
}

Compiler output:
a.cc:67:1: error: expected declaration before '}' token
   67 | }
      | ^
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] = ''; // Set the terminating character 

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

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

// Print the lcs 
cout<< lcs; 
} 

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


Compiler output:
a.cc:32:14: error: empty character constant
   32 | lcs[index] = ''; // Set the terminating character
      |              ^~