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

// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
#define END(ans) ANS(ans); return
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

vector<vector<ll>> g;
ll dp[INF];

ll rec(ll v) {
  if (dp[v] != -1)
    return dp[v];
  ll ans = 0;
  for (ll nv : g[v]) {
    chmax(ans, rec(nv) + 1);
  }
  return dp[v] = ans;
}

void solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y) {
  g.assign(N, vector<ll>());
  rep(i, M) {
    g[x[i] - 1].pb(y[i] - 1);
  }
  rep(i, N) dp[i] = -1;

  ll ans = 0;
  rep(i, N) chmax(ans, rec(i));
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> x(M);
  std::vector<long long> y(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
  solve(N, M, std::move(x), std::move(y));
  return 0;
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::vector<long long int>, std::allocator<std::vector<long long int> > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::vector<long long int>]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
#define END(ans) ANS(ans); return
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

vector<vector<ll>> G;
ll dp[INF];

ll rec(ll v) {
  if (dp[v] != -1)
    return dp[v];
  ll ans = 0;
  for (ll nv : G[v]) {
    chmax(ans, rec(nv) + 1);
  }
  return dp[v] = ans;
}

void solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y) {
  G.assign(N, vector<ll>());
  rep(i, M) {
    G[x[i] - 1].pb(y[i] - 1);
  }
  rep(i, N) dp[i] = -1;

  ll ans = 0;
  rep(i, N) chmax(ans, rec(i));
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> x(M);
  std::vector<long long> y(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
  solve(N, M, std::move(x), std::move(y));
  return 0;
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::vector<long long int>, std::allocator<std::vector<long long int> > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::vector<long long int>]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}
vector<vector<ll>> adj(MAXN);
vector<ll> vis(MAXN), indeg(MAXN), dist(MAXN, 0);
void addedge()
{
	ll a, b;
	cin >> a >> b;
	adj[a].pb(b);
	++indeg[b];
	// adj[b].pb(a);
}
vector<ll> ans;
void dfs(ll node)
{
	vis[node] = 1;
	for (auto child : adj[node])
	{
		dist[child] = max(dist[node] + 1, dist[child]);
		--indeg[child];
		if (indeg[child] == 0)
			dfs(child);
	}
}
signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n, m;
	cin >> n >> m;
	loop(i, m)	addedge();
	FOR(i, 1, n)
	{
		if (vis[i] == 0 && indeg[i] == 0)
		{
			dfs(i, 0);
		}
	}
	cout << *max_element(all(dist)) << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:95:28: error: too many arguments to function 'void dfs(ll)'
   95 |                         dfs(i, 0);
      |                         ~~~^~~~~~
a.cc:71:6: note: declared here
   71 | void dfs(ll node)
      |      ^~~
Language: Java

import java.math.*;
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
       String[] l1 = br.readLine().split(" ");
       int N = Integer.parseInt(l1[0]);
       int M = Integer.parseInt(l1[1]);
       HashMap<Integer, ArrayList<Integer>()> map = new HashMap<>();

        for(int i = 0; i < M; i++){
            String[] l2 = br.readLine().split(" ");
            int a = Integer.parseInt(l2[0]);
            int b = Integer.parseInt(l2[1]);

            if(!map.containsKey(a)){
                map.put(a, new ArrayList<Integer>());
            }

            map.get(a).add(b);

        }
        int[] dp = new int[M];
        Arrays.fill(dp, -1);
        int ans = 0;
        for(int i = 1; i <= N; i++){
            ans = Math.max(ans, helper(map, i, dp));
        }
        System.out.println(ans);
    }

    public static int helper(Map<Integer, ArrayList<Integer>()> map, int node, int[] dp){
        if(dp[node] != -1){
            return dp[node];
        }

        dp[node] = 0;
        int count = 0;

        if(map.containsKey(node)){
            for(int neigh: map.get(node)){
                count = Math.max(count, helper(map, neigh, dp) + 1);
            }
        }
        dp[node] = count;
        return dp[node];
    }

}

Compiler output:
Main.java:12: error: > or ',' expected
       HashMap<Integer, ArrayList<Integer>()> map = new HashMap<>();
                                          ^
Main.java:12: error: not a statement
       HashMap<Integer, ArrayList<Integer>()> map = new HashMap<>();
              ^
