If query is of type 1 then function call to update with BITree2
for ( int i = m ; i >= 1 ; i -- ) { if ( q [ i ] [ 0 ] == 1 ) { long int val = getSum ( BITree , i - 1 ) ; update ( BITree2 , q [ i ] [ 1 ] - 1 , q [ i ] [ 2 ] - 1 , n , ( val + 1 ) ) ; } } for ( int i = 1 ; i <= n ; i ++ ) cout << ( getSum ( BITree2 , i - 1 ) ) << " ▁ " ; return 0 ; }