//-------------------------------------------------------------
// Next Combination
//
// Verified by
//   - SRM345 Div1 LV3
//-------------------------------------------------------------

LL next_combination(LL p)
{
	assert( p > 0 );
	LL lsb = p & -p;
	LL rem = p + lsb;
	LL rit = rem & ~p;
	return rem | (rit/lsb >> 1)-1;
}
