Segment Tree Code
void update(int node, int start, int end, int index, int val) { if (index end) return; if (start == end) { tree[node] = val; return; } update(tree, node * 2, start, (start + end) / 2, index, val); update(tree, node * 2 + 1, (start + end) / 2 + 1, end, index, val); tree[node] = tree[node * 2] + tree[node * 2 + 1]; } int query(int node, int start, int end, int i, int j) { if (jend) return 0; if (i..