Hi! The problem is with the following
bool comp(pair<ll,ll> a,pair<ll,ll> b){
if(a.s>b.s)
return false;
else
return true; }
after changing it to
bool comp(pair<ll,ll> a,pair<ll,ll> b){
return a.s<b.s;}
your code gets accepted.
as far as I know (but feel free to do your own research), the reason for this is the way STL sort expects the comparator to work - your implementation returns true for two equal elements, mine returns false. The way STL interprets that afaik is ‘if A comp B is true, then A < B. if neither A comp B, nor B comp A, then it means A == B’. But yours returned true both times, as if A < B and B < A, and it cant cope with it.
hope this helps 