Driver code
static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; int [ ] tree = new int [ 4 * N + 5 ] ; build ( tree , arr , 0 , N - 1 , 0 ) ; int [ , ] Q = { { 2 , 0 , 3 } , { 1 , 1 , 5 } , { 2 , 1 , 2 } } ; int cntQuey = 3 ; for ( int i = 0 ; i < cntQuey ; i ++ ) { if ( Q [ i , 0 ] == 1 ) { update ( tree , 0 , 0 , N - 1 , Q [ i , 1 ] , Q [ i , 2 ] ) ; } else { if ( Q [ i , 1 ] % 2 == 0 ) { Console . Write ( FindSum ( tree , 0 , N - 1 , Q [ i , 1 ] , Q [ i , 2 ] , 0 ) + " ▁ " ) ; } else { Console . Write ( - FindSum ( tree , 0 , N - 1 , Q [ i , 1 ] , Q [ i , 2 ] , 0 ) + " ▁ " ) ; } } } } }