Doubt in today's byte problem on HackerBlocks

ques ) https://hack.codingblocks.com/app/dcb/1457

my answer ) https://ide.codingblocks.com/s/241384
problem ) 3 test case are passing and 3 are not. Please tell where is the error

simply count no of set bits

ur code malfunctions of large inputs
since power( 2, large no)
gives wrong o/p

Thank you . Understood.

Can you please help me with another problem
ques )https://hack.codingblocks.com/app/practice/1/1275/problem
ans ) https://ide.codingblocks.com/s/242590
problem ) 2 test cases are giving wrong answer

u should be using fastPower
this approach is discussed in the course content

complexity is O(logn )
and take long long type variable

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}