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

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

typedef long long ll;

const int MAXN = 3e3 + 5;
const int INF = 0x3f3f3f3f;

int n, m, d[MAXN][MAXN] = {0};
char s[MAXN], t[MAXN], ans[MAXN];
int cnt = 0;

void backtrace(int i, int j) {
    if (i == 0 || j == 0) return;
    if (d[i][j] == d[i - 1][j - 1] + 1) {
        backtrace(i - 1, j - 1);
        putchar(s[i]);
    }
    else if (d[i][j] == d[i - 1][j]) backtrace(i - 1, j);
    else backtrace(i, j - 1);
}

int main() {
    gets(s + 1);
    gets(t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            //printf("%d, %d: %c %c\n", i, j, s[i - 1], t[j - 1]);
            if (s[i] == t[j]) {
                d[i][j] = d[i - 1][j - 1] + 1;
            }
            else {
                d[i][j] = max(d[i - 1][j], d[i][j - 1]);
            }
        }
    backtrace(n, m);
    return 0;
}


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

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

typedef long long ll;

const int MAXN = 3e3 + 5;
const int INF = 0x3f3f3f3f;

string s, t;
int n, m, d[MAXN][MAXN] = {0};
char ans[MAXN];

int main() {
    cin >> s >> t;
    n = s.length();
    m = t.length();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            if (s[i - 1] == t[j - 1]) {
                d[i][j] = d[i - 1][j - 1] + 1;
            }
            else {
                d[i][j] = max(d[i - 1][j], d[i][j - 1]);
            }
        }
    int p = n, q = m, cnt = 0;
    while (p >= 1 && q >= 1 && d[p][q]) {
        if (d[p][q] == d[p - 1][q - 1] + 1) {
            ans[cnt++] = s[p - 1];
            --p; --q;
        }
        else if (d[p][q] == d[p - 1][q]) --p;
        else if (d[p][q] == d[p][q - 1]) --q;
        else break;
    }
    for (int i = cnt - 1; i >= 0; --i) cout << ans[i];
    cout << '' << endl;
    return 0;
}


Compiler output:
a.cc:37:13: error: empty character constant
   37 |     cout << '' << endl;
      |             ^~
Language: C++

//
//  main.cpp
//  F - LCS
//
//  Created by Nishant Dhankhar on 16/01/19.
//  Copyright © 2019 Nishant Dhankhar. All rights reserved.
//
#include </bits/stdc++.h> //REMEMBER TO REMOVE '/'
#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define RE(i,n) for(int i=1;i<=n;i++)
#define ss second
#define ff first
#define vi vector<int>

int dp[3003][3003];
//string dp2[3003][3003];
signed main() {
    string s,t;
    cin>>s>>t;

    for(int i=0;i<max(s.size(),t.size())+3;i++){
        dp[i][0]=dp[0][i]=0;
        //dp2[i][0]=dp2[0][i]="";
    }
    rep(i,s.size()){
        rep(j,t.size()){
               dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            if(s[i]==t[j]){dp[i+1][j+1]=max(dp[i+1][j+1],1+dp[i][j]);}  //dp2[i+1][j+1]=dp2[i][j]+t[j];}
            
    }
    }
    //int x=dp[s.size()][t.size()];
    string a="";
    for(int i=s.size() ,j=t.size(); i>=0&&j>=0;){
        if(dp[i][j]==dp[i-1][j-1]+1 && s[i-1]==t[j-1]) {a+=s[i-1] ; i--; j--;}
        else if(dp[i][j]==dp[i-1][j]) i--;
        else if(dp[i][j]==dp[i][j-1])j--;
    }
    for(int i=a.size()-1;i>=0;i--) cout<<a[i];
    cout<<endl;
    
    return 0;
}


Compiler output:
a.cc:8:10: fatal error: /bits/stdc++.h: No such file or directory
    8 | #include </bits/stdc++.h> //REMEMBER TO REMOVE '/'
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

