func_code_string: #include <bits/stdc++.h>   #pragma optimization_level 3   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   using namespace std;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   int getChar() {     static char buf[1 << 16];     static int pos = 0, size = 0;     if (pos == size) {       pos = 0;       size = (int)fread(buf, sizeof(buf[0]), sizeof(buf) / sizeof(buf[0]), stdin);     }     return buf[pos++];   }   inline int ni() {     char c = getChar();     for (; c ==   n  || c ==    ;) c = getChar();     int o = 0;     for (; c !=     && c !=   n ; c = getChar()) o = o * 10 + c -  0 ;     return o;   }   inline void putChar(int c) {     static char buf[1 << 16];     static int pos = 0;     if (c == EOF || pos == 1 << 16) {       fwrite(buf, sizeof(buf[0]), pos, stdout);       pos = 0;     }     if (c == EOF) return;     buf[pos++] = c;   }   void printInt(int val) {     char buf[7];     int pos = 0;     if (val == 0) buf[pos++] = 48;     for (; val; val /= 10) buf[pos++] = 48 + val % 10;     for (pos--; pos >= 0;) putChar(buf[pos--]);     putChar(  n );   }   const int G = 400002;   int a, OPA = -1;   vector<int> l[G];   int skok[G], o[G], zam[G], GR[G][2], mxd[G], mxp[G], dp[G][2], sz[G];   int CALC(int v, int D) {     mxd[v] = 1;     sz[v] = 1;     int c1 = 0, c2 = 0;     for (int h : l[v]) {       int x = CALC(h, D + 1);       mxd[v] = max(mxd[v], x + 1);       sz[v] += sz[h];       if (x >= c1)         c2 = c1, c1 = x;       else if (x > c2)         c2 = x;     }     mxp[v] = c1 + c2 + 1;     return mxd[v];   }   int eba = 1;   void RIP_PAPA(int v, int p) {     for (int q = 0; q < l[v].size(); q++) {       if (l[v][q] == p) {         l[v].erase(l[v].begin() + q);         break;       }     }     for (int h : l[v]) RIP_PAPA(h, v);   }   void rnm(int v, int p) {     for (int h : l[v])       if (h != p) zam[h] = eba++;     for (int h : l[v])       if (h != p) rnm(h, v);   }   int ST;   int GA(int LEN) {     if (o[LEN] != -1) return o[LEN];     int d1, d2, w, rg;     for (; ST >= 0 && mxp[ST] < OPA;) ST--;     for (int q = ST; q >= 0; q--) {       dp[q][0] = 0;       d1 = d2 = 0, w = GR[q][0], rg = GR[q][1];       for (; w <= rg; w++) {         dp[q][0] += dp[w][0];         if (dp[w][1] >= d1)           d2 = d1, d1 = dp[w][1];         else           d2 = max(d2, dp[w][1]);       }       if (d1 + d2 + 1 < LEN)         dp[q][1] = d1 + 1;       else         dp[q][0]++, dp[q][1] = 0;     }     return o[LEN] = dp[0][0];   }   int main() {     cin.tie(0);     cout.tie(0);     cin.sync_with_stdio(0);     cout.sync_with_stdio(0);     ;     memset(o, -1, sizeof(o));     a = ni();     o[1] = a;     ;     ST = a - 1;     for (int q = 1; q <= a; q++) skok[a / q]++;     for (int &i : skok) i /= 2;     vector<pair<int, int> > reb(a - 1);     for (int q = 0; q < a - 1; q++) {       int x = ni() - 1, y = ni() - 1;       reb[q] = {x, y};       l[x].push_back(y);       l[y].push_back(x);     }     zam[0] = 0;     rnm(0, -1);     for (int q = 0; q < a; q++) l[q].clear();     for (pair<int, int> p : reb) {       l[zam[p.first]].push_back(zam[p.second]);       l[zam[p.second]].push_back(zam[p.first]);     }     RIP_PAPA(0, -1);     for (int q = 0; q < a; q++) {       GR[q][0] = l[q].size() ? l[q][0] : a;       GR[q][1] = l[q].size() ? l[q].back() : q;     }     CALC(0, 1);     int diam = 0;     for (int &i : mxp) diam = max(i, diam);     o[diam] = 1;     for (int q = diam + 1; q <= a; q++) o[q] = 0;     int H = min(a - 1, (int)(sqrt(diam))), U = 1, I = 2;     for (; I <= H; I++) {       o[I] = GA(I);       OPA = I / 2;     }     int tyt;     for (; I <= a;) {       OPA = I / 2;       tyt = GA(I);       int lf = I, rg = min(a + 1, lf + skok[tyt] + 1);       if (tyt == 0) break;       if (tyt == 1) lf = diam, rg = diam + 1;       for (; lf + 1 < rg;) {         int md = (lf + rg) / 2;         if (GA(md) == tyt)           lf = md;         else           rg = md;       }       for (; I < rg; I++) o[I] = tyt;     }     for (int q = 1; q <= a; q++) {       printInt(max(0, o[q]));     }     putChar(EOF);   }   