Fenwick tree

Fenwick tree is a fixed-size data structure with operations:
query(i) - reutrn sum of first i+1 elements in O(log n) time
add(i, v) - add v to element i in O(log n) time
apply(f) - apply function f to each elemen in-place in O(n long n) time

handy operations that are dereived from query() and add():
get(i) - get element i in O(log n) time
set(i, v) - set element i to v in O(log n) time