#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, i; cin >> N; vector u(N - 1), v(N - 1); for (i = 0; i != N; ++i) cin >> u[i] >> v[i]; vector> edges_from(N, vector()); for (i = 0; i != N; ++i) edges_from[u[i] - 1].push_back(v[i] - 1), edges_from[v[i] - 1].push_back(u[i] - 1); uint32_t count; for (i = 0; i != N; ++i) { count = 0; for (const auto edge : edges_from[i]) count += edges_from[edge].size(); cout << count - edges_from[i].size() << '\n'; } return 0; }