Driver program for the above code
int main ( ) { vector < pair < int , int > > segments ; segments . push_back ( make_pair ( 2 , 5 ) ) ; segments . push_back ( make_pair ( 4 , 8 ) ) ; segments . push_back ( make_pair ( 9 , 12 ) ) ; cout << segmentUnionLength ( segments ) << endl ; return 0 ; }