//
//  main.cpp
//  F - LCS
//
//  Created by Nishant Dhankhar on 16/01/19.
//  Copyright © 2019 Nishant Dhankhar. All rights reserved.
//
#include </bits/stdc++.h> //REMEMBER TO REMOVE '/'
#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define RE(i,n) for(int i=1;i<=n;i++)
#define ss second
#define ff first
#define vi vector<int>

int dp[3003][3003];
string dp2[3003][3003];
signed main() {
    string s,t;
    cin>>s>>t;

    for(int i=0;i<max(s.size(),t.size())+3;i++){
        dp[i][0]=dp[0][i]=0;
        dp2[i][0]=dp2[0][i]="";
    }
    int a=(int)s.size();
    int b=(int)t.size();
    rep(i,a){
        rep(j,b){
            if(s[i]==t[j]){dp[i+1][j+1]=1+dp[i][j];  dp2[i+1][j+1]=dp2[i][j]+t[j];}
            else {
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
                if(dp[i][j+1]>dp[i+1][j])dp2[i+1][j+1]=dp2[i][j+1];
                else dp2[i+1][j+1]=dp2[i+1][j];
        }
    }
    }
    cout<<dp2[s.size()][t.size()]<<endl;
    
    return 0;
}


Compiler output:
a.cc:8:10: fatal error: /bits/stdc++.h: No such file or directory
    8 | #include </bits/stdc++.h> //REMEMBER TO REMOVE '/'
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Language: Java


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class TaskF {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int t = 1;
		for (int i = 1; i <= t; ++i) {
			String a = in.next();
			String b = in.next();
			String r = solve(a, b);
			System.out.println(r);
		}
		in.close();
	}

	private static String solve(String a, String b) {
		int[][] path = new int[a.length() + 1][b.length() + 1];
		int[][] state = new int[a.length() + 1][b.length() + 1];
		for (int i = 1; i <= a.length(); i++) {
			for (int j = 1; j <= b.length(); j++) {
				state[i][j] = state[i - 1][j];
				path[i][j] = 0;
				if (state[i][j] < state[i][j - 1]) {
					state[i][j] = state[i][j - 1];
					path[i][j] = 1;
				}
				if (a.charAt(i - 1) == b.charAt(j - 1) && state[i][j] < state[i - 1][j - 1] + 1) {
					state[i][j] = state[i - 1][j - 1] + 1;
					path[i][j] = 2;
				}
			}
		}
		String r = getStr(a, b, path, a.length(), b.length());
		return r;
	}

	private static String getStr(String a, String b, int[][] path, int i, int j) {
		if (i == 0 || j == 0) {
			return "";
		} else if (path[i][j] == 2) {
			String r = getStr(a, b, path, i - 1, j - 1);
			if (a.charAt(i - 1) == b.charAt(j - 1)) {
				r += a.charAt(i - 1);
			}
			return r;
		} else if (path[i][j] == 0) {
			return getStr(a, b, path, i - 1, j);
		} else {
			return getStr(a, b, path, i, j - 1);
		}
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


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

package Algoritmos;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class LongestCommonSubsequence {

	static int L[][];
	static char X[];
	static char Y[];
	//Halla la longitd de la subsecuencia comun más larga
	static int max(int a, int b) {
		return Math.max(a, b);
	}
	static int lcs1(String s1, String s2) {
		X = s1.toCharArray();
		Y = s2.toCharArray();
		int m = X.length, n = Y.length;
		L = new int[m+1][n+1];
		
		/*
		 * Se llena la matriz L. L[i][j] = lcs(X[0...i-1],Y[0...j-1])
		 */
		for(int i=0; i<=m; i++) {
			for(int j =0; j<=n; j++) {
				if(j==0 || i==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]);
				}
			}
		}
		return L[m][n];
	}
	//Reconstruye la subsecuencia comun más larga
	static String lcs2(String s1, String s2) {
		int index = lcs1(s1,s2);
		//System.out.println(index);
		char [] rta = new char[index];
		int i =X.length,  j = Y.length;
		while(i>0 && j>0 && index>0) {
			if(X[i-1]==Y[j-1]) {
				
				rta[index-1] = X[i-1];
				i--; j--; index--;
			}
			else if(L[i-1][j]>L[i][j-1]) {
				i--;
			}
			else {
				j--;
			}
		}
		return new String(rta);
		
	}
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String s1 = bf.readLine();
		String s2 = bf.readLine();
		String lcs = lcs2(s1,s2);
		System.out.println(lcs);
	}
}


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

