Language: C++

    #include<bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define fi first
    #define se second
    ll sieve[1000001]={0},i,j;
    ll m=1e9+7;
    ll lev=0;
    ll n,k;
    ll power(ll p, ll k)
    {
    ll a=1;
    while(k)
    {
    if(k&1)
    a=(a*p)%m;
    p=(p*p)%m;
    k>>=1;
    }
    return a;
    }
    using namespace std;
    vector<ll> v[1000000+1];
    ll vis[1000000+1]={0};
    void dfs(ll u,ll p,ll lev)
    {
        vis[u]=lev;
    for(auto x: v[u])
    {
    if(x!=p)
    {
    dfs(x,u,lev+1);
    }
    }
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
     int tc=1;
    //cin>>tc;
    ll cas=1;
     while(tc--)
     {
      
    ll n;
    cin>>n;
    ll a[n+1];
    map<ll,ll> m;
    for(i=2;i<=n;i++)
    {
    cin>>a[i];
    m[a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
    cout<<m[i];
         cout<<"\n";
     } 
     } 
    }

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll m=1e9+7;
ll lev=0;
ll n,k;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
vector<ll> v[1000000+1];
ll vis[1000000+1]={0};
void dfs(ll u,ll p,ll lev)
{
    vis[u]=lev;
for(auto x: v[u])
{
if(x!=p)
{
dfs(x,u,lev+1);
}
}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
  
ll n;
cin>>n;
ll a[n+1];
map<ll,ll> m;
for(i=2;i<=n;i++)
{
cin>>a[i];
m[a[i]]++;
}
for(i=1;i<=n;i++)
{
cout<<m[i];
     cout<<"\n";
 } 
 } 
}

Compiler output:
a.cc:68:4: error: redefinition of 'long long int sieve [1000001]'
   68 | ll sieve[1000001]={0},i,j;
      |    ^~~~~
a.cc:6:8: note: 'long long int sieve [1000001]' previously defined here
    6 |     ll sieve[1000001]={0},i,j;
      |        ^~~~~
a.cc:68:23: error: redefinition of 'long long int i'
   68 | ll sieve[1000001]={0},i,j;
      |                       ^
a.cc:6:27: note: 'long long int i' previously declared here
    6 |     ll sieve[1000001]={0},i,j;
      |                           ^
a.cc:68:25: error: redefinition of 'long long int j'
   68 | ll sieve[1000001]={0},i,j;
      |                         ^
a.cc:6:29: note: 'long long int j' previously declared here
    6 |     ll sieve[1000001]={0},i,j;
      |                             ^
a.cc:69:4: error: redefinition of 'long long int m'
   69 | ll m=1e9+7;
      |    ^
a.cc:7:8: note: 'long long int m' previously defined here
    7 |     ll m=1e9+7;
      |        ^
a.cc:70:4: error: redefinition of 'long long int lev'
   70 | ll lev=0;
      |    ^~~
a.cc:8:8: note: 'long long int lev' previously defined here
    8 |     ll lev=0;
      |        ^~~
a.cc:71:4: error: redefinition of 'long long int n'
   71 | ll n,k;
      |    ^
a.cc:9:8: note: 'long long int n' previously declared here
    9 |     ll n,k;
      |        ^
a.cc:71:6: error: redefinition of 'long long int k'
   71 | ll n,k;
      |      ^
a.cc:9:10: note: 'long long int k' previously declared here
    9 |     ll n,k;
      |          ^
a.cc:72:4: error: redefinition of 'long long int power(long long int, long long int)'
   72 | ll power(ll p, ll k)
      |    ^~~~~
a.cc:10:8: note: 'long long int power(long long int, long long int)' previously defined here
   10 |     ll power(ll p, ll k)
      |        ^~~~~
a.cc:85:12: error: redefinition of 'std::vector<long long int> v [1000001]'
   85 | vector<ll> v[1000000+1];
      |            ^
a.cc:23:16: note: 'std::vector<long long int> v [1000001]' previously declared here
   23 |     vector<ll> v[1000000+1];
      |                ^
a.cc:86:4: error: redefinition of 'long long int vis [1000001]'
   86 | ll vis[1000000+1]={0};
      |    ^~~
a.cc:24:8: note: 'long long int vis [1000001]' previously defined here
   24 |     ll vis[1000000+1]={0};
      |        ^~~
a.cc:87:6: error: redefinition of 'void dfs(long long int, long long int, long long int)'
   87 | void dfs(ll u,ll p,ll lev)
      |      ^~~
a.cc:25:10: note: 'void dfs(long long int, long long int, long long int)' previously defined here
   25 |     void dfs(ll u,ll p,ll lev)
      |          ^~~
a.cc:98:5: error: redefinition of 'int main()'
   98 | int main()
      |     ^~~~
a.cc:36:9: note: 'int main()' previously defined here
   36 |     int main()
      |         ^~~~