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

#include<stdio.h>
int main(void)
{
	int i, j, count = 0,;
	long int a[100000], b[100000],n;

	scanf("%ld", &n);

	for (i = 0; i < n; i++)
		scanf("%ld %ld", &a[i], &b[i]);

	i = n - 1;
	while (i >= 0) {
		if (a[i] % b[i] == 0) {
			i--;
		}
		else {
			for (j = 0; j <= i; j++) {
				if (i == j)count++;
				a[j]++;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:29: error: expected identifier or '(' before ';' token
    4 |         int i, j, count = 0,;
      |                             ^
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    int i,tmp;
    long ans=0l;
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int[] b=new int[n];
    for(i=0;i<n;i++){
      a[i]=sc.nextInt();
      b[i]=sc.nextInt();
    }
    for(i=n-1;i>=0;i--){
      tmp=(a[i]+ans)%b[i];
      if(tmp!=0)ans+=(long)(b[i]-tmp);
    }
    System.out.println(ans);
  }
}


Compiler output:
Main.java:15: error: incompatible types: possible lossy conversion from long to int
      tmp=(a[i]+ans)%b[i];
                    ^
1 error
Language: C++

#pragma GCC optimize ("O3");
#include <cstdlib>
#include <iostream>
#include <valarray>


long long div_ceil(long long a, long long b) {
	return (a + b - 1) / b;
}


int main(){
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	int n;
	std::cin >> n;
	std::valarray<long long> xs(n);
	std::valarray<long long> ys(n);
	for (int i = 0; i < n; i++)
	{
		std::cin >> xs[i] >> ys[i];
	}
	long long ctr = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		auto diff = div_ceil(xs[i], ys[i]) * ys[i] - xs[i];
		ctr += diff;
		std::slice_array<long long> res = xs[std::slice(0, i + 1, 1)];
		res += std::valarray<long long>(diff, i + 1);
	}
	std::cout << ctr << std::endl;
	return EXIT_SUCCESS;
}

Compiler output:
a.cc:1:28: error: '#pragma GCC optimize' string is badly formed
    1 | #pragma GCC optimize ("O3");
      |                            ^
Language: C

#include <stdio.h>

int main(){

     int i, n;

     scanf("%d", &n);

     int buttonA[n];
     int buttonB[n];

     for(i = 0; i < n; i++){
          int a, b;
          scanf("%d %d", &a, &b);
          buttonA[i] = a;
          buttonB[i] = b;
     }

     int counter = 0;

     for(i = n - 1; i >= 0; i--){

          int remaining = buttonA[i] % buttonB[i]; 

          if(remaining > 0){
               int diff = buttonB[i] - remaining;
               if(diff > 0){
                    counter += diff;
                    int j;
                    for(j = i - 1; j >= 0; j--)
                         buttonA[j] += diff;
               }

          }
     }

     return counter
}


Compiler output:
main.c: In function 'main':
main.c:37:20: error: expected ';' before '}' token
   37 |      return counter
      |                    ^
      |                    ;
   38 | }
      | ~
Language: C++

#include <stdio.h>
#include <math.h>
void main(){
 
     int i, n;
 
     scanf("%d", &n);
 
     int buttonA[n];
     int buttonB[n];
 
     for(i = 0; i < n; i++){
          int a, b;
          scanf("%d %d", &a, &b);
          buttonA[i] = a;
          buttonB[i] = b;
     }
 
     int counter = 0;
 
     for(i = n - 1; i >= 0; i--){
 
          int remaining = buttonA[i] % buttonB[i]; 
 
          if(remaining > 0){
               int diff = buttonB[i] - remaining;
               if(diff > 0){
                    counter += diff;
                    int j;
                    for(j = i - 1; j >= 0; j--)
                         buttonA[j] += diff;
               }
 
          }
     }
 
     printf("%d", counter);
}

