Driver code
int main ( ) { int arr [ ] = { 1 , 2 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; vector < pair < int , int > > queries = { { 1 , 2 } , { 1 , 3 } } ; answerQueries ( arr , n , queries ) ; }