Driver Code
if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = [ 1 , 1 , 5 , 4 , 5 ] NEW_LINE n = len ( a ) NEW_LINE q = [ Query ( 0 , 2 , 2 ) , Query ( 1 , 4 , 1 ) , Query ( 2 , 4 , 5 ) ] NEW_LINE m = len ( q ) NEW_LINE initialize ( a , n , q , m ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT flag = False NEW_LINE l = q [ i ] . L NEW_LINE r = q [ i ] . R NEW_LINE x = q [ i ] . X NEW_LINE p = r NEW_LINE while p >= l : NEW_LINE DEDENT DEDENT