Sir my one test case is not passing it is giving me TLE. So what should i do?

#include<bits/stdc++.h>
using namespace std;

int main() {

set<long long int> s;
long long int t,k;
long long int n = 1e9 + 7;
cin>>t>>k;

while(t--) {
    
    long long int q,x,y,d = 0;

    cin>>q;

    if(q != 2) {
        cin>>x>>y;
        d = (x) * (x) + (y) * (y);
        s.insert(d);
    }
    else {
        auto it = s.begin();
        advance(it,k-1);
        cout << *it << endl;
    }

}

s.clear();

return 0;

}

Hello @yashme7125 your appraoch is correct but not optimised.
this is the question of the priority queue.
if you will use priority queue your code will be optimised and it will not give TLE.
it will make the code optimised.
Here for your reference i am attaching the code:


if you have any test case you can ask here:
Happy Learning!!