func_code_string: #include <bits/stdc++.h>   using namespace std;   void snum(long long &x) { scanf( %lld , &x); }   void snum(long long &x, long long &y) { scanf( %lld %lld , &x, &y); }   void snum(long long &x, long long &y, long long &z) {     scanf( %lld %lld %lld , &x, &y, &z);   }   vector<long long> adj[100100];   long long outDegree[100100];   long long out[100100];   bool vis[100100];   void dfs(long long u) {     vis[u] = true;     long long aux = 0;     for (long long i = 0; i < adj[u].size(); i++) {       long long v = adj[u][i];       if (!vis[v]) {         aux++;         dfs(v);       }     }     out[u] = outDegree[u] = aux;   }   long long n;   long long cant[100100];   long long need[100100];   void bfs() {     deque<long long> q;     for (long long i = 0; i < n; i++) {       if (outDegree[i] == 0) {         q.push_back(i);         cant[i]++;       }     }     while (!q.empty()) {       long long u = q.front();       q.pop_front();       for (long long i = 0; i < adj[u].size(); i++) {         long long v = adj[u][i];         outDegree[v]--;         if (outDegree[v] >= 0) {           cant[v] += cant[u];         }         if (outDegree[v] == 0) {           q.push_back(v);         }       }     }   }   void doit() {     snum(n);     for (long long i = 0; i < n - 1; i++) {       long long x;       snum(x);       x--;       adj[i + 1].push_back(x);       adj[x].push_back(i + 1);     }     dfs(0);     bfs();     for (long long i = 0; i < n; i++) {       need[cant[i]]++;     }     for (long long i = 1; i <= n; i++) {       long long x = need[i];       for (long long j = 0; j < x; j++) {         printf( %lld  , i);       }     }   }   int main() {     long long T = 1;     while (T--) {       doit();     }     return 0;   }   