import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    String S = sc.next();
    String T = sc.next();
    int[][] dp = new int[S.length() + 1][T.length() + 1];
    for (int i = 1; i <= S.length(); i++) {
      for (int j = 1; j <= T.length(); j++) {
		if (S.charAt(i - 1) == T.charAt(j - 1)) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
        }
      }
    }
    int length = dp[S.length()][T.length()];
    char[] ans = new char[length];
    for (int i = S.length(), j = T.length(), k = length - 1; i > 0 && j > 0;) {
      if (S.charAt(i - 1) == T.charAt(j - 1)) {
        ans[k--] = S[i - 1];
        i--;
        j--;
      } else if (dp[i - 1][j] > dp[i][j - 1]) {
        i--;
      } else {
        j--;
      }
    }
    for (int i = 0; i < length; i++) System.out.print(ans[i]);
    System.out.println();
  }
}

Compiler output:
Main.java:4: error: cannot find symbol
    String S = sc.next();
               ^
  symbol:   variable sc
  location: class Main
Main.java:5: error: cannot find symbol
    String T = sc.next();
               ^
  symbol:   variable sc
  location: class Main
Main.java:20: error: array required, but String found
        ans[k--] = S[i - 1];
                    ^
3 errors
Language: Java

import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    String S = sc.next();
    String T = sc.next();
    for (int i = 1; i <= S.length(); i++) {
      for (int j = 1; j <= T.length(); j++) {
		if (S.charAt(i - 1) == T.charAt(j - 1)) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
        }
      }
    }
    int length = dp[S.length()][T.length()];
    char[] ans = new char[length];
    for (int i = S.length(), j = T.length(), k = length - 1; i > 0 && j > 0;) {
      if (S.charAt(i - 1) == T.charAt(j - 1)) {
        ans[k--] = S[i - 1];
        i--;
        j--;
      } else if (dp[i - 1][j] > dp[i][j - 1]) {
        i--;
      } else {
        j--;
      }
    }
    for (int i = 0; i < length; i++) System.out.print(ans[i]);
    System.out.println();
  }
}

Compiler output:
Main.java:4: error: cannot find symbol
    String S = sc.next();
               ^
  symbol:   variable sc
  location: class Main
Main.java:5: error: cannot find symbol
    String T = sc.next();
               ^
  symbol:   variable sc
  location: class Main
Main.java:9: error: cannot find symbol
          dp[i][j] = dp[i - 1][j - 1] + 1;
          ^
  symbol:   variable dp
  location: class Main
Main.java:9: error: cannot find symbol
          dp[i][j] = dp[i - 1][j - 1] + 1;
                     ^
  symbol:   variable dp
  location: class Main
Main.java:11: error: cannot find symbol
          dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
          ^
  symbol:   variable dp
  location: class Main
Main.java:11: error: cannot find symbol
          dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
                              ^
  symbol:   variable dp
  location: class Main
Main.java:11: error: cannot find symbol
          dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
                                            ^
  symbol:   variable dp
  location: class Main
Main.java:15: error: cannot find symbol
    int length = dp[S.length()][T.length()];
                 ^
  symbol:   variable dp
  location: class Main
Main.java:19: error: array required, but String found
        ans[k--] = S[i - 1];
                    ^
