Help me in solving SMOL problem

My issue

so in this problem how do I avoid getting runtime error

My code

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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    long n,k;
	    cin>>n>>k;
	    if(n<k){
	        cout<<n<<endl;
	    }
	    else{
	        cout<<n%k<<endl;
	    }
	}
}

Learning course: Level up from 1* to 2*
Problem Link: Smallest Possible Whole Number Practice Problem in Level up from 1* to 2* - CodeChef

@iamthelegend89
U have to take care of the case when k==0
plzz refer my solution

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n,k;
	    cin>>n>>k;
	    if(k==0)
	    cout<<n;
	    else
	    cout<<n%k;
	    cout<<endl;
	}
	return 0;
}

Figured it out, thanks alot