To find index of a element in a vector  we usually find
 it=lower_bound(vector.begin(),vector.end(),element)
and subtract it like this int index = it-vector.begin()
But same concept is not applicable for set why and how can I do that?
Because int pos = it-a.begin() is giving me error in below program.
I want to find position of element in the set in that element.
#include<bits/stdc++.h>
using namespace std;
set<int>a;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++){
        int u;
        cin>>u;
        a.insert(u);
    }
    int ans=0;
    while(n--){
        for(int i=0;i<m;i++){
            int u;
            cin>>u;
            set<int>::iterator it = a.lower_bound(u);
            int pos = it-a.begin();
            a.erase(it);
            a.insert(a.begin(),u);
            ans+=pos;
        }
    }
    cout<<ans;
}
 
     
     
    