BIT: range updates, point queries; true meaning of tree[x]
For BIT and its variants, I recommend this article: http://coutcode.com/blog/binaryindexedtree/

The core of BIT is point update - range query, ie. for array $A[1 \dotsc n]$, BIT supports following operations:


$A[k] \leftarrow A[k] + d$ (Point update(k,d))
query partial sum $S[k] = A[1] + A[2] + \dotsb + A[k]$ (Range query(k))


Other variants are just converting to 1 or more of this case.

For range update - point query, it requires support following operations for array $A[1 \dotsc n]$:


$A[i] \leftarrow A[i] + d$ for all $a\le i &lt; b$. (Range update(a,b,d))
query value of $A[k]$. (Point query(k))


First, noting that after range update $A_1[i] \leftarrow A[i] + d, (a \le i \le b)$, we have $$\begin{align}A_1[a]-A_1[a-1]=&amp;A[a]-A[a-1]+d\\A_1[b+1]-A_1[b]=&amp;A[b+1]-A[b]-d\\A_1[i]-A_1[i-1]=&amp;A[i]-A[i-1]\ (i\notin\{a,b+1\})\end{align}$$
Taking $$D[i] = \begin{cases}A[i],&amp;i=1\\A[i]-A[i-1],&amp;1&lt;i\le n\end{cases}$$ then there are only 2 updates $$D[a]\leftarrow D[a]+d\\D[b+1]\leftarrow D[b+1]-d$$ and $$\begin{align}A[k]=&amp;A[1]+(A[2]-A[1])+\dotsb+(A[k]-A[k-1])\\=&amp;D[1]+D[2]+\dotsb+D[k]\end{align}$$

Thus building BIT on $D[1\dotsc n]$, we convert the range update$(a,b,d)$ on $A$ to 2 point updates $(a,d)$ and $(b+1,-d)$ on $D$, and the point query $(k)$ on $A$ is just the range query $(k)$ on $D$.