#include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using ld = long double; constexpr ll MOD = 1000000007LL; template constexpr T INF = numeric_limits::max() / 10; template struct fix_type { Functor functor; template decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward(args)...); } }; template fix_type::type> fix(Functor&& functor) { return {std::forward(functor)}; } int main() { ll N; cin >> N; if (N == 0) { cout << "YES" << endl; return 0; } int depth = 0; for (ll minimum = 1; minimum <= N; minimum = 2 * minimum + 1) { depth++; } ll s = 1; ll t = 1; for (int i = 0; i < depth; i++) { ll sum = 0; for (ll j = i + 1, tmp = t * 2; j < depth; j++, tmp = 2 * tmp + 1) { sum += tmp; } if (s + sum == N) { cout << "YES" << endl; return 0; } if (s + sum < N) { s += t * 2 + 1; t = t * 2 + 1; } else { s += t * 2; t = t * 2; } } cout << (s == N ? "YES" : "NO") << endl; return 0; }