Help me in solving SMOL problem

My issue

it is giving runtime error again and again ?

My code

t=int(input())
for i in range(t):
    N, K=map(int,input().split())
    remainder = N % K
    if K != 0:
        remainder = N % K
        if remainder > K//2:
            print(K - remainder)
        else:
            print(remainder)
    else:
        print(0)

Problem Link: CodeChef: Practical coding for everyone

@amarkant10 i will just try to help u i use cpp as my language so i’ll just paste my solution over here
I hope that will help.(u can understand my approach I guess.)
hope this helps.

#include<iostream>
using namespace std;

int main()
{
    int T;
    cin>>T;
    
    while(T--)
    {
        int n,k;
        cin>>n>>k;
        
        if(k==0)
        {
            cout<<n<<endl;
        }
        else
        {
            cout<<n%k<<endl;
        }
        
    }
}

Why have you declared the variable “remainder” twice in the code?