Main.java:35: error: > or ',' expected
    public static int helper(Map<Integer, ArrayList<Integer>()> map, int node, int[] dp){
                                                            ^
Main.java:35: error: <identifier> expected
    public static int helper(Map<Integer, ArrayList<Integer>()> map, int node, int[] dp){
                                                                              ^
Main.java:35: error: ';' expected
    public static int helper(Map<Integer, ArrayList<Integer>()> map, int node, int[] dp){
                                                                                       ^
5 errors
Language: Java

import java.math.*;
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
       String[] l1 = br.readLine().split(" ");
       int N = Integer.parseInt(l1[0]);
       int M = Integer.parseInt(l1[1]);
       HashMap<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>();

        for(int i = 0; i < M; i++){
            String[] l2 = br.readLine().split(" ");
            int a = Integer.parseInt(l2[0]);
            int b = Integer.parseInt(l2[1]);

            if(!map.containsKey(a)){
                map.put(a, new ArrayList<Integer>());
            }

            map.get(a).add(b);

        }
        int[] dp = new int[M];
        Arrays.fill(dp, -1);
        int ans = 0;
        for(int i = 1; i <= N; i++){
            ans = Math.max(ans, helper(map, i, dp));
        }
        System.out.println(ans);
    }

    public static int helper(Map<Integer, List<Integer>> map, int node, int[] dp){
        if(dp[node] != -1){
            return dp[node];
        }

        dp[node] = 0;
        int count = 0;

        if(map.containsKey(node)){
            for(int neigh: map.get(node)){
                count = Math.max(count, helper(map, neigh, dp) + 1);
            }
        }
        dp[node] = count;
        return dp[node];
    }

}

Compiler output:
Main.java:12: error: > or ',' expected
       HashMap<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>();
                                                                               ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll dp[100005];
vector<ll>v[100005];
ll dfs(ll u,ll p)
{
    if(dp[u]!=-1)
        return dp[u];
    ll l=0;
    for(int i=0;i<v[u].size();i++)
    {
        if(v[u][i]==p)
            continue;
        else
            l=max(l,1+dfs(v[u][i],u));
    }
    return (dp[u]=l);
}
int main()
{
    memset(dp,#,sizeof(dp));
    ll n,m;
    cin>>n>>m;
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        v[a].push_back(b);
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(dp[i]==-1)
            dfs(i,-1);
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc:22:15: error: stray '#' in program
   22 |     memset(dp,#,sizeof(dp));
      |               ^
a.cc: In function 'int main()':
a.cc:22:16: error: expected primary-expression before ',' token
   22 |     memset(dp,#,sizeof(dp));
      |                ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;


map<int, vector<int>> adjList;
bool isConnected[10005];
int dp[10005];
bool visited[10005];

int dfs(int idx) {
	visited[next] = true;
	if (dp[idx] != -1) {
		return dp[idx];
	}
	else {
		for (int i = 0; i < adjList[idx].size(); i++) {
			int next = adjList[idx][i];
			
			dp[idx] = max(dfs(next) + 1, dp[idx]);
		}
		return dp[idx];
	}
}

int main() {
	int n, m;
	cin >> n >> m;


	for (int i = 0; i <n; i++) {
		isConnected[i] = false;
		visited[i] = false;
		dp[i] = -1;
	}

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		adjList[x].push_back(y);
		isConnected[x] = true;
	}


	for (int i = 0; i < n; i++) {
		if (isConnected[i] == false) {
			dp[i] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		if (visited[i] == false) {
			visited[i] = true;
			dfs(i);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:15:16: error: invalid types 'bool [10005][<unresolved overloaded function type>]' for array subscript
   15 |         visited[next] = true;
      |                ^
Language: C++

// #include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>

using namespace std;
#define mod 1000000007
#define ll long long 


ll dp[100009];
int n, m;

vector<int> g[100009];

ll solve(int i) {
	if(dp[i] != -1)
		return dp[i];
	
	ll ans = 1;
	for(int j = 0; j < g[i].size(); j++) {
		int u = g[i][j];
		ans = max(ans, 1 + solve(u));
	}

	return dp[i] = ans;
}


int main() {
  	cin>>n>>m;
  	int x, y;
  	for(int i = 0; i < m; i++) {
  		cin>>x>>y;
  		g[x].push_back(y);
  	}

  	memset(dp, -1, sizeof(dp));
  	ll ma = INT_MIN;
  	for(int i = 1; i <= n; i++) {
  		ma = max(ma, solve(i));
  	}
  	cout<<ma - 1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: 'memset' was not declared in this scope
   40 |         memset(dp, -1, sizeof(dp));
      |         ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include<map>
  +++ |+#include <cstring>
    7 | 
a.cc:41:17: error: 'INT_MIN' was not declared in this scope
   41 |         ll ma = INT_MIN;
      |                 ^~~~~~~
a.cc:7:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<map>
  +++ |+#include <climits>
    7 |
Language: C++

#include<iostream>
#include<vector>
using namespace std;
vector<int> graph[100001];
int dp[100001];

int solve(int src){
    if(dp[src]!=-1){
        return dp[src];
    }

    bool leaf = true;
    int bestChild = 0;
    for(int c: graph[src]){
        leaf = 0;
        bestChild = max(bestChild,solve(c));
    }
    return dp[src] = leaf ? 0 : 1 + bestChild;
}

int main() 
{
    int n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;i++){
        int s,e;
        cin>>s>>e;
        graph[s].push_back(e);
    }
    int ans = 0;
    for(int i=1;i<=m;i++){
        ans = max(ans,solve(i));
    }
    cout<<ans;
    return 0;
}


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

from sys import stdin,stdout
from queue import Queue

inp = stdin.readline
out = stdout.write

n,m = map(int,inp().split())
adj = [[] for _ in range(n+1)]

for i in range(m):
    u,v = map(int,inp().split())
    adj[u].append(v)

dp = [-1 for i in range(n+1)]

def dfs(u):
    if dp[u] != -1: return dp[u]
    if adj[u] == []: return 1
    for i in adj[u]: dp[u] = max(dp[u],dfs(i)+1)
    return dp[u]

ans = 0

for u in range(1,n+1): 
    ans = max(ans,dfs(u))

out(str(ans-1))

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from sys import stdin,stdout
      | ^~~~
Language: C++

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> dp(100001,-1);
vector<vector<int>> graph(n+1,vector<int> (0));
int dfs(int source){

    if(dp[source]!=-1)
    return dp[source];
if(graph[source].size()==0)
return dp[source]=0;
int maxr =0;
    
    for(auto child:graph[source]){
        
       
           maxr = max(maxr,1+dfs(child));
      
      
    }

dp[source] = maxr;
return dp[source];
}
int main()
{
	//sb();
    int n,m;
    cin>>n>>m;
    
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        graph[u].pb(v);
    }
    int ans =0;
   for(int i=1;i<n+1;i++){
   
   ans = max(ans,dfs(i));
   
   }
    cout<<ans;




return 0;
}



Compiler output:
a.cc:38:27: error: 'n' was not declared in this scope; did you mean 'yn'?
   38 | vector<vector<int>> graph(n+1,vector<int> (0));
      |                           ^
      |                           yn
Language: C++

#include <iostream>
#include <vector>
using namespace std;
template<class T>inline bool chmax(T& a,T b){
 if(a<b){a=b; return true;} return false;
}

int N,M;
vector<vector<int>> G;

int dp[100100];
int rec(inv v){
	if(dp[v]!=-1)return dp[v];//already updated
	int res=0;
	for (auto nv:G[v]){
		chmax(res,rec(nv)+1);
	}
	return dp[v]=res;//memo and return
}

int main(){
	cin>>N>>M;
	G.assign(N,vector<int>());
	for (int i=0;i<M;++i){
		int x,y;cin>>x>>y;
		--x,--y;//0-index
		G[x].push_back(y);
	}

	for (int v=0;v<N;++v)dp[v]=-1;

	int res=0;
	for(int v=0;v<N;++v)chmax(res,rec(v));
	cout<<res<<endl;
}

Compiler output:
a.cc:12:9: error: 'inv' was not declared in this scope; did you mean 'int'?
   12 | int rec(inv v){
      |         ^~~
      |         int
a.cc: In function 'int main()':
a.cc:33:42: error: 'rec' cannot be used as a function
   33 |         for(int v=0;v<N;++v)chmax(res,rec(v));
      |                                       ~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[100001];
memset(dp,-1,sizeof dp);
 vector<int> adj[100001];

int solve(int src)
{
    if(dp[src]!=-1) return dp[src];
      
     bool leaf=1;
     int bestchild=0;
     for(auto child:adj[src])
     {
         leaf=0;
         bestchild=max(bestchild,solve(child));
     }
     return dp[src]=leaf?0:1+bestchild;
}
int main()
{
   
        int n,m;
        cin>>n>>m;
        int ans=-1;
       
        for(int i=0;i<m;i++)
        {
            int u,v;
            cin>>u>>v;
            adj[u].push_back(v);
        }
        for(int i=1;i<=n;i++)
        {
            ans=max(ans,solve(i));
        }

        cout<<ans<<endl;


  
}



Compiler output:
a.cc:4:7: error: expected constructor, destructor, or type conversion before '(' token
    4 | memset(dp,-1,sizeof dp);
      |       ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class G {
    public static int[] dp;
    public static ArrayList<Integer>[] graph;
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] lo = reader.readLine().split(" ");
        int N =Integer.parseInt(lo[0]);
        int M =Integer.parseInt(lo[1]);
        graph = new ArrayList[N+1];
        dp = new int[N+1];
        for (int i = 0; i <=N ; i++) {
            dp[i]=-1;
            graph[i]=new ArrayList<>();
        }
        for (int i = 0; i <M ; i++) {
            String[] xy = reader.readLine().split(" ");
            int x = Integer.parseInt(xy[0]);
            int y = Integer.parseInt(xy[1]);
            graph[x].add(y);
        }
        int res =0;
        for (int i = 1; i <=N ; i++) {
            res=Math.max(res,dfs(i));
        }
        System.out.println(res);
    }
    public static int dfs(int a){
        if(dp[a]!=-1) return dp[a];
        int temp = 0;
        for(int y:graph[a]){
            temp = Math.max(temp,1+dfs(y));
        }
        dp[a] = temp;
        return temp;
    }
}


Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Language: C++

# include <bits/stdc++.h>

using namespace std;

bool visited[100002];
int dp[100002];

bool graph[100002][100002];

int N, M , x, y;

int solve(int i){
    if (visited[i]) return dp[i];
    int longest = 0;
    for(int j=1; j<=N; j++){
        if (graph[i][j]==true){
            if (visited[j]==true){
                if (longest < dp[j] + 1) longest = dp[j];
            }else{
                int candid = solve(j);
                if (longest < candid + 1) longest = candid + 1;
            }
        }
    }
    dp[i] = longest;
    return longest;
}


int main(){
    cin >> N >> M;
    for(int i=1; i<=M; i++){
        cin >> x >> y;
        graph[x][y] = true;
    }

    int longest = 0, candid;
    for(int i=1; i<=N; i++){
        int candid = solve(i);
        // cout << "i = " << i << ": candid = " << candid << endl;
        if (candid > longest) longest = candid;
    }
    cout << longest << endl;
    return 0;
}

Compiler output:
/tmp/ccfbo44o.o: in function `solve(int)':
a.cc:(.text+0xec): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccfbo44o.o
/tmp/ccfbo44o.o: in function `main':
a.cc:(.text+0x123): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccfbo44o.o
a.cc:(.text+0x13f): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccfbo44o.o
a.cc:(.text+0x15a): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccfbo44o.o
a.cc:(.text+0x176): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/ccfbo44o.o
a.cc:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccfbo44o.o
a.cc:(.text+0x18d): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/ccfbo44o.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccfbo44o.o
a.cc:(.text+0x1ed): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccfbo44o.o
collect2: error: ld returned 1 exit status
Language: Java

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

class Main
{
	int V;
	ArrayList<Integer> adj[];
    longest_path(int V)
    {
        this.V = V;
        adj = new ArrayList[V];
        for(int i = 0; i < V; i++)
        {
            adj[i] = new ArrayList<>();
        }
    }
    void addEdge(int p1, int p2)
    {
        adj[p1].add(p2);
    }
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int e = sc.nextInt();
	    longest_path g1 = new longest_path(n);
	    for(int i = 0; i < e; i++)
	    {
	    	int a = sc.nextInt();
	    	int b = sc.nextInt();
	    	g1.addEdge(a-1, b-1);
	    }
	    boolean[] vis = new boolean[n];
	    int[] dp = new int[n];
	    for(int i = 0; i < n; i++)
	    {
	    	dp[i] = 0;
	    	vis[i] = false;
	    }
	    int res = 0;
	    for(int i = 0; i < n; i++)
	    {
	    	if(!vis[i])
	    	{
	    		res = Math.max(res, g1.dfs(i, dp, vis));
	    	}	
	    }
		System.out.println(res);
	}
	int dfs(int v, int[] dp, boolean[] vis)
    {
    	int ans = 0;
    	vis[v] = true;
    	Iterator<Integer> itr = adj[v].iterator();
        while(itr.hasNext())
        {
        	int i = itr.next();
        	if(!vis[i])
        	{
        		ans = Math.max(ans, dfs(i, dp, vis));
        	}	
        	else
        	{
        		ans = Math.max(ans, dp[i]);
        	}  
        }
        if(adj[v].size() == 0)
        {
        	dp[v] = ans;
        }
        else
        {
        	dp[v] = ans + 1;
        }
        return dp[v];
    }
}

Compiler output:
Main.java:8: error: invalid method declaration; return type required
    longest_path(int V)
    ^
1 error
Language: C++

#include<bits/stdc++.h>
#define ll long long int 
#define N 1e6 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef unsigned long long int  uint64;
int dP[100005]= {0};
bool vis[100005] = {false};
vector<vector<int>> gV(100005+1);
void dfs(int i)
{
 
if(vis[i] == true)
{
	return;
}
 
	vis[i] = true;
	FOR(j, 0, gV[i].size(), 1){
		int nei = gV[i][j];
		
		if(!vis[nei]){
			dfs(gV,nei);
		}
		dP[i] = max(dP[i], dP[nei]+1);
}
}
 
int main(){
  
    	ios_base::sync_with_stdio(false); cin.tie(0);
 
    	int n, m;
    	cin>> n>> m;
    	vector<int> dP(n+1, 0);
    	vector<bool> vis(n+1, false);
    	FOR(i, 0, m, 1){
    		int x, y;
    		cin>> x>> y;
    		gV[x].PB(y);
    	}
    	
    	FOR(i, 1, n+1, 1){
    		if(!vis[i]){
    			dfs(i);
 
    		}
    	}
    	int max = INT_MIN;
 
    	FOR(i, 1, n+1, 1){
    		if(dP[i]> max)
        {
    			max = dP[i];
    		}
    		
    	}
    	cout<< max<< endl;
 
    		}
    	


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:58:29: error: cannot convert 'std::vector<std::vector<int> >' to 'int'
   58 |                         dfs(gV,nei);
      |                             ^~
      |                             |
      |                             std::vector<std::vector<int> >
a.cc:45:14: note:   initializing argument 1 of 'void dfs(int)'
   45 | void dfs(int i)
      |          ~~~~^
Language: C++

#include<bits/stdc++.h>
#define ll long long int 
#define N 1e6 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef unsigned long long int  uint64;
int dP[100005]= {0};
bool vis[100005] = {false
vector<vector<int>> gV(100005+1);
void dfs(int i)
{
 
if(vis[i] == true)
{
	return;
}
 
	vis[i] = true;
	FOR(j, 0, gV[i].size(), 1){
		int nei = gV[i][j];
		
		if(!vis[nei]){
			dfs(gV,nei);
		}
		dP[i] = max(dP[i], dP[nei]+1);
}
}
 
int main(){
  
    	ios_base::sync_with_stdio(false); cin.tie(0);
 
    	int n, m;
    	cin>> n>> m;
    	vector<int> dP(n+1, 0);
    	vector<bool> vis(n+1, false);
    	FOR(i, 0, m, 1){
    		int x, y;
    		cin>> x>> y;
    		gV[x].PB(y);
    	}
    	
    	FOR(i, 1, n+1, 1){
    		if(!vis[i]){
    			dfs(i);
 
    		}
    	}
    	int max = INT_MIN;
 
    	FOR(i, 1, n+1, 1){
    		if(dP[i]> max)
        {
    			max = dP[i];
    		}
    		
    	}
    	cout<< max<< endl;
 
    		}
    	


Compiler output:
a.cc:44:1: error: expected '}' before 'vector'
   44 | vector<vector<int>> gV(100005+1);
      | ^~~~~~
a.cc:43:20: note: to match this '{'
   43 | bool vis[100005] = {false
      |                    ^
a.cc:44:1: error: expected ',' or ';' before 'vector'
   44 | vector<vector<int>> gV(100005+1);
      | ^~~~~~
a.cc: In function 'void dfs(int)':
a.cc:54:19: error: 'gV' was not declared in this scope
   54 |         FOR(j, 0, gV[i].size(), 1){
      |                   ^~
a.cc:15:43: note: in definition of macro 'FOR'
   15 | #define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
      |                                           ^
a.cc: In function 'int main()':
a.cc:75:17: error: 'gV' was not declared in this scope
   75 |                 gV[x].PB(y);
      |                 ^~
Language: Java

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

class Main
{
	int V;
	ArrayList<Integer> adj[];
    longest_path(int V)
    {
        this.V = V;
        adj = new ArrayList[V];
        for(int i = 0; i < V; i++)
        {
            adj[i] = new ArrayList<>();
        }
    }
    void addEdge(int p1, int p2)
    {
        adj[p1].add(p2);
    }
    static int max;
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int e = sc.nextInt();
	    longest_path g1 = new longest_path(n);
	    for(int i = 0; i < e; i++)
	    {
	    	int a = sc.nextInt();
	    	int b = sc.nextInt();
	    	g1.addEdge(a-1, b-1);
	    }
	    max = 0;
	    int res = 0;
	    boolean[] vis = new boolean[n];
	    for(int i = 0; i < n; i++)
	    {
	    	g1.fun(i, n, vis, 0);
	    	//System.out.println(max);
	    	res = Math.max(res, max);
	    }
		System.out.println(res);
	}
	void fun(int v, int n, boolean[] vis, int count)
    {
    	vis[v] = true;
    	Iterator<Integer> itr = adj[v].iterator();
        while(itr.hasNext())
        {
        	int i = itr.next();
        	count = count+1;
        	if(!vis[i])
        		fun(i, n, vis, count);
        	count = count - 1;  
        }
        if(count > max)
        {
        	max = count;
        }
        //count = count-1;
        vis[v] = false; 
    }
}

Compiler output:
Main.java:8: error: invalid method declaration; return type required
    longest_path(int V)
    ^
1 error
Language: C++

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

void chmax(int&a, int b) {
  if (a < b) a = b;
}


// メモ化再帰
int rec(int v) {
  if (dp[v] != -1) return dp[v];
  
  int res = 0;
  for (auto nv : G[v]) {
    chmax(res, rec(nv) + 1);
  }
  return dp[v] = res; //dp[v] を res にしてリターン
}

int main() {
  int N, M;
  cin >> N >> M;
 
  vector<vector<int>> G;
  int dp[100000];
  
  G.assign(N,vector<int>()); // GのN個分の要素として，空っぽのvector<int>を作る
  for (int i = 0; i < M; i++) {
    int x, y; cin >> x >> y;
    x--, y--; // 0-indexed
    G[x].push_back(y);
  }
  
  // dp の初期化
  for (int v = 0; v < N; v++) dp[v] = -1; 
  
  int ans = 0;
  for (int v = 0; v < N; v++) chmax(ans, rec(v));
  cout << ans << endl;

}

Compiler output:
a.cc: In function 'int rec(int)':
a.cc:11:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |   if (dp[v] != -1) return dp[v];
      |       ^~
      |       dup
a.cc:14:18: error: 'G' was not declared in this scope
   14 |   for (auto nv : G[v]) {
      |                  ^
a.cc:17:10: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |   return dp[v] = res; //dp[v] を res にしてリターン
      |          ^~
      |          dup
Language: C++

#include<bits/stdc++.h>

using namespace std;

int dfs(int x,vvi& graph,vi& dp){
    
    if(dp[x]!=-1) return dp[x];
    
    int count=0;
    for(int e:graph[x]){
        count=max(count,dfs(e,graph,dp)+1);
    }
    return dp[x]=count;
}

void longestpath(){
    int n,m,a,b;
    cin>>n>>m;
    vector<vector<int>> graph(n+1,vector<int>());
    while(m--){
        cin>>a>>b;
        graph[a].push_back(b);
    }
    vi dp(n+1,-1);
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dfs(i,graph,dp));
    }
    cout<<ans;
}

int main(){
  longestpath();
}

Compiler output:
a.cc:5:15: error: 'vvi' has not been declared
    5 | int dfs(int x,vvi& graph,vi& dp){
      |               ^~~
a.cc:5:26: error: 'vi' has not been declared
    5 | int dfs(int x,vvi& graph,vi& dp){
      |                          ^~
a.cc: In function 'int dfs(int, int&, int&)':
a.cc:7:10: error: invalid types 'int[int]' for array subscript
    7 |     if(dp[x]!=-1) return dp[x];
      |          ^
a.cc:7:28: error: invalid types 'int[int]' for array subscript
    7 |     if(dp[x]!=-1) return dp[x];
      |                            ^
a.cc:10:20: error: invalid types 'int[int]' for array subscript
   10 |     for(int e:graph[x]){
      |                    ^
a.cc:13:14: error: invalid types 'int[int]' for array subscript
   13 |     return dp[x]=count;
      |              ^
a.cc: In function 'void longestpath()':
a.cc:24:5: error: 'vi' was not declared in this scope
   24 |     vi dp(n+1,-1);
      |     ^~
a.cc:27:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   27 |         ans=max(ans,dfs(i,graph,dp));
      |                                 ^~
      |                                 dup
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 1000007;
vector<int> e[N];

int memo[N];

int solve(int u) {
	int & st = memo[u];
    if(st == -1) {
      	st = 1;
		for(int v : e[u]) {
          	st = max(st, 1 + solve(v));
        }
    }
  	return st;
}

int main() {
  	memset(memo, -1, sizeof memo);
  	ios::sync_with_stdio(0); cin.tie(0);
 	int n, m; cin >> n >> m;
  
  	for(int i = 0; i < m; ++i) {
     	int u, v; cin >> u >> v;
      	e[u].pb(v);
    }
  
  	int ans = 0;
  	for(int i = 1; i <= n; ++i) ans = max(ans, solve(i));
  	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:14: error: 'class std::vector<int>' has no member named 'pb'
   29 |         e[u].pb(v);
      |              ^~
Language: C++

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

#include<algorithm>
#define str(a) to_string(a)
#define int long long
#define pb push_back
#define N 1000001

vector<int> adj[N];
unordered_map<int, int> outdegree;
vector<int> dp;

int LongestPath(int source) {
	if (outdegree[source] == 0) {
		return dp[source] = 0;
	}
	if (dp[source] != -1)
		return dp[source];
	int mx = INT_MIN;
	for (int neighbor : adj[source]) {
		mx = max(mx, LongestPath(neighbor));
	}
	dp[source] = 1 + mx;
	return dp[source];
}

int32_t main()
{
// 	ios_base::sync_with_stdio(0);
// 	cin.tie(0);
// 	cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int n, m; cin >> n >> m;
	dp.assign(n + 1, -1);

	while (m--) {
		int x, y; cin >> x >> y;
		adj[x].pb(y);		// Directed acyclic graph
		outdegree[x]++;
	}

	for (int i = 1; i <= n; i++) {
		if (outdegree.find(i) == outdegree.end())
			outdegree[i] = 0;
	}

	int ans = INT_MIN;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, LongestPath(i));
	}
	cout << ans << endl;


}









Compiler output:
a.cc: In function 'long long int LongestPath(long long int)':
a.cc:22:18: error: 'INT_MIN' was not declared in this scope
   22 |         int mx = INT_MIN;
      |                  ^~~~~~~
a.cc:7:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<algorithm>
  +++ |+#include <climits>
    7 | #define str(a) to_string(a)
a.cc: In function 'int32_t main()':
a.cc:53:19: error: 'INT_MIN' was not declared in this scope
   53 |         int ans = INT_MIN;
      |                   ^~~~~~~
a.cc:53:19: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

// C++ program to find the longest 
// path in the DAG 

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

// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	// Mark as visited 
	vis[node] = true; 

	// Traverse for all its children 
	for (int i = 0; i < adj[node].size(); i++) { 

		// If not visited 
		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		// Store the max of the paths 
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	} 
} 

// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
	// Dp array 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 

	// Visited array to know if the node 
	// has been visited previously or not 
	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	// Call DFS for every unvisited vertex 
	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	// Traverse and find the maximum of all dp[i] 
	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 

// Driver Code 
int main() 
{   int n,m,x,y;
	cin>>n>>m
	vector<int> adj[n + 1]; 

	for(int i=1;i<=m;++i)
    	{	cin>>x>>y;addEdge(adj, x, y); 
	}
	
	cout << findLongestPath(adj, n); 
	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:63:18: error: expected ';' before 'vector'
   63 |         cin>>n>>m
      |                  ^
      |                  ;
   64 |         vector<int> adj[n + 1];
      |         ~~~~~~    
a.cc:67:35: error: 'adj' was not declared in this scope
   67 |         {       cin>>x>>y;addEdge(adj, x, y);
      |                                   ^~~
a.cc:70:33: error: 'adj' was not declared in this scope
   70 |         cout << findLongestPath(adj, n);
      |                                 ^~~
Language: C++

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

void helper(vector<vector<int>> &graph,vector<int> &dp,bool &check,int node)
{
    check[node]=true;
    for(int i=0;i<graph[node].size();i++)
    {
        if(!check[graph[node][i]])
          helper(graph,dp,check,graph[node][i]);

        dp[node]=max(dp[node],1+dp[graph[node][i]]);         
    }
}
int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> graph(n+1);
    bool check[n+1];
    vector<int> dp(n+1,-1);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
    }
    for(int i=1;i<=n;i++)
     helper(graph,dp,check,i);

     int gmax=0;
    for(int i:dp)
     gmax=max(gmax,i); 
    cout<<gmax;
 return 0;
}


Compiler output:
a.cc: In function 'void helper(std::vector<std::vector<int> >&, std::vector<int>&, bool&, int)':
a.cc:7:10: error: invalid types 'bool[int]' for array subscript
    7 |     check[node]=true;
      |          ^
a.cc:10:18: error: invalid types 'bool[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   10 |         if(!check[graph[node][i]])
      |                  ^
a.cc: In function 'int main()':
a.cc:29:22: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'bool*'
   29 |      helper(graph,dp,check,i);
      |                      ^~~~~
a.cc:5:62: note:   initializing argument 3 of 'void helper(std::vector<std::vector<int> >&, std::vector<int>&, bool&, int)'
    5 | void helper(vector<vector<int>> &graph,vector<int> &dp,bool &check,int node)
      |                                                        ~~~~~~^~~~~
Language: C++

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

int main(int argc, char* argv[]) {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g (n);
	vector<vector<int>> dp (n, vector<int> (n));
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		g[x-1].push_back(y-1);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		queue<int> q;
		q.push(i);
		while (q.size()) {
			int s = q.front();
			q.pop();
			for (auto x:g[s]) {
				q.push(x);
				dp[i][x] = max(dp[i][x], dp[i][s]+1);
				ans = max(ans, dp[i][x]);
			}
		}
	}
	cout << ans << endl;2
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:29:30: error: expected ';' before 'return'
   29 |         cout << ans << endl;2
      |                              ^
      |                              ;
   30 |         return 0;
      |         ~~~~~~
Language: C++

#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

vector<set<uint64_t>> edge;
vector<int64_t> dp;
// dp[i]; ノードiを始点とした有向パスの最大長

int64_t dfs(uint64_t src) {
  if (dp[src] > 0) { return dp[src]; }

  for (uint64_t dst : edge[src]) {
    dp[src] = max(dp[src], dfs(dst) + 1);
  }

  return dp[src];
}

int main()
{
  uint64_t N, M;
  cin >> N >> M;

  edge = vector<set<uint64_t>>(N);
  N_TIMES(m, M) {
    uint64_t x, y;
    cin >> x >> y;

    edge[x - 1].insert(y - 1);
  }

  dp = vector<int64_t>(N, 0);

  N_TIMES(i, N) {
    if (dp[i] == 0) {
      dp[i] = dfs(i);
    }
  }
  debug(dp);

  cout << *max_element(dp.begin(), dp.end()) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:3: error: 'debug' was not declared in this scope
   58 |   debug(dp);
      |   ^~~~~
Language: C++


//longest path in a directed graph
#include<bits/stdc++.h>
using namespace std;
int dp[100001];  //dp[i]= len of longest path starting at node i;

vector<int>Graph[100001];
int solve(int src)
{
    if(dp[src]!=-1)
    return dp[src];
    
    int bestchild=0;
     bool leaf=1;
     for(int child:Graph[src])  //O(M)
     {
         leaf=0;
         bestchild=max(bestchild,solve(child));
     }
     return dp[src]=leaf?0:1+bestchild;



}





int main()
{
    int n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof dp);
  
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        Graph[u].push_back(v);
    }
    int ans=0;((
    for(int i=1;i<=n;i++)   //O(N)
    ans=max(ans,solve(i));
    cout<<ans;
    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:5: error: expected primary-expression before 'for'
   43 |     for(int i=1;i<=n;i++)   //O(N)
      |     ^~~
a.cc:42:17: error: expected ')' before 'for'
   42 |     int ans=0;((
      |                ~^
      |                 )
   43 |     for(int i=1;i<=n;i++)   //O(N)
      |     ~~~          
a.cc:43:16: error: expected ')' before ';' token
   43 |     for(int i=1;i<=n;i++)   //O(N)
      |                ^
      |                )
a.cc:42:15: note: to match this '('
   42 |     int ans=0;((
      |               ^
a.cc:43:17: error: 'i' was not declared in this scope
   43 |     for(int i=1;i<=n;i++)   //O(N)
      |                 ^
Language: C++

/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,L,R) for(auto i=R-1;i>=L;i--)
#define show(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

vi graph[100001];
int ans[100001];
vi vis(100001,0);

int main() 
{
    int n,m,a,b;
    cin>>n>>m;
    F(i,0,m)
    {
        cin>>a>>b;
        a--;b--;
        graph[a].PB(b);
    }
	int ans=0;
    vi level(n,0);
	F(i,0,n)
	{
	    if(vis[i]==1)
	        continue;
	     
	    queue<int> q;
	    q.push(i);
	    while(!q.empty())
	    {
	        int s = q.front();
	        vis[s]=1;
	        q.pop();
	        for(auto it=graph[s].begin();it!=graph[s].end();it++)
	        {
	            if(level[*it]<level[s]+1)
	            {
	                level[*it] = level[s] + 1;
	                q.push(*it);
	            }
	        }
	    }
	//    ans = max(ans, ));
	}
	cout<<(*max_element(level.begin(),level.end())<<"\n";
}




Compiler output:
a.cc: In function 'int main()':
a.cc:61:55: error: invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
   61 |         cout<<(*max_element(level.begin(),level.end())<<"\n";
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
      |                |                                        |
      |                int                                      const char [2]
a.cc:61:61: error: expected ')' before ';' token
   61 |         cout<<(*max_element(level.begin(),level.end())<<"\n";
      |               ~                                             ^
      |                                                             )