Main.java:22: error: cannot find symbol
      } else if (dp[i - 1][j] > dp[i][j - 1]) {
                 ^
  symbol:   variable dp
  location: class Main
Main.java:22: error: cannot find symbol
      } else if (dp[i - 1][j] > dp[i][j - 1]) {
                                ^
  symbol:   variable dp
  location: class Main
11 errors
Language: Java

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class C {

    static String[][]memo;
    static String s,m;
    static boolean issub(String a){
       if (a==null)return false;
        int i=0,j=0;
        while (i<a.length()&&j<m.length()){
            if (m.charAt(j)==a.charAt(i)){
                i++;
            }
            j++;
        }
        return i==a.length();
    }
    static String dp(int id,int id2) {
        if (id==s.length()||id2==m.length())return "";
        if (memo[id][id2]!=null){
            return memo[id][id2];
        }
        String x1="";
        if (s.charAt(id)==m.charAt(id2)){
            x1=s.charAt(id)+dp(id+1,id2+1);
        }
        String x2=dp(id+1,id2);
        String x3=dp(id,id2+1);
        String ans="";
        if (x1.length()>x2.length()) {
            ans = x1;
        }
        else ans =x2;
        if (x3.length()>ans.length())ans=x3;
        return memo[id][id2]=ans;
        }

    public  static void main(String[]args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        s=sc.nextLine();
        m = sc.nextLine();
        memo= new String[s.length()+1][m.length()+1];
        pw.println(dp(0,0));
       // pw.println(Arrays.deepToString(memo));
      pw.flush();
    }
    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

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

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

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

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

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

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

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


    }
}

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

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

int DP[S.size()+1][T.size()+1];

int main () {
    string S,T;
    cin >> S >> T;
    
    memset(DP,0,sizeof(DP));
    for (int i=1;i<=S.size();i++) {
        for (int j=1;j<=T.size();j++) {
            if (T[j-1]==S[i-1]) {
                DP[i][j]=DP[i-1][j-1]+1;
            }
            else {
                DP[i][j]=max(DP[i-1][j],DP[i][j-1]);
            }
        }
    }
    string ans;
    int i=S.size(),j=T.size();
    while (i>0 && j>0) {
        if (DP[i-1][j-1]+1==DP[i][j] ) {
            ans.push_back(S[i-1]);
            i--;
            j--;
        }
        else if (DP[i][j-1] > DP[i-1][j]) {
            j--;
        }
        else{
            i--;
        }
    }
    for (int k=ans.size()-1;k>=0;k--) {
        cout << ans[k];
    }
    return 0;
}

Compiler output:
a.cc:5:8: error: 'S' was not declared in this scope
    5 | int DP[S.size()+1][T.size()+1];
      |        ^
a.cc:5:20: error: 'T' was not declared in this scope
    5 | int DP[S.size()+1][T.size()+1];
      |                    ^
a.cc: In function 'int main()':
a.cc:11:12: error: 'DP' was not declared in this scope
   11 |     memset(DP,0,sizeof(DP));
      |            ^~
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int opt[3001][3001];
char s[3010], t[3010];

vector<char> ans;

void constructAns(int n, int m) {
	if (n == 0 || m == 0) return;
	else if (s[n-1] == t[m-1]) ans.push_back(s[n-1]), constructAns(n-1, m-1);
	else if (opt[n][m] == opt[n-1][m]) constructAns(n-1, m);
	else constructAns(n, m-1);
}

int main() {
	scanf("%s", s);
	scanf("%s", t);
	int n = strlen(s), m = strlen(t);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i-1] == t[j-1]) opt[i][j] = opt[i-1][j-1] + 1;
			else opt[i][j] = max(opt[i-1][j], opt[i][j-1]);
		}
	}
	constructAns(n, m);
	reverse(ans.begin(), ans.end());
	for (char c : ans) printf("%c", c);
	printf("\n");
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'strlen' was not declared in this scope
   21 |         int n = strlen(s), m = strlen(t);
      |                 ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
