For hostel visit problemm

my code is giving correct output for sample input but wrong for test cases
#include
#include
#include
using namespace std;
int main() {
int q;
int k;
cin>>q>>k;
int query;

priority_queue<int> topk;

for(int i=0;i<k;i++)
  {  topk.push(10000000);}
	


for(int i=0;i<q;i++)
{
	cin>>query;
	if(query==1)
	{
		int x,y;
		cin>>x>>y;
		int dist= ((x*x)+(y*y));
		if(dist<topk.top())
        {
            topk.pop();
            topk.push(dist);
        }
		


	}
	else if(query==2)
	{
		cout<<topk.top()<<endl;
	}
}
return 0;

}

please consider long long int as squares wont fit into int data structures.
there is overflow in you solution which is changing values.

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.