1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "bits/stdc++.h"
using namespace std;

int CountFast(int n) {
  vector<tuple<int,int,int>> S; S.reserve(20000);
  auto Check = [&](int i, int j, int k) {
    if (i == -1) {i = n/(1+j+j*k);}
    if (j == -1) {j = (n-i)/(i+i*k);}
    if (k == -1) {k = (n-i-i*j)/(i*j);}
    int a = i;
    int b = j*a;
    int c = k*b;
    if(1 <= a && a < b && b < c && a + b + c == n) {
      S.emplace_back(a,b,c);
    }
  };
  for (int i = 1; i*i*i <= n; ++i) {
    for (int j = 1; i*j*max(i,j) <= n; ++j) {
      Check(i,j,-1);
      Check(j,i,-1);
      Check(i,-1,j);
      Check(j,-1,i);
      Check(-1,i,j);
      Check(-1,j,i);
    }
  }
  sort(S.begin(), S.end());
  return unique(S.begin(), S.end()) - S.begin();
}

int CountSlow(int n) {
  int cnt = 0;
  for (int a = 1; a < n; ++a) if (n % a == 0){
    for (int b = 2 * a; a + 2 * b < n; b += a) if ((n-a)%b == 0){
      int c = n - a - b;
      if (c % b == 0) {
          ++cnt;
      }
    }
  }
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  cout << CountFast(n) << '\n';
}