Function to take maxmium interval
def query ( l , r ) : NEW_LINE INDENT if l + r in m . keys ( ) : NEW_LINE INDENT m [ l + r ] = max ( m [ l + r ] , r ) NEW_LINE DEDENT else : NEW_LINE INDENT m [ l + r ] = max ( 0 , r ) NEW_LINE DEDENT DEDENT