Couldn't figure out y it is going wrong


#1

MY code:
int Mod1(int A,int B,int C)
{

if(B==0)
return 1;
else if(B%2==0)
{
      int y=Mod1(A,B/2,C);
       return ((y%C)*(y%C))%C;
   
}
 else
 {
   return ((A%C)*(Mod1(A,B-1,C)%C))%C;
  }

}

int Solution::Mod(int A, int B, int C) {

if(A==0)
return 0;

int  ans=Mod1(A,B,C);
 if(ans<0)
 return ans+C;
 return ans;

}
not working for larger inputs
A : 71045970
B : 41535484
C : 64735492


#2

Make int y as long long int