1. Abridged Problem Statement  
A network of N computers forms a tree: the very first computer is node 1, and each new computer i (2≤i≤N) connects to exactly one earlier computer with a cable of given length. For each computer i, compute Si = the maximum total cable length on a path from i to any other computer in the network.

2. Detailed Editorial  
- We have a weighted tree of N nodes. For each node, we want its eccentricity: the greatest distance to any other node.  
- A well-known fact about trees is that the farthest pair of nodes (the diameter endpoints) can be found by two breadth-first or depth-first searches (BFS/DFS):  
  1. Start at an arbitrary node A, do a DFS to find the farthest node U from A.  
  2. From U, do another DFS to find the farthest node V; the path U–V is a diameter of the tree.  
- Let distU[i] be the distance from U to node i, and distV[i] the distance from V to node i. Then for any node i, the eccentricity Si = max(distU[i], distV[i]).  
- This works because every longest path from i to some other node must end at one of the diameter endpoints U or V.  
- Complexity: each DFS is O(N), so overall O(N). N≤10 000, total cable length ≤10^9, fits time/memory limits.

3. C++ Solution
```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream &out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream &in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream &in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream &out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n;
vector<vector<pair<int, int>>> adj;

void read() {
    cin >> n;
    adj.assign(n, {});
    for(int i = 1; i < n; i++) {
        int u, w;
        cin >> u >> w;
        u--;
        adj[i].push_back({u, w});
        adj[u].push_back({i, w});
    }
}

vector<int> get_distances(int src) {
    vector<int> dist(n, -1);

    function<void(int, int)> dfs = [&](int u, int p) {
        for(auto [v, w]: adj[u]) {
            if(v == p) {
                continue;
            }
            dist[v] = dist[u] + w;
            dfs(v, u);
        }
    };

    dist[src] = 0;
    dfs(src, -1);
    return dist;
}

void solve() {
    // For each node we need the eccentricity: the distance to its farthest
    // node in the tree. The farthest node from any vertex is always one of the
    // two endpoints of the tree's diameter. We find the diameter with the
    // classic two passes: a DFS from node 0 gives the first endpoint (the
    // farthest from 0), a DFS from there gives the second endpoint, and a DFS
    // from that second endpoint gives the third distance array. For every node
    // the answer is the larger of its distances to the two diameter endpoints.

    vector<int> dist0 = get_distances(0);
    int diam_end_1 = max_element(dist0.begin(), dist0.end()) - dist0.begin();
    vector<int> dist1 = get_distances(diam_end_1);
    int diam_end_2 = max_element(dist1.begin(), dist1.end()) - dist1.begin();
    vector<int> dist2 = get_distances(diam_end_2);

    for(int i = 0; i < n; i++) {
        cout << max(dist1[i], dist2[i]) << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}
```

4. Python Solution with Detailed Comments  
import sys  
sys.setrecursionlimit(20000)

def read_tree():
    input_data = sys.stdin.read().split()
    it = iter(input_data)
    n = int(next(it))
    adj = [[] for _ in range(n)]
    # Each of the next n-1 lines: parent u, weight w
    for i in range(1, n):
        u = int(next(it)) - 1
        w = int(next(it))
        adj[i].append((u, w))
        adj[u].append((i, w))
    return n, adj

def get_distances(n, adj, src):
    dist = [-1] * n
    dist[src] = 0
    # DFS to fill dist[]
    def dfs(u, parent):
        for v, w in adj[u]:
            if v == parent: continue
            dist[v] = dist[u] + w
            dfs(v, u)
    dfs(src, -1)
    return dist

def main():
    n, adj = read_tree()
    # 1) from arbitrary node 0
    dist0 = get_distances(n, adj, 0)
    # find farthest from 0
    u = max(range(n), key=lambda i: dist0[i])
    # 2) from u
    dist_u = get_distances(n, adj, u)
    # farthest from u
    v = max(range(n), key=lambda i: dist_u[i])
    # 3) from v
    dist_v = get_distances(n, adj, v)
    # 4) answer for i is max(dist_u[i], dist_v[i])
    out = "\n".join(str(max(dist_u[i], dist_v[i])) for i in range(n))
    print(out)

if __name__ == "__main__":
    main()

5. Compressed Editorial  
To compute every node’s eccentricity in a weighted tree, find two diameter endpoints U and V by running two DFS/BFS traversals: one from an arbitrary node to find U, then from U to find V. Record distances distU[] and distV[]. For each node i, its maximum distance to any other node is max(distU[i], distV[i]).