Compiler output:
a.cc:3:1: error: '::main' must return 'int'
    3 | void main(){
      | ^~~~
Language: C++

#include <stdio.h>

void main(){

     int i, n;

     scanf("%d", &n);

     int buttonA[n];
     int buttonB[n];

     for(i = 0; i < n; i++){
          int a, b;
          scanf("%d %d", &a, &b);
          buttonA[i] = a;
          buttonB[i] = b;
     }

     int counter = 0;

     for(i = n - 1; i >= 0; i--){

          int remaining = buttonA[i] % buttonB[i]; 

          if(remaining > 0){
               int diff = buttonB[i] - remaining;
               if(diff > 0){
                    counter += diff;
                    int j;
                    for(j = i - 1; j >= 0; j--)
                         buttonA[j] += diff;
               }

          }
     }

     printf("%d", counter);
}

Compiler output:
a.cc:3:1: error: '::main' must return 'int'
    3 | void main(){
      | ^~~~
Language: C++

#include<iostream>
#include<cctype>
#include<vector>
#include<ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include<math.h>
#include<iomanip>
using namespace std;
long long n, m; vector<long long> a;
int main() {
	cin >> n;
	for (size_t i = 0; i < n + 1; i++)
	{
		a.push_back(0);
	}
	for (size_t i = 2; i < n+1; i++)
	{
		cin >> m;
		a[m]++;
		a[i]++;
		a[m] = max(a[m], a[i]);
		a[i] = max(a[m], a[i]);

	}
	sort(a.begin(), a.end());
	cout << *(a.end()-1)<<endl;
	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:29:18: error: expected '}' at end of input
   29 |         return 0;
      |                  ^
a.cc:12:12: note: to match this '{'
   12 | int main() {
      |            ^
Language: C++

#include<iostream>

using namespace std;
#define int __int64

signed main(){

   int N;
   cin>> N;
   int a[N], b[N];
   for(int i=0; i<N; i++){
      cin>> a[i]>> b[i];
   }

   int s=0, t=0;
   for(int i=N-1; i>=0; i--){
      if(a[i]+s<=b[i]){
         s+=b[i]-(a[i]+s);
      }else{
         if(b[i]==1){

         }else if((a[i]+s)%b[i]==0){

         }else{
            s+=b[i]-((a[i]+s)%b[i]);
         }
      }
   }

   cout<< s<< endl;

   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:13: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
    4 | #define int __int64
      |             ^~~~~~~
a.cc:8:4: note: in expansion of macro 'int'
    8 |    int N;
      |    ^~~
a.cc:9:10: error: 'N' was not declared in this scope
    9 |    cin>> N;
      |          ^
a.cc:10:8: error: expected ';' before 'a'
   10 |    int a[N], b[N];
      |        ^
a.cc:11:12: error: expected ';' before 'i'
   11 |    for(int i=0; i<N; i++){
      |            ^
a.cc:11:17: error: 'i' was not declared in this scope
   11 |    for(int i=0; i<N; i++){
      |                 ^
a.cc:12:13: error: 'a' was not declared in this scope
   12 |       cin>> a[i]>> b[i];
      |             ^
a.cc:12:20: error: 'b' was not declared in this scope
   12 |       cin>> a[i]>> b[i];
      |                    ^
a.cc:15:8: error: expected ';' before 's'
   15 |    int s=0, t=0;
      |        ^
a.cc:16:12: error: expected ';' before 'i'
   16 |    for(int i=N-1; i>=0; i--){
      |            ^
a.cc:16:19: error: 'i' was not declared in this scope
   16 |    for(int i=N-1; i>=0; i--){
      |                   ^
a.cc:17:10: error: 'a' was not declared in this scope
   17 |       if(a[i]+s<=b[i]){
      |          ^
a.cc:17:15: error: 's' was not declared in this scope
   17 |       if(a[i]+s<=b[i]){
      |               ^
a.cc:17:18: error: 'b' was not declared in this scope
   17 |       if(a[i]+s<=b[i]){
      |                  ^
a.cc:30:11: error: 's' was not declared in this scope
   30 |    cout<< s<< endl;
      |           ^
Language: C++

//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

//メイン関数
int main() {
	//入力の取得
	int N;
	std::cin >> N;

	std::vector<int> A;
	std::vector<int> B;

	for(int i=0; i<N; ++i) {
		int tempA;
		int tempB;
		std::cin >> tempA >> tempB;
		A.push_back(tempA);
		B.push_back(tempB);
	}

	//入力の反転
	std::reverse(A.begin(), A.end());
	std::reverse(B.begin(), B.end());

	//答え
	auto answer = 0;

	//計算
	for(int i=0; i<N; ++i) {
		int Ai = A.at(i) + answer;
		int Bi = B.at(i);
		int answerTemp = 0;
		for(;(Ai % Bi) != 0; ++answerTemp, ++Ai) {
		}
		answer += answerTemp;
	}

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:14: error: 'reverse' is not a member of 'std'
   25 |         std::reverse(A.begin(), A.end());
      |              ^~~~~~~
a.cc:26:14: error: 'reverse' is not a member of 'std'
   26 |         std::reverse(B.begin(), B.end());
      |              ^~~~~~~
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    int i,tmp;
    int ans=0;
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int[] b=new int[n];
    for(i=0;i<n;i++){
      a[i]=sc.nextInt();
      b[i]=sc.nextInt();
    }
    for(i=n-1;i>=0;i--){
      tmp=a[i]%b[i];
      if(tmp!=0)ans+=n-tmp
    }
    System.out.println(ans);
  }
}


Compiler output:
Main.java:16: error: ';' expected
      if(tmp!=0)ans+=n-tmp
                          ^
1 error
Language: C++

int main(){
	vector<int> A,B;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		A.push_back(a);
		B.push_back(b);
	}
	int ans=0;
	for(int i=N-1;i>=0;i--){
		if (A[i]%B[i]!=0){
			int d=(B[i]-(A[i]%B[i]));
			ans+=d;
			for(int j=0;j<i;j++) A[j]+=d;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:9: error: 'vector' was not declared in this scope
    2 |         vector<int> A,B;
      |         ^~~~~~
a.cc:2:16: error: expected primary-expression before 'int'
    2 |         vector<int> A,B;
      |                ^~~
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin>>N;
      |         ^~~
a.cc:8:17: error: 'A' was not declared in this scope
    8 |                 A.push_back(a);
      |                 ^
a.cc:9:17: error: 'B' was not declared in this scope
    9 |                 B.push_back(b);
      |                 ^
a.cc:13:21: error: 'A' was not declared in this scope
   13 |                 if (A[i]%B[i]!=0){
      |                     ^
a.cc:13:26: error: 'B' was not declared in this scope
   13 |                 if (A[i]%B[i]!=0){
      |                          ^
a.cc:19:9: error: 'cout' was not declared in this scope
   19 |         cout<<ans<<endl;
      |         ^~~~
a.cc:19:20: error: 'endl' was not declared in this scope
   19 |         cout<<ans<<endl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll big = 1000000007ll;
ll n,m,k,x,y;

vector<ll> A;
vector<ll> B;

ll mod(ll i , ll b){
    if(i < 0)return mod(b - mod(-i),b);
    return i%b;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll c1,c2,c3,c4,c5;
    ll a,b,c;

    cin >> n;

    ll ans = 0;

    for(c1 = 0; c1 < n; c1++){
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    for(c1 = n-1; c1 >= 0; c1--){
        a = A[c1];
        b = B[c1];
        ans += mod(- ans - a,b);
    }
    cout << ans << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'll mod(ll, ll)':
a.cc:13:32: error: too few arguments to function 'll mod(ll, ll)'
   13 |     if(i < 0)return mod(b - mod(-i),b);
      |                             ~~~^~~~
a.cc:12:4: note: declared here
   12 | ll mod(ll i , ll b){
      |    ^~~
Language: C++

#include<bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long

using namespace std ;

const int MAXN = 101 * 1001 ;

int a[MAXN] , b[MAXN] ;

int32_t main()
{
    ios::sync_with_stdio(0) ; cin.tie(0) ;
    int n ;
    cin >> n ;
    for(int i = 0 ; i < n; i ++ )
        cin >> a[i] >> b[i] ;
    int m = 0 , ans = 0 ;
    for(int i = n - 1 ; i > -1 ; i -- )
    {
        a[i] += ans ;
        if(b[i]==1||a[i]%b[i]==0)
            continue ;
        ans += (b[i]-a[i]%b[i]) ;
    }
    cout << ans << '\n' ;
}
~    

Compiler output:
a.cc:32:2: error: expected class-name at end of input
   32 | ~
      |  ^
Language: C++

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll dfs(ll now, vector<vector<ll>>& graph)
{
    int i;
    vector<ll> v;
    for(i = 0;i < graph.at(now).size();++i){
        v.push_back(dfs(graph.at(now).at(i), graph));
    }
    sort(all(v));
    ll res = 0;
    for(i = 0;i < v.size();++i){
        res = max(res, v.at(i) + v.size() - i);
    }
    return res;
}

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<vector<ll>> graph(n);
    for(i = 1;i < n;++i){
        ll a;
        cin >> a;
        --a;
        graph.at(a).push_back(i);
    }
    cout << dfs(0, graph) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'll dfs(ll, std::vector<std::vector<long long int> >&)':
a.cc:18:18: error: no matching function for call to 'max(ll&, long long unsigned int)'
   18 |         res = max(res, v.at(i) + v.size() - i);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:18:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   18 |         res = max(res, v.at(i) + v.size() - i);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:18:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         res = max(res, v.at(i) + v.size() - i);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

vector<int> G[100'010];

int dfs(int v, vector<int>& dp, int p = -1){
  
  if(dp[v] >= 0) return dp[v];
  
  int deg = G[v].size();
  if(v != 0 && deg == 1) return dp[v] = 0;
  vector<int> temp;
  for(int nv: G[v]){
    if(nv == p) continue;
    temp.push_back(dfs(nv, dp, v));
  }
  sort(ALL(temp), greater<int>);
  int res = -1;
  int k = temp.size();
  REP(i, k) res = max(res, temp[i] + i + 1);
  return res;
}
    
int dfs()
int main(){
  //using namespace std;
  int n;
  cin>>n;
  int a[n];
  for(int i = 1; i < n; i++){
    cin>>a[i];
    a[i]--;
  }
  
  for(int i = 1; i < n; i++){
    G[i].push_back(a[i]);
    G[a[i]].push_back(i);
  }
  
  vector<int> dp(n, -1);
  dfs(0, dp);
  int ans = dp[0];
  cout << ans << endl;  
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(int, std::vector<int>&, int)':
a.cc:82:31: error: expected primary-expression before ')' token
   82 |   sort(ALL(temp), greater<int>);
      |                               ^
a.cc: At global scope:
a.cc:90:1: error: expected initializer before 'int'
   90 | int main(){
      | ^~~
Language: C++

#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
using namespace std;
int input() { int r; cin >> r; return r; }
vector<int>v[123456]; int n;
int f(int i) {
	vector<int>v1;
	for (int t : v[i])v1.push_back(f(t));
	sort(all(v1), greater<int>());
	int r = 0;
	for0(j, v1.size())r = max(r, v1[j] + j+1);
	return r;
}
signed main() {
	n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: 'i' was not declared in this scope
   17 |         n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1));
      |                           ^
a.cc:17:22: error: 'for1' was not declared in this scope; did you mean 'fork'?
   17 |         n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1));
      |                      ^~~~
      |                      fork
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

void dfs(ll cur, vector<ll>& depth, vector<vector<ll>>& net){
    for(ll nxt : net.at(cur)){
        depth.at(nxt) = depth.at(cur) + 1;
        dfs(nxt, depth, net);
    }
}

int main(){
    ll n;
    cin >> n;
    vector<ll> numwin(n, 0);
    vector<vector<ll>> net(n);
    for(ll i = 1; i < n; ++i){
        ll ai;
        cin >> ai;
        ai--;
        net.at(ai).push_back(i);
        numwin.at(ai)++;
    }

    vector<ll> depth(n, 0);
    dfs(0, depth);

    ll ans = 0;
    REP(i, n){
        ans = max(ans, depth.at(i) + numwin.at(i));
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:8: error: too few arguments to function 'void dfs(ll, std::vector<long long int>&, std::vector<std::vector<long long int> >&)'
   30 |     dfs(0, depth);
      |     ~~~^~~~~~~~~~
a.cc:9:6: note: declared here
    9 | void dfs(ll cur, vector<ll>& depth, vector<vector<ll>>& net){
      |      ^~~
Language: C++

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)

#define FOR(i, n, m) for (ll i = n; i < (ll)(m); i++)

#define pb push_back

#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef pair<int, int> p;

#define MAX_N 100010

vector<int> child[MAX_N];

ll dfs(ll node)
{
    vector<int> v;
    for (auto ch : child[node])
    {
        v.pb(dfs(ch));
    }
    sort(v.begin(), v.end()); //N log N
    ll tmp = 0;
    REP(i, v.size())
    {
        tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]);
    }
    return tmp;
}
int main()
{
    int N;
    cin >> N;
    REP(i, N - 1)
    {
        int a;
        cin >> a;
        child[--a].pb(i + 1);
    }
    cout << dfs(0) << endl;
}

Compiler output:
a.cc: In function 'll dfs(ll)':
a.cc:30:18: error: no matching function for call to 'max(ll&, long long unsigned int)'
   30 |         tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:30:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   30 |         tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:30:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |         tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  set <int> q;
  a[0] = 0;
  vector<int>ans(n,-1);
  ans[0]=0;
  vector<vector<int>>g(n);
  for (int i = 1; i < n; i++) {
    int x;
    cin>>x;
    x--;
    g[x].push_back(i);
  }
  function<int(int)>solve=[&](int i){
    vector<int>cur;
    for (int j:g[i]){
      cur.push_back(solve(j)+1);
    }
    int mx = 0;
    sort(cur.begin(),cur.end());
    for(int y:cur){
      if(y==mx)mx++;
      if(y>mx)mx=y;
    }
    return mx;
  };
  cout<<solve(0)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:3: error: 'function' was not declared in this scope
   53 |   function<int(int)>solve=[&](int i){
      |   ^~~~~~~~
a.cc:22:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
   21 | #include <cstring>
  +++ |+#include <functional>
   22 | 
a.cc:53:12: error: expected primary-expression before 'int'
   53 |   function<int(int)>solve=[&](int i){
      |            ^~~
a.cc:66:9: error: 'solve' was not declared in this scope
   66 |   cout<<solve(0)<<endl;
      |         ^~~~~
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

int n;
vector<int> G[100100];

int dfs(int v, int p) {
    vector<int> vec;
    if(G[v].size() == 0) return 0;
    for(auto& nv: G[v]) {
        if(nv == p) continue;
        int r = dfs(nv, v);
        ++r;
        vec.push_back(r);
    }
    sort(all(vec));
    reverse(all(vec));
    int res = vec[0];
    int i = 0;
    for(auto& rec: vec) {
        chmax(res, rec + i);
        ++i;
    }
    return res;
}

void solve() {
	cin >> n;
    rep(i, n - 1) {
        int a; cin >> a; --a;
        G[i].push_bacK(a);
        G[a].push_back(i);
    }
    cout << dfs(0) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:79:14: error: 'class std::vector<int>' has no member named 'push_bacK'; did you mean 'push_back'?
   79 |         G[i].push_bacK(a);
      |              ^~~~~~~~~
      |              push_back
a.cc:82:16: error: too few arguments to function 'int dfs(int, int)'
   82 |     cout << dfs(0) << endl;
      |             ~~~^~~
a.cc:55:5: note: declared here
   55 | int dfs(int v, int p) {
      |     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    cin >> N;
    int a[N+1];
    vector<int> edge[N+1];
    rep2(i, 2, N+1){
        cin >> a[i];
        edge[a[i]].push_back(i);
    }
    queue<int> que;
    int dep[N+1];
    bool lost[N+1];
    fill_n(lost, N+1, false);
    rep2(i, 1, N+1){
        if(edge[i].size() == 0){
            dep[i] = 0;
            lost[i] = true;
            que.push(i);
        }
    }
    int count[N+1]; //iに負ける人が何回出たか
  	rep(i,N+1)
    	count[i]=0;
    while(!que.empty()){
        int i = que.front();
        que.pop();
        if(i == 1) break;
        int j = a[i];
        int n = edge[j].size();
        bool update = true;
      	count[j]++;
      	if(count<n) //まだn人出ていなかったら更新しない
        	update=false;
        if(!update) continue;
        lost[j] = true;
        int d[n];
        rep(k, n) d[k] = dep[edge[j][k]];
        sort(d, d+n, greater<int>());
        dep[j] = 0;
        rep(k, n){
            dep[j] = max(dep[j], d[k]+k+1);
        }
        que.push(j);
    }
    cout << dep[1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   43 |         if(count<n) //まだn人出ていなかったら更新しない
      |            ~~~~~^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int n;
vi depth;
vvi v;
dfs(int i){
  vi k;int a=0;
  for(int x:v[i]){
    if(depth[x]=inf)depth[x]=dfs(x);
    k.pb(depth[x]);
  }
  sort(all(k));
  rep(i,k.size())chmax(a,k[i]+i+1);
  return a;
}

int main(){
    cin>>n;
  v=vvi(n);
  REP(i,1,n){
    int a;cin>>a;a--;
    v[a].pb(i);
  }
  depth=vi(n);
  rep(i,n)depth[i]=inf;
  cout<<depth[0]<<endl;
}

Compiler output:
a.cc:21:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
      |            ^~~~
a.cc:21:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
      |                    ^~~~
a.cc:22:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   22 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
      |            ^~~~
a.cc:22:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   22 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
      |                    ^~~~
a.cc:26:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   26 | dfs(int i){
      | ^~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
using namespace std;

const ll MAXN = 1e5 + 100;

vector <ll> g[MAXN];

bool used[MAXN];

ll n, len[MAXN];

void dfs(ll v) {

    used[v] = 1;
    len[v] = 1;

    for(auto to : g[v]) {

        if(!used[to]) {

            dfs(to);
            len[v] += len[to];

        }

    }

}

int main() {

cin >> n;

ll k;

for(int i = 2; i <= n; ++i) {

    cin >> k;

    g[i].pb(k);
    g[k].pb(i);

}

dfs(1);

ll ans = 0;

for(auto to : g[1]) {

    ans = max(ans, len[to]);

}

for(int i = 1; i <= n; ++i) {

    ans = max(ans, g[i].sz() * 1ll);

}

cout << ans;

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:14: error: no matching function for call to 'max(long long int&, long long unsigned int)'
   60 |     ans = max(ans, g[i].sz() * 1ll);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:60:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   60 |     ans = max(ans, g[i].sz() * 1ll);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:60:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     ans = max(ans, g[i].sz() * 1ll);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~
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 ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(222222);
ll dp[222222];
ll dfs(ll now,ll par){
  map<ll,ll>MP;
  for(auto a:E[now]){
    if(a==par)continue;
    MP[dfs(a,now)]++;
  }
  if(MP.size()==0)return dp[now]=0;
  else{
    ll num=-1;
    for(auto a:MP)
      num=(a.F>num)?a.F+a.S-1:num+cnt;
    return dp[now]=num+1;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n-1;i++){
    ll a;cin>>a;
    E[--a].pb(i+1);
    E[i+1].pb(a);
  }
  fill(dp,dp+222222,llINF);
  cout<<dfs(0,-1)<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'long long int dfs(long long int, long long int)':
a.cc:32:35: error: 'cnt' was not declared in this scope; did you mean 'int'?
   32 |       num=(a.F>num)?a.F+a.S-1:num+cnt;
      |                                   ^~~
      |                                   int
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
  cin >> n;
    vector<int> a(n+1);
    set<int> s;
    set<int> btm;
    for(int i = 2; i <= n; i++)
    {
        btm.insert(i);
    }
    for(int i = 2; i <= n; i++)
    {
        cin >> a[i];
        if(a[i] == 1)
        {
            s.insert(i);
        }
        btm.erase(a[i]);
    }
    vector<int> dp(n+1);
    for(int cand : s)
    {
        dp[cand] = 1;
    }
    function<int(int)> dfs = [&](int pos)
    {
        if(dp[pos] != 0) return dp[pos];
        return dp[pos] = dfs(a[pos]) + 1;
    };
    for(int i = 2; i <= n; i++)
    {
        dfs(i);
    }

    multiset<int> ms;
    for(int cand : btm)
    {
        ms.insert(dp[cand]);
    }
    int size = all.size();
    int ans = 0;
    int count = 0;
    auto itr = ms.rbegin();
    while(size)
    {
        ans = max(ans, *itr + count);
        count++;
        size--;
        itr++;
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:16: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   43 |     int size = all.size();
      |                ^~~
      |                std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

vector<lli> v[100010];
lli index1[100010];

int main(){

	lli n;
	cin>>n;

	for(lli i=2;i<=n;i++){
		lli tmp;
		cin>>tmp;
		v[tmp].push_back(i);
	}

	queue<lli> q;
	queue<lli> size;
	q.push(1);
	size.push(0);
	lli lastAns = 0;

	while(q.size()){
		lli top = q.front();
		lli topS = size.front();
		q.pop();
		size.pop();
		lastAns = topS;

		lli nowIndex = index1[top];
		if(nowIndex<v[top].size()){
			q.push(top);
			q.push(v[top].at(nowIndex));
			size.push(topS+1);
			size.push(topS+1);
			index[top]++;
		}
	}
	cout<<lastAns<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:30: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   43 |                         index[top]++;
      |                              ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

vector<lli> v[100010];
lli index[100010];

int main(){

	lli n;
	cin>>n;

	for(lli i=2;i<=n;i++){
		lli tmp;
		cin>>tmp;
		v[tmp].push_back(i);
	}

	queue<lli> q;
	queue<lli> size;
	q.push(1);
	size.push(0);
	lli lastAns = 0;

	while(q.size()){
		lli top = q.front();
		lli topS = size.front();
		q.pop();
		size.pop();
		lastAns = topS;

		lli nowIndex = index[top];
		if(nowIndex<v[top].size()){
			q.push(top);
			q.push(v[top].at(nowIndex));
			size.push(topS+1);
			size.push(topS+1);
			index[top]++;
		}
	}
	cout<<lastAns<<endl;

	return 0;
}

Compiler output:
a.cc:11:17: error: 'long long int index [100010]' redeclared as different kind of entity
   11 | lli index[100010];
      |                 ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:37:37: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   37 |                 lli nowIndex = index[top];
      |                                     ^
a.cc:43:30: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   43 |                         index[top]++;
      |                              ^
Language: C++

#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

void proc() {
	LOAD(int, N);
	LOADVEC(int, a, N - 1);
	std::vector<unordered_set<int>>childs(N);
	std::vector<unordered_set<int>>childs2;
	std::vector<int> depth(N, -1);
	std::vector<int>stack;
	for (int i = 0; i < N - 1; ++i) {
		childs[a[i] - 1].insert(1 + i);
	}
	childs2 = childs;
	//
	stack.reserve(N + 1);
	stack.push_back(0);
	depth[0] = -2;
	while (!stack.empty()) {
		int v = stack.back();
		bool pushed = false;
		for (auto child : childs2[v]) {
			int child = *childs2[v].begin();
			if (depth[child] == -1) {
				depth[child] = -2;
				stack.push_back(child);
				childs2[v].erase(child);
				pushed = true;
				break;
			}
		}
		if (!pushed) {
			std::vector<int>childsDepth;
			childsDepth.reserve(childs[v].size());
			for (auto &child : childs[v]) {
				childsDepth.push_back(depth[child]);
			}
			std::sort(childsDepth.begin(), childsDepth.end(), std::greater<int>());
			//
			int maxDepth = 0;
			for (int i = 0; i < childsDepth.size(); ++i) {
				int oneDepth = childsDepth[i] + i + 1;
				if (maxDepth < oneDepth)maxDepth = oneDepth;
			}
			depth[v] = maxDepth;
			stack.pop_back();
		}
	}
	cout << depth[0];
}

#endif


Compiler output:
a.cc: In function 'void proc()':
a.cc:70:29: error: redeclaration of 'long long int child'
   70 |                         int child = *childs2[v].begin();
      |                             ^~~~~
a.cc:69:27: note: 'long long int child' previously declared here
   69 |                 for (auto child : childs2[v]) {
      |                           ^~~~~
Language: C++

#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}



ll i,j,k,ii,jj;
ll n,m,num;
ll a,b,c,e,f,g,h;
ll y[800005],z[900005];
ll in[800005];
ll vnum = 0,sum,ans;
bool dame;
bool check[500005];

ll dfs(ll a){
	if(num <= 2000){
			ll x[2205];
		}else if(num <=  5000){
			ll x[5500];
		}else{
			ll x[8000];
		}
    if(G[a].size() == 0){
        return 0;
    }else{
        ll num = G[a].size();
		
		for(int i=0;i<num;i++){
			x[i] = dfs(G[a][i]);
		}
		sort(x,x+num);
		ll a = 0;
		for(i = 0;i<num;i++){
			a = max(a,x[i] + num - i);
		}
		return a;

    }
}

int main(){
    cin>>n;
    for(i=0;i<n-1;i++){
        cin >> a;
        //i+2番目はaに負けた
        G[a].pb(i+2);        
    }
    p(dfs(1));
    //p(ans);
    return 0;
}

Compiler output:
a.cc: In function 'll dfs(ll)':
a.cc:89:25: error: 'x' was not declared in this scope
   89 |                         x[i] = dfs(G[a][i]);
      |                         ^
a.cc:91:22: error: 'x' was not declared in this scope
   91 |                 sort(x,x+num);
      |                      ^
Language: C++

#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}



ll i,j,k,ii,jj;
ll n,m,num;
ll a,b,c,e,f,g,h;
ll y[800005],z[900005];
ll in[800005];
ll vnum = 0,sum,ans;
bool dame;
bool check[500005];

ll dfs(ll a){
	
    if(G[a].size() == 0){
        return 0;
    }else{
        ll num = G[a].size();
		if(num <= 2000){
			ll x[2205];
		}else if(num <=  5000){
			ll x[5500];
		}else{
			ll x[8000];
		}
		for(int i=0;i<num;i++){
			x[i] = dfs(G[a][i]);
		}
		sort(x,x+num);
		ll a = 0;
		for(i = 0;i<num;i++){
			a = max(a,x[i] + num - i);
		}
		return a;

    }
}

int main(){
    cin>>n;
    for(i=0;i<n-1;i++){
        cin >> a;
        //i+2番目はaに負けた
        G[a].pb(i+2);        
    }
    p(dfs(1));
    //p(ans);
    return 0;
}


Compiler output:
a.cc: In function 'll dfs(ll)':
a.cc:89:25: error: 'x' was not declared in this scope
   89 |                         x[i] = dfs(G[a][i]);
      |                         ^
a.cc:91:22: error: 'x' was not declared in this scope
   91 |                 sort(x,x+num);
      |                      ^
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
ll int MOD=998244353;
#define INF 2*1e9
#define N 310000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

int n;
vector<int> v[N];
int depth(int a){
    if(!v[a].size()) return 0;
    vector<int> w;
    rep(i,v[a].size()){
        w.pb(depth(v[a][i]));
    }
    sort(w.begin(),w.end());
    int ans=0;
    rep(i,w.size()){
        ans=max(ans,w[i]+(int)w.size()-i);
        temp--;
    }
    return ans;
}
main(){
    cin>>n;
    rep2(i,2,n){
        int a;
        cin>>a;
        v[a].push_back(i);
    }
    cout<<depth(1);
    return 0;
}


Compiler output:
a.cc: In function 'int depth(int)':
a.cc:29:9: error: 'temp' was not declared in this scope; did you mean 'tm'?
   29 |         temp--;
      |         ^~~~
      |         tm
a.cc: At global scope:
a.cc:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main(){
      | ^~~~
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
ll int MOD=998244353;
#define INF 2*1e9
#define N 310000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

int n;
vector<int> v[N];
int depth(int a){
    if(!v[a].size()) return 0;
    vector<int> w;
    rep(i,v[a].size()){
        w.pb(depth(v[a][i]));
    }
    sort(w.begin(),w.end());
    int ans=0;
    rep(i,w.size()){
        ans=max(ans,w[i]+w.size-i);
        temp--;
    }
    return ans;
}
main(){
    cin>>n;
    rep2(i,2,n){
        int a;
        cin>>a;
        v[a].push_back(i);
    }
    cout<<depth(1);
    return 0;
}


Compiler output:
a.cc: In function 'int depth(int)':
a.cc:28:28: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   28 |         ans=max(ans,w[i]+w.size-i);
      |                          ~~^~~~
      |                                ()
a.cc:29:9: error: 'temp' was not declared in this scope; did you mean 'tm'?
   29 |         temp--;
      |         ^~~~
      |         tm
a.cc: At global scope:
a.cc:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main(){
      | ^~~~