FEB STARTERS25 BUILDING TOWER QUESTION

// LINK - to QUES → CodeChef: Practical coding for everyone
// My solution is same as provided by leetcode then why is my answer not being accepted ??
#include
#include
#include <math.h>
using namespace std;

int main() {
int t;
cin>>t;
for(int i=0;i<t;i++)
{
unsigned long long x;
unsigned long long m;
cin>>x;
cin>>m;
if(x==1)
{
cout<<m<<endl;
continue;
}
long long l = log2(x);
if(pow(2,l)!=x)
{
l=l+1;
}
l=l+1;
int ans = (m-l)+1;
if(m==0||ans<=0)
{
cout<<0<<endl;
}
else
{
cout<<ans<<endl;
}
}
return 0;
}