a.cc:23:38: error: 'm' was not declared in this scope
   23 |                 for (int j = 1; j <= m; ++j) {
      |                                      ^
a.cc:28:25: error: 'm' was not declared in this scope
   28 |         constructAns(n, m);
      |                         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_S 3010

string S, T;

// 文字列 s と t の最長共通部分列(LCS)を求める
// O(2|s||t|)
string lcs(string s, string t) {
    // まず DP で長さを求める
    // S の [0, i] と、 T の [0, j] を使った時の LCS の長さ
    vector< vector<ll> > dp(s.length()+1, vector<ll>(t.length()+1, 0));
    for(int i = 1; i <= s.length(); ++i) {
        for(int j = 1; j <= t.length(); ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(S[i-1] == T[j-1]) { dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1); }
        }
    }
    // この時点で dp[s.length()][t.length()] に LCS の長さが入る
    // ここから経路復元
    string ret = "";
    int s_ind = s.length(), t_ind = t.length();
    while(ret.length() < dp[s.length()][t.length()]) {
        if(dp[s_ind][t_ind] == dp[s_ind-1][t_ind]) { s_ind--; }     // 同じならこの s_ind は使われていない
        else if(dp[s_ind][t_ind] == dp[s_ind][t_ind-1]) { t_ind--; }
        else {
            s_ind--;
            t_ind--;
            ret += S[s_ind];
        }
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

signed main()
{
    cin >> S >> T;
    REP(i, S.length()) { REP(j, T.length()) { dp[i][j] = ""; } }
    printf("%s\n", lcs(S, T).c_str());
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:47: error: 'dp' was not declared in this scope; did you mean 'dup'?
   52 |     REP(i, S.length()) { REP(j, T.length()) { dp[i][j] = ""; } }
      |                                               ^~
      |                                               dup
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int dp[3010][3010];

int main(){
  string s, t, ans="";
  cin >> s >> t;

  memset(dp, 0, sizeof(dp));
  for(int i=0;i<s.length();i++){
    for(int j=0;j<t.length();j++){
      if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1], dp[i][j]+1);
      dp[i+1][j+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]);
    }
  }
  int i=s.length(), j=t.length();
  while(i+j){
    int x=dp[i][j];
    if(i&&dp[i-1][j]==x)
      i--;
    else if(j&&dp[i][j-1]==x)
      j--;
    else {
      i--;
      j--;
      ans+=s[i];
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}


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

#include <iostream>
#include <string>
#include <stack>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INT_MAX 0x7FFFFFFF
#define LL_MAX 0x7FFFFFFFFFFFFFFF
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
using namespace std;
typedef long long int LL;
 
int main(){
  string S, T;
  getline(cin, S);
  getline(cin, T);
  int lS = S.size(), lT = T.size();
  int score[3005][3005] = {};
  REP(i, 3001) {
    score[0][i] = 0;
    score[i][0] = 0;
  }
  REP(i, lS) {
    REP(j, lT) {
      if(S[i] == T[j]) {
        score[i+1][j+1] = score[i][j] + 1;
      } else {
        score[i+1][j+1] = MAX(score[i+1][j], score[i][j+1]);
      }
    }
  }
  stack<char> ret;
  {
    int i = lS, j = lT;
    while(score[i][j] > 0) {
      if(score[i-1][j] == score[i][j]) {
        --i;
      } else if(score[i][j-1] == score[i][j]) {
        --j
      } else {
        ret.push(S[i-1]);
        --i; --j;
      }
    }
  }
  while(!ret.empty()) {
    cout << ret.top();
    ret.pop();
  }
  cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:12: error: expected ';' before '}' token
   39 |         --j
      |            ^
      |            ;
   40 |       } else {
      |       ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
#define MAX int(3010)
int dp[MAX][MAX];
oid solve() {
	var(string, s, t);
	int n = len(s), m = len(t);
	rep(i, 0, n) {
		rep(j, 0, m) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			} else {
				if (dp[i][j + 1] > dp[i + 1][j]) {
					dp[i + 1][j + 1] = dp[i][j + 1];
				} else {
					dp[i + 1][j + 1] = dp[i + 1][j];
				}
			}
		}
	}
	string ans = "";
	rrep(i, dp[n][m], 0) {
		while(dp[n - 1][m] == i) --n;
		while(dp[n][m - 1] == i) --m;
		ans += t[m - 1];
	}
	reverse(all(ans));
	print(ans);
}
int main() {
	solve();
	return 0;
}


Compiler output:
a.cc:45:1: error: 'oid' does not name a type; did you mean 'void'?
   45 | oid solve() {
      | ^~~
      | void
a.cc: In function 'int main()':
a.cc:71:9: error: 'solve' was not declared in this scope
   71 |         solve();
      |         ^~~~~
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 of " << X << " and " << Y << " is " << lcs; 
} 

/* Driver program to test above function */
int main() 
{ string s,t;
 cin >> s >> t;
 
int m = strlen(s); 
int n = strlen(t);
char X[m];
char Y[n];
for(int i=0; i<m; i++)
  X[i]=s[i];
 for(int i=0; i<n; i++)
   Y[i]=t[i];
 
lcs(X, Y, m, n); 
return 0; 
} 


Compiler output:
a.cc:32:14: error: empty character constant
   32 | lcs[index] = ''; // Set the terminating character
      |              ^~
a.cc: In function 'int main()':
a.cc:64:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   64 | int m = strlen(s);
      |                ^
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:3:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:65:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   65 | int n = strlen(t);
      |                ^
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
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 of " << X << " and " << Y << " is " << lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
string s;
  string t;
  cin >> s >> t;
int m = strlen(s); 
int n = strlen(t); 
lcs(s, t, m, n); 
return 0; 
} 


