Driver code
if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 ] NEW_LINE N = len ( arr ) NEW_LINE tree = [ 0 for i in range ( 4 * N + 5 ) ] NEW_LINE build ( tree , arr , 0 , N - 1 , 0 ) NEW_LINE Q = [ [ 2 , 0 , 3 ] , [ 1 , 1 , 5 ] , [ 2 , 1 , 2 ] ] NEW_LINE cntQuey = 3 NEW_LINE for i in range ( cntQuey ) : NEW_LINE INDENT if ( Q [ i ] [ 0 ] == 1 ) : NEW_LINE INDENT update ( tree , 0 , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT if ( Q [ i ] [ 1 ] % 2 == 0 ) : NEW_LINE INDENT print ( FindSum ( tree , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 ) , end = " ▁ " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - FindSum ( tree , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 ) , end = " ▁ " ) NEW_LINE DEDENT DEDENT DEDENT DEDENT