#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- #define FAC_MAX 200001 typedef long long ll; ll fac_memo[FAC_MAX]; int fac_memo_max = 0; ll fac(ll a) { if (a <= fac_memo_max) return fac_memo[a]; fac_memo[0] = 1; rep(i, fac_memo_max + 1, a + 1) { fac_memo[i] = fac_memo[i - 1] * i; } fac_memo_max = a; return fac_memo[a]; } ll aCb(ll a, ll b) { if (a == 0) return 1; if (a < b) return 0; return fac(a) / (fac(a - b) * fac(b)); } /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ ll N; //--------------------------------------------------------------------------------------------------- ll f(ll a) { if (a == 0 or a == 1) return 0; if (a % 2 == 0) return f(a / 2) + a / 2; return 2 * f(a / 2); } //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; cout << f(N) << endl; return; rep(n, 0, 20) { printf("<%d>\n", n); int cnt = 0; rep(i, 0, n + 1) { ll x = aCb(n, i); if (x % 2 == 0) cnt++; printf(" %lld", x); } printf(" [%d] \n", cnt); } }