Compiler output:
a.cc:32:14: error: empty character constant
   32 | lcs[index] = ''; // Set the terminating character
      |              ^~
a.cc: In function 'int main()':
a.cc:65:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   65 | int m = strlen(s);
      |                ^
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:3:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:66:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   66 | int n = strlen(t);
      |                ^
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:67:5: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char*'
   67 | lcs(s, t, m, n);
      |     ^
      |     |
      |     std::string {aka std::__cxx11::basic_string<char>}
a.cc:8:17: note:   initializing argument 1 of 'void lcs(char*, char*, int, int)'
    8 | void lcs( char *X, char *Y, int m, int n )
      |           ~~~~~~^
Language: C++

#include<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]; 
   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<<endl; 
} 
  
/* Driver program to test above function */
int main() 
{ 
    string s,t;
    cin>>s>>t;
    int a=s.length(), b=t.length();
  char X[a];
  char Y[b];
  for(int i=0; i<a; i++){
    X[i]=s[i];
  }
  for(int i=0; i<b; i++){
    Y[i]=t[i];
  }
  int m = strlen(X); 
  int n = strlen(Y); 
  lcs(X, Y, m, n); 
  return 0; 
} 

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

#include<bits/stdc++.h>
using namespace std;
char ch1[3005],ch2[3002];
int dp[3005][3005],n,m,ara[3005][3005][2];

op(int i,int j)
{
    if(i>=n||j>=m)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(ch1[i]==ch2[j]){
        ara[i][j][0]=1;
        ara[i][j][1]=1;
        return dp[i][j]=op(i+1,j+1)+1;


    }
    else{
        int a=op(i+1,j);
        int b=op(i,j+1);

        if(a<b){
            ara[i][j][0]=0;
            ara[i][j][1]=1;
            return dp[i][j]=b;
        }
        else{
            ara[i][j][0]=1;
            ara[i][j][1]=0;
            return dp[i][j]=a;
        }
    }
}

int main()
{
    int i,j,k,a,b,c,x,y,z;
    scanf(" %s %s",ch1,ch2);
    n=strlen(ch1);
    m=strlen(ch2);
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++){
            dp[i][j]=-1;
        }
    }
    a=op(0,0);
    for(i=0,j=0;i<n&&j<m;)
    {
        if(ch1[i]==ch2[j]){
            printf("%c",ch1[i]);
        }
        //cout<<i<< "  " <<j<<endl;
        a=i+ara[i][j][0];
        b=j+ara[i][j][1];
        i=a;
        j=b;
       // cout<<i<< "   " <<j<<endl;
    }

    printf("\n");
    //cout<<a<<endl;

}


Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'op' with no type [-fpermissive]
    6 | op(int i,int j)
      | ^~
Language: C++

#include<bits/stdc++.h>

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  string s,s2;
  cin>>s>>s2;
  int ma=0;
  string dp[2][s2.size()+1]={};
  for(int i=0;i<s.size();i++){
    for(int j=ma;j<s2.size();j++){
      if(s[i]==s2[j]){
	dp[(i+1)%2][j+1]=dp[i%2][j]+s[i];
      }else{
	if(dp[i%2][j+1].size()>dp[(i+1)%2][j].size())
	  dp[(i+1)%2][j+1]=dp[i%2][j+1];
	else
	  dp[(i+1)%2][j+1]=dp[(i+1)%2][j];
      }
      ma=max(ma,(int)dp[(i+1)%2][j+1]);
    }
  }
  cout<<dp[s.size()%2][s2.size()]<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
   38 |       ma=max(ma,(int)dp[(i+1)%2][j+1]);
      |                 ^~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, i, j;
