Help me in solving SMOL problem

My issue

while(t–){
long long n,k;
cin>>n>>k;
if(n>k) cout<<n%k<<endl;
else cout<<n<<endl;
}
why i am getting run time error in this approach.

My code

#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
        long long n,k;
        cin>>n>>k;
        if(n>k) cout<<n%k<<endl;
        else cout<<n<<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

@hasingh_20
u have to take care of the case when k==0 .
plzz refer my c++ 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;
}