Gives TLE in one of the test case

#include
#include

#include<bits/stdc++.h>
using namespace std;
typedef pair<long,pair<int,int>> ppi;
int kthsmallest(vector<pair<int,int>> v,int k){
priority_queue maxh;
int size=v.size();

for(int i=0;i<size;i++){

maxh.push({v[i].first*v[i].first+v[i].second*v[i].second,{v[i].first,v[i].second}});
if(maxh.size()>k){
	maxh.pop();
}

}
return maxh.top().first;

}
int main() {
vector<pair<int,int>> coord_v;
int q;
cin>>q;
int k;
cin>>k;
int no;
while(q–){
cin>>no;
if(no==1){
//query1
int x,y;
cin>>x>>y;
coord_v.push_back({x,y});

}else{
	//query2
	cout<<kthsmallest(coord_v,k)<<endl;
}}
return 0;

}

instead of int take long long int

after taking long long int for distabce,still getting TLE

please use priority queue for this question

yes , i m using priority_queue

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.