int m
char a[3005];
char b[3005];
int dp[3001][3001];

int main(){
    scanf("%s", a+1);
    scanf("%s", b+1);
    n = strlen(a+1);
    m = strlen(b+1);
    memset(dp, 0, sizeof dp);
    for(i=1;i<=n;++i){
        for(j=1;j<=m;++j){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(a[i] == b[j]){
                dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
            }
        }
    }
    printf("%d\n", dp[n][m]);
    return 0;
}







Compiler output:
a.cc:9:1: error: expected initializer before 'char'
    9 | char a[3005];
      | ^~~~
a.cc: In function 'int main()':
a.cc:14:17: error: 'a' was not declared in this scope
   14 |     scanf("%s", a+1);
      |                 ^
a.cc:17:5: error: 'm' was not declared in this scope; did you mean 'tm'?
   17 |     m = strlen(b+1);
      |     ^
      |     tm
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

string dp[2][3252];
// int dp2[2][3252];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin>>s>>t;
	int n=s.size(), m=t.size();
	REP(i, n){
		if(i&1){
			REP(j, m){
				if(s[i]==t[j]){
					dp[0][j+1]=dp[1][j]+s[i];
					// dp2[0][j+1]=dp2[1][j]+1;
				}
				else{
					if(dp[0][j].size()>dp2[1][j+1].size()){
						dp[0][j+1]=dp[0][j];
						// dp2[0][j+1]=dp2[0][j];
					}
					else{
						dp[0][j+1]=dp[1][j+1];
						// dp2[0][j+1]=dp2[1][j+1];
					}
				}
			}
		}
		else{
			REP(j, m){
				if(s[i]==t[j]){
					dp[1][j+1]=dp[0][j]+s[i];
					// dp2[1][j+1]=dp2[0][j]+1;
				}
				else{
					if(dp2[1][j].size()>dp2[0][j+1].size()){
						dp[1][j+1]=dp[1][j];
						// dp2[1][j+1]=dp2[1][j];
					}
					else{
						dp[1][j+1]=dp[0][j+1];
						// dp2[1][j+1]=dp2[0][j+1];
					}
				}
			}
		}
	}
	cout<<dp[n&1][m]<<'\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:60: error: 'dp2' was not declared in this scope; did you mean 'dup2'?
   48 |                                         if(dp[0][j].size()>dp2[1][j+1].size()){
      |                                                            ^~~
      |                                                            dup2
a.cc:66:44: error: 'dp2' was not declared in this scope; did you mean 'dup2'?
   66 |                                         if(dp2[1][j].size()>dp2[0][j+1].size()){
      |                                            ^~~
      |                                            dup2
Language: C

#include "bits/stdc++.h"

using namespace std;

void solve()
{
	string s, t;
	cin >> s >> t;
	int sl = s.size(), tl = t.size();
	int dp[sl+1][tl+1];
	memset(dp, 0, sizeof(dp));
	int ans = 0;
	for (int ti = 0; ti < tl; ti++) for (int si = 0; si < sl; si++)
	{
		dp[si+1][ti+1] = max({dp[si+1][ti+1], dp[si][ti+1], dp[si+1][ti], dp[si][ti]+(s[si]==t[ti])});
		ans = max(ans, dp[si+1][ti+1]);
	}

	cout << ans << endl;

	string go = "";

	for (int ti = tl-1; ti >= 0;) for (int si = sl-1; si >= 0;)
	{
		if (ans == 0)
		{
			reverse(go.begin(), go.end());
			cout << go << endl;
			return;
		}
		if (dp[si][ti]+1 == dp[si+1][ti+1] && ans == dp[si+1][ti+1])
		{
			go.push_back(s[si]);
			si--;
			ti--;
			ans--;
		}
		else if (dp[si+1][ti+1] == dp[si+1][ti]) ti--;
		else if (dp[si+1][ti+1] == dp[si][ti+1]) si--;
		else si--, ti--;
		//cout << si << ' ' << ti << ' ' << go << endl;
	}

}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	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++

/* 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
      |              ^~
Language: C++

#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}

int n,m,u,v;

int memo[110000];
bool fl[110000];
vector <int > eg(110000);
int dp(int v){
    if(fl[v]){
        return memo[v];
    }
    int ans = 0;
    for(int to:eg[v]){
        ans = max(ans, dp(to) + 1);
    }
    fl[v] = true;
    memo[v] = ans;
    return ans;
}
using namespace std;
int main(){
   

    cin >> n >> m;
    REP(i,n){
        cin >> u >> v;
        eg[u].push_back(v);
    }
    int ans = 0;
    FOR(i,1,n){
        ans = max(ans,dp(i));
    }

    cout <<ans <<endl;

}





Compiler output:
a.cc:62:1: error: 'vector' does not name a type
   62 | vector <int > eg(110000);
      | ^~~~~~
a.cc: In function 'int dp(int)':
a.cc:68:16: error: 'eg' was not declared in this scope
   68 |     for(int to:eg[v]){
      |                ^~
a.cc:69:15: error: 'max' was not declared in this scope; did you mean 'std::max'?
   69 |         ans = max(ans, dp(to) + 1);
      |               ^~~
      |               std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:82:9: error: 'eg' was not declared in this scope
   82 |         eg[u].push_back(v);
      |         ^~
Language: C++

//Using DFS
#include<bits/stdc++.h>
using namespace std;
int dp[100001];
int maxi = INT_MIN;
int dfs_helper(int src, int v,int e,list<int> *l,map<int,bool>&vis)
{
  vis[src]=true;
  list<int>::iterator it;

  for(it=l[src].begin();it!=l[src].end();++it)
  {
    if(!vis[*it])
      dfs_helper(*it,v,e,l,vis)
      
      dp[src] = max(dp[src],dp[*it]+1);
  }
  maxi = max(dp[src],maxi);
}
      
void dfs(int v,int e, list<int>* l)
{
  map<int,bool>vis;
  for(int i=1;i<=v;i++)
  {
    if(!vis[i])
      dfs_helper(i,v,e,l,vis);
  }
  cout<<maxi<<endl;
}
int main()
{
  int v,e;
  cin>>v>>e;
  list<int>l[v+1];
  while(e--)
  {
    int x,y;
    cin>>x>>y;
    l[x].push_back(y);
  }
  dfs(v,e,l);
}

Compiler output:
a.cc: In function 'int dfs_helper(int, int, int, std::__cxx11::list<int>*, std::map<int, bool>&)':
a.cc:14:32: error: expected ';' before 'dp'
   14 |       dfs_helper(*it,v,e,l,vis)
      |                                ^
      |                                ;
   15 | 
   16 |       dp[src] = max(dp[src],dp[*it]+1);
      |       ~~                        
a.cc:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
Language: C++

////=====BIsmiintahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comiinta University

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

const int maX=1e5+5;
vector<int>ara[maX];
int dp[maX];
int visit[maX];
int dfs(int x){
    if(visit[x])return dp[x];
    int ans=0;
    for(int i=0;i<ara[x].size();i++){
        ans=max(ans,1+dfs(ara[x][i]));
    }
    visit[x]=1;
    dp[x]=ans;
    return ans;
}

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        ara[x].push_back(y);
    }
    int mx=-1;
    for(int i=1;i<=n;i++){
        dfs(i);
        mx=max(dp[i],mx);
    }
    cout<<mx<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:21:8: error: reference to 'visit' is ambiguous
   21 |     if(visit[x])return dp[x];
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:13:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:19:5: note:                 'int visit [100005]'
   19 | int visit[maX];
      |     ^~~~~
a.cc:26:5: error: reference to 'visit' is ambiguous
   26 |     visit[x]=1;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:19:5: note:                 'int visit [100005]'
   19 | int visit[maX];
      |     ^~~~~