Fast Exponentiation [FEXP]

Subtask 3 giving TLE

Problem link -> https://www.codechef.com/problems/FEXP

My Code

#include <stdio.h>
#define mod 1000000007
long power(long,long);
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		long a,b;
		scanf("%ld%ld",&a,&b);
		printf("%ld\n",power(a,b));
	}
}

long power(long a,long b){
	if(b==0)
		return 1;
	long res = power(a%mod,((b%mod)/2))%mod;
	res = ((res%mod)*(res%mod))%mod;

	if(b&1)
		return res = ((res%mod) * (a%mod))%mod;
	return res%mod;
}

try doing it iterative merhod
const int mod = 1000000007;
inline int add(int x, int y){ x += y; return x%mod;}
inline int sub(int x, int y){ x -= y; x%=mod; x+=mod; return x%mod;}
inline int mul(int x, int y){ return (x*y) % mod;}
inline int powr(int a, int b){
int x = 1 % mod;
while(b){
if(b & 1) x = mul(x, a);
a = mul(a, a);
b >>= 1;
}
return x;
}