Driver Code
if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = [ 1 , 1 , 2 , 1 , 3 ] NEW_LINE n = len ( a ) NEW_LINE queries = [ Query ( 0 , 4 , 0 ) , Query ( 1 , 3 , 1 ) , Query ( 2 , 4 , 2 ) ] NEW_LINE q = len ( queries ) NEW_LINE queries . sort ( key = lambda x : x . r ) NEW_LINE answeringQueries ( a , n , queries , q ) NEW_LINE DEDENT