#include <bits/stdc++.h>
using namespace std;
inline int random_value(int min, int max) {
static mt19937 random(chrono::system_clock::now().time_since_epoch().count());
return uniform_int_distribution<int>(min,max)(random); }
unordered_map<int,int> dp; int used;
inline int solve(int n, int p = 0) {
if (n == 1)
return 1-p;
if (n == 2 or n&1)
return p;
auto it = dp.find(n);
if (it != dp.end())
return ++used, it->second^p;
int ans = 1-p;
for (int y, x = 2; x*x <= n; ++x)
if (n%x == 0) {
if (x&1 and solve(n/x,1-p) == p) {
ans = p; break; }
if (y = n/x, y > x and y&1 and solve(n/y,1-p) == p) {
ans = p; break; } }
dp[n] = ans^p;
return ans; }
int main() {
for (int i = 0; i < 1000000; ++i)
solve(random_value(1,1000000000));
cout << "dp value used " << used << " time(s)"; }
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbmxpbmUgaW50IHJhbmRvbV92YWx1ZShpbnQgbWluLCBpbnQgbWF4KSB7CiAgICAgc3RhdGljIG10MTk5MzcgcmFuZG9tKGNocm9ubzo6c3lzdGVtX2Nsb2NrOjpub3coKS50aW1lX3NpbmNlX2Vwb2NoKCkuY291bnQoKSk7CiAgICAgcmV0dXJuIHVuaWZvcm1faW50X2Rpc3RyaWJ1dGlvbjxpbnQ+KG1pbixtYXgpKHJhbmRvbSk7IH0KCnVub3JkZXJlZF9tYXA8aW50LGludD4gZHA7IGludCB1c2VkOyAKCmlubGluZSBpbnQgc29sdmUoaW50IG4sIGludCBwID0gMCkgewogICAgaWYgKG4gPT0gMSkKICAgICAgICByZXR1cm4gMS1wOyAKICAgIGlmIChuID09IDIgb3IgbiYxKQogICAgICAgIHJldHVybiBwOyAKICAgIGF1dG8gaXQgPSBkcC5maW5kKG4pOwogICAgaWYgKGl0ICE9IGRwLmVuZCgpKSAKICAgICAgICByZXR1cm4gKyt1c2VkLCBpdC0+c2Vjb25kXnA7CiAgICBpbnQgYW5zID0gMS1wOwogICAgZm9yIChpbnQgeSwgeCA9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