Hostel visit problem

#include
#include

using namespace std;
typedef long long ll;
int main() {

priority_queue pq;
int Q,K;

cin>>Q>>K;

while(Q–)
{
int t;

   cin>>t;

   if(t == 1)
   {
     int x,y;

     cin>>x>>y;
     
     ll r = x*x + y*y;
     pq.push( r );

   }
   else if(t == 2)
   {
     while(pq.size()>K)
      pq.pop();

    if(pq.size() == K)
      cout<<pq.top()<<endl;
   }

}
return 0;
}

This code gets wrong-answer in TEST CASE 1.
Please tell me what is wrong in my code ?

You have declared x and y to be int.

And calculating the distance in long long. For you to get result in long long x and y also must be long long otherwise integer calculation is being performed.

Also declare pq as

priority_queue <ll> pq;

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.