#include <stdio.h>

    long long  NumberOfA(long long  x)
    {
    	long long t = x <<1;
    	while(t^(t&-t)) t ^= (t&-t);
        return t-++x;
    }
    
    unsigned long long NA2(long long x)
    {
    	unsigned long long y = ((((unsigned long long)x)-1)+1) >> 1;
    	return y;
    }



int main(void) {
	
	long long  x = 10000000000;
	
	printf("X:%lld => N(a):%lld; N2(a):%llu\n", 10LL, NumberOfA(10LL), NA2(10LL));
	printf("X:%lld => N(a):%lld; N2(a)%llu\n", x, NumberOfA(x), NA2(x));
	
	return 0;
}
