Help in question ANDSUBAR

For this question Longest AND Subarray
the code i wrote

#include <iostream>
using namespace std;
#include <math.h>
#define ll long long int

ll power(ll a,ll b){
	ll k;
	if (b==1 ) return a;
	else if (b%2!=0){
		k=power(a,b/2);
		return a*k*k;
	}
	else {
		k=power(a,b/2);
		return k*k;
	}
}

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    ll x;
	    cin>>x;
	    ll n=0;
	    if (x==1 || x==2) cout<<1;
	    else{
	        ll k;
	        while(power(2,n)<x){
	            n++;
	        }
	        k=power(2,n);
	        if (k==x) cout<<x/2;
	        else {
	            ll ans=k/4>x+1-k/2?k/4:x+1-k/2;
	            cout<<ans;
	        }
	        
	        
	    }
	    cout<<endl;
	}
	return 0;
}

type or paste code here

It shows SIGKILL error but when i use power function from math module it runs fine.
So can anyone tell what’s the problem

@meldig23
if(b==0)
return 1;
this base condition is missing in your code for power function

Thanks i got it