malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<long long int> adj[200005];   vector<int> visited(200005, 0);   vector<long long int> ans;   void topo(long long int s) {     visited[s] = 1;     long long int sz = adj[s].size();     for (long long int i = 0; i < sz; i++) {       if (visited[adj[s][i]] == 0) topo(adj[s][i]);     }     ans.push_back(s);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int w;     cin >> w;     while (w--) {       long long int t, x, y, n, m;       cin >> n >> m;       vector<pair<long long int, long long int> > anso;       vector<pair<long long int, long long int> > edg;       for (long long int i = 1; i <= n; i++) {         visited[i] = 0;         adj[i].clear();       }       ans.clear();       for (long long int i = 0; i <= m - 1; i++) {         cin >> t >> x >> y;         if (t == 1) {           adj[x].push_back(y);           anso.push_back({x, y});         } else {           edg.push_back({x, y});         }       }       long long int fou = 0;       for (long long int i = 1; i <= n; i++) {         if (!visited[i]) topo(i);       }       reverse((ans).begin(), (ans).end());       vector<long long int> pre(n + 1, 0);       for (long long int i = 0; i < n; i++) {         pre[ans[i]] = i + 1;       }       for (long long int i = 0; i < anso.size(); i++) {         if (pre[anso[i].first] > pre[anso[i].second]) {           fou = 1;           break;         }       }       if (fou) {         cout <<  NO  <<   n ;         continue;       } else {         cout <<  YES  <<   n ;       }       long long int sz = edg.size();       for (long long int i = 0; i < sz; i++) {         if (pre[edg[i].first] < pre[edg[i].second]) {           anso.push_back({edg[i].first, edg[i].second});         } else {           anso.push_back({edg[i].second, edg[i].first});         }       }       for (auto i : anso) {         cout << i.first <<     << i.second <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   std ::map<int, int>::iterator x, l, s;   int main() {     int n, p;     cin >> n;     mp[0] = 0;     mp[1 << 30] = 0;     for (int i = 0; i < n; i++) {       cin >> p;       x = mp.lower_bound(p);       l = x--;       s = x->second > l->second ? x : l;       if (i) cout << s->first <<    ;       mp[p] = s->second + 1;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     scanf( %d , &t);     for (int a = 0; a < t; a++) {       int n;       scanf( %d , &n);       string attack, prepend;       cin >> attack;       while (!attack.empty() and attack.back() == attack.front()) {         prepend += attack.back();         attack.pop_back();       }       if (attack.empty()) {         printf( %d n , (n + 2) / 3);         continue;       }       attack = prepend + attack;       int answer = 0, streak = 1;       for (int b = 1; b < n; b++) {         if (attack[b] == attack[b - 1]) {           streak++;         } else {           streak = 1;         }         if (streak % 3 == 0) {           answer++;         }       }       printf( %d n , answer);     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxN = 3e2 + 2, N = 1e5 + 7, MOD = 1e9 + 7, Mod = 1e9 + 6,                   INF = 1LL << 56;   long long n, m, k, x, y, z, dp[maxN][maxN], ans[maxN][maxN];   int main() {     cin.tie(0);     cout.tie(0);     ios::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) dp[i][j] = INF, ans[i][j] = INF;     }     for (int i = 1; i <= m; i++) cin >> x >> y >> z, dp[x][y] = min(dp[x][y], z);     for (long long i = n; i >= 1; i--) {       for (long long j = n; j >= 1; j--)         dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]),                dp[i][j - 1] = min(dp[i][j], dp[i][j - 1]);     }     for (int len = 1; len <= n - 1; len++) {       for (int i = 1; i <= n - len; i++) {         long long j = len - i;         for (int u = i; u <= j; u++)           dp[i][j] = min(dp[i][u] + dp[u + 1][j], dp[i][j]);       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= i; j++) {         if (i != 1) ans[i][j] = min(ans[i][j], ans[i - 1][j]);         for (int u = 1; u <= j; u++)           ans[i][j] = min(ans[i - u][j - u] + dp[i - u + 1][i], ans[i][j]);       }     }     if (ans[n][k] == INF) return cout <<  -1 n , 0;     return cout << ans[n][k] <<   n , 0;   }
#include <bits/stdc++.h>   using namespace std;   void RD(int &x) { scanf( %d , &x); }   void RD(long long &x) { scanf( %I64d , &x); }   void RD(double &x) { scanf( %lf , &x); }   void RD(int &x, int &y) { scanf( %d%d , &x, &y); }   void RD(long long &x, long long &y) { scanf( %I64d%I64d , &x, &y); }   void RD(double &x, double &y) { scanf( %lf%lf , &x, &y); }   void RD(char *s) { scanf( %s , s); }   void RD(char &s) { scanf( %c , &s); }   void RD(string &s) { cin >> s; }   void PR(int x) { printf( %d n , x); }   void PR(int x, int y) { printf( %d %d n , x, y); }   void PR(long long x) { printf( %I64d n , x); }   void PR(char x) { printf( %c n , x); }   void PR(char *x) { printf( %s n , x); }   void PR(string x) { cout << x << endl; }   const int inf = 1e9;   const long long mod = 1LL;   int dp[1010][1010];   char s1[1010], s2[1010];   int len1, len2;   int solve(int n, int m) {     if (n == len1) return dp[n][m] = len2 - m;     if (m == len2) return dp[n][m] = len1 - n;     int &ret = dp[n][m];     if (ret != inf) return ret;     if (s1[n] == s2[m])       ret = solve(n + 1, m + 1);     else       ret = min(min(1 + solve(n + 1, m + 1), 1 + solve(n, m + 1)),                 1 + solve(n + 1, m));     return ret;   }   void path(int n, int m, int p, int q) {     if (n == len1) {       int i, j;       for (i = m, j = q; i < len2; i++, j++)         printf( INSERT %d %c n , j + 1, s2[i]);       return;     }     if (m == len2) {       int i;       for (i = n; i < len1; i++) printf( DELETE %d n , p + 1);       return;     }     if (s1[n] == s2[m]) return path(n + 1, m + 1, p + 1, q + 1);     if (dp[n][m] == 1 + dp[n + 1][m + 1]) {       printf( REPLACE %d %c n , p + 1, s2[m]);       return path(n + 1, m + 1, p + 1, q + 1);     } else if (dp[n][m] == 1 + dp[n][m + 1]) {       printf( INSERT %d %c n , p + 1, s2[m]);       return path(n, m + 1, p + 1, q + 1);     } else {       printf( DELETE %d n , p + 1);       return path(n + 1, m, p, q);     }   }   int main() {     int i, j;     while (scanf( %s %s , s1, s2) == 2) {       len1 = strlen(s1);       len2 = strlen(s2);       for ((i) = 0; (i) < (int)(len1 + 1); (i)++)         for ((j) = 0; (j) < (int)(len2 + 1); (j)++) dp[i][j] = inf;       PR(solve(0, 0));       path(0, 0, 0, 0);     }     return 0;   }
#include <algorithm>   #include <iostream>   #include <climits>   #include <iomanip>   #include <cstring>   #include <string>   #include <vector>   #include <queue>   #include <cmath>   #include <set>   #include <map>      using namespace std;      template <typename T> istream &operator>>   (istream &is, vector<T> &vec)    {   for (auto &v : vec) is >> v; return is; }      #define all(x) (x).begin(),(x).end()   #define rall(x) (x).rbegin(),(x).rend()   #define ll long long   #define mod 1000000007   #define nod 1000000007   #define vi vector<int>   #define vll vector<ll>   #define pb push_back         // D R U L   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};      const int mx = 1e6 + 5;   const int INF = mod;      ll power(ll x, ll y){       ll res = 1;       while(y > 0){           if(y & 1) res = (res * x) % nod;           y >>= 1;           x = (x * x) % nod;       }       return (res % nod);   }         // Check for number of Cases!!   void solve() {       ll n; cin >> n;       string str; cin >> str;       str +=  $ ;              vector<int> freq(26, -1);              for(int i = 1; i < str.length(); i++) {           if(str[i] != str[i - 1]) {               if(freq[str[i - 1] -  A ] == -1) {                   freq[str[i - 1] -  A ] = i;               }else {                   cout <<  NO n ;                   return;               }           }       }              cout <<  YES n ;   }      int main(){          #ifndef ONLINE_JUDGE       freopen( /ATOMCODES/input.txt ,  r , stdin);       freopen( /ATOMCODES/output.txt ,  w , stdout);       freopen( /ATOMCODES/err_output.txt ,  w , stderr);       #endif          ios_base::sync_with_stdio(false);       cin.tie(NULL);              int t = 1;       cin >> t;       while(t--) {         solve();       }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   void solve() {     long long v, c, vv, cc;     cin >> v >> c >> vv >> cc;     long long f = 0;     if (cc > min(v, c)) {       cout <<  NO n ;       return;     }     v += c;     vv += cc;     if (vv > v) {       cout <<  NO n ;       return;     }     cout <<  YES n ;     if (f == 1) {     } else {     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long int n, c = 0, p = 0;       cin >> n;       long long int s = (n / 2);       for (int i = 1; i <= s; i++) {         p += 8;         c += (p * i);       }       cout << c << endl;     }   }
#include <bits/stdc++.h>   namespace imzzy {   class fastin {    private:     int _ch, _f;       public:     inline fastin &operator>>(char &c) {       c = getchar();       return *this;     }     template <typename _Tp>     inline fastin &operator>>(_Tp &_x) {       _x = 0;       while (!isdigit(_ch)) _f |= (_ch == 45), _ch = getchar();       while (isdigit(_ch))         _x = (_x << 1) + (_x << 3) + (_ch ^ 48), _ch = getchar();       _f && (_x = -_x, _f = 0);       return *this;     }     fastin() { _ch = _f = 0; }   } fin;   }  // namespace imzzy   using namespace imzzy;   const int maxn = 1004, maxm = 500004;   int nxt[maxn], pre[maxn], p[5];   bool g1[maxn][maxn], g2[maxn][maxn];   std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > > ans1, ans2;   inline std::pair<std::pair<int, int>, std::pair<int, int> > rev(       int u, int v, int n, bool g[maxn][maxn]) {     int indx = 0;     for (register int i = 1; i <= n; ++i)       if (g[u][i] && g[v][i]) p[++indx] = i;     g[u][v] = g[v][u] = 0, g[p[1]][p[2]] = g[p[2]][p[1]] = 1;     return std::make_pair(std::make_pair(u, v), std::make_pair(p[1], p[2]));   }   inline void work(       int n, bool g[maxn][maxn],       std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > > &res) {     for (register int i = 2; i <= n; ++i) {       for (register int j = n; j > 1; --j) {         if (j == i || j == pre[i] || j == nxt[i]) continue;         if (g[i][j]) res.push_back(rev(i, j, n, g));       }     }   }   signed main() {     int n, u, v;     fin >> n;     for (register int i = 1; i <= n; ++i) pre[i] = i - 1, nxt[i] = i + 1;     pre[1] = n, nxt[n] = 1;     for (register int i = 1; i <= n; ++i)       g1[i][pre[i]] = g1[i][nxt[i]] = g2[i][pre[i]] = g2[i][nxt[i]] = 1;     for (register int i = 1; i <= n - 3; ++i)       fin >> u >> v, g1[u][v] = g1[v][u] = 1;     for (register int i = 1; i <= n - 3; ++i)       fin >> u >> v, g2[u][v] = g2[v][u] = 1;     work(n, g1, ans1), work(n, g2, ans2);     std::cout << ans1.size() + ans2.size() <<   n ;     for (register int i = 0; i < ans1.size(); ++i)       std::cout << ans1[i].first.first <<     << ans1[i].first.second <<   n ;     for (register int i = ans2.size() - 1; i >= 0; --i)       std::cout << ans2[i].second.first <<     << ans2[i].second.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, f;   char x;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> x;         if (x !=  B  && x !=  W  && x !=  G ) f = 1;       }     if (f == 0)       cout <<  #Black&White ;     else       cout <<  #Color ;   }
#include <bits/stdc++.h>   using namespace std;   struct Edge {     int u, v, w;     Edge() {}     Edge(int tu, int tv, int tw) : u(tu), v(tv), w(tw) {}     int operator<(const Edge e1) const { return w > e1.w; }   } p[100007];   int n, m;   struct uset {     int p[100007], sz[100007];     uset() {}     uset(int n) {       for (int i = 1; i <= n; i++) p[i] = i, sz[i] = 1;     }     int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }   } us;   double kruskal() {     us = uset(n);     sort(p, p + m);     long long ans = 0;     for (int i = 0; i < m; i++) {       int u = p[i].u, v = p[i].v;       int fx = us.find(u), fy = us.find(v);       long long s1 = us.sz[fx], s2 = us.sz[fy];       if (fx != fy) {         long long cur = (s1 + s2) * (s1 + s2 - 1) - s1 * (s1 - 1) - s2 * (s2 - 1);         ans += cur * (long long)p[i].w;         us.p[fx] = fy;         us.sz[fy] += us.sz[fx];       }     }     return double(ans) / n / (n - 1);   }   int main() {     int c[100007], u, v;     for (; cin >> n >> m;) {       for (int i = 1; i <= n; i++) scanf( %d , c + i);       for (int i = 0; i < m; i++) {         scanf( %d%d , &u, &v);         p[i] = Edge(u, v, min(c[u], c[v]));       }       printf( %.9lf n , kruskal());     }     return 0;   }
#include <bits/stdc++.h>   const int MOD = 1e9 + 7;   using namespace std;   signed main() {     long long t, n;     cin >> t >> n;     long long a[n];     set<long long> s;     long long c = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n - 1; i++) {       c += t - a[i];     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200100;   const int M = 1000100;   const long long mod = 998244353;   int main() {     ios::sync_with_stdio(false);     int q;     cin >> q;     while (q--) {       string s;       cin >> s;       int l = 0, r = 0, u = 0, d = 0;       for (int i = 0; i < s.length(); i++) {         if (s[i] ==  L ) l++;         if (s[i] ==  R ) r++;         if (s[i] ==  U ) u++;         if (s[i] ==  D ) d++;       }       int ss = 0;       int minl = min(l, r);       int okl = 0, oku = 0;       if (minl != 0) {         okl = 1;       }       ss += minl;       int minu = min(u, d);       if (minu != 0) {         oku = 1;       }       ss += minu;       if (okl && oku) {         cout << ss * 2 << endl;         for (int i = 1; i <= minl; i++) {           cout <<  L ;         }         for (int i = 1; i <= minu; i++) {           cout <<  U ;         }         for (int i = 1; i <= minl; i++) {           cout <<  R ;         }         for (int i = 1; i <= minu; i++) {           cout <<  D ;         }         cout << endl;       } else if (okl && !oku) {         cout << 2 << endl;         cout <<  LR  << endl;       } else if (!okl && oku) {         cout << 2 << endl;         cout <<  UD  << endl;       } else {         cout << 0 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t = 1;     while (t--) {       long long n, min, cnt = 0, x;       cin >> n;       vector<long long> v(n);       for (int i = 0; i < n; ++i) cin >> v[i];       min = *min_element(v.begin(), v.end());       for (int i = 0; i < n; ++i) {         if (min == v[i]) {           cnt++;           x = i;         }       }       if (cnt > 1)         cout <<  Still Rozdil  << endl;       else         cout << x + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       string a, b, c;       cin >> a >> b >> c;       bool ok = true;       for (int i = 0; i < a.size(); i++) {         ok &= a[i] == c[i] || b[i] == c[i];       }       cout << (ok ?  YES n  :  NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 4e5 + 5;   int fa[maxn];   int m, n, q, i, x, y;   int getfa(int x) {     if (x == fa[x]) return x;     return fa[x] = getfa(fa[x]);   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (i = 1; i <= m + n; i++) fa[i] = i;     for (i = 1; i <= q; i++) {       scanf( %d%d , &x, &y);       fa[getfa(x)] = getfa(y + n);     }     int num = 0;     for (i = 1; i <= m + n; i++) {       if (fa[i] == i) num++;     }     cout << num - 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int arr[300001];   bool check(int val) {     if (val < 0) return false;     if (val >= m - 1) return true;     int prev = 0;     for (int i = int(1); i <= int(n); i++) {       if (arr[i] + val < prev) return false;       int r = (arr[i] + val) % m;       if (r < arr[i]) {         if (r >= prev)           continue;         else           prev = (prev > arr[i] ? prev : arr[i]);       } else {         prev = (prev > arr[i] ? prev : arr[i]);       }     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = int(1); i <= int(n); i++) cin >> arr[i];     int l = 0, r = m - 1;     while (l <= r) {       int mid = (l + r) / 2;       if (check(mid) && (!check(mid - 1))) {         cout << mid;         return 0;       } else if (!check(mid))         l = mid + 1;       else         r = mid - 1;     }   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 100100;   const int INF = 0x7f7f7f7f;   const double eps = 1e-8;   const double pi = 3.1415926535897932384626433832795;   int main() {     int n;     ios::sync_with_stdio(0);     cin >> n;     cout << n * n / 4 << endl;     for (int i = 1; i <= n / 2; i++)       for (int j = n / 2 + 1; j <= n; j++) cout << i <<     << j << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void err(istream_iterator<string> it) { cerr << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<   ,  ;     err(++it, args...);   }   namespace fastIO {   bool IOerror = 0;   inline char nc() {     static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;     if (p1 == pend) {       p1 = buf;       pend = buf + fread(buf, 1, 100000, stdin);       if (pend == p1) {         IOerror = 1;         return -1;       }     }     return *p1++;   }   inline bool blank(char ch) {     return ch ==     || ch ==   n  || ch ==   r  || ch ==   t ;   }   inline void read(int &x) {     char ch;     while (blank(ch = nc()))       ;     if (IOerror) return;     for (x = ch -  0 ; (ch = nc()) >=  0  && ch <=  9 ; x = x * 10 + ch -  0 )       ;   }   }  // namespace fastIO   using namespace fastIO;   const double PI = acos(-1.0);   const double eps = 1e-8;   const int maxn = 2e6 + 7;   const long long mod = 1e9 + 7;   long long fac[maxn], finv[maxn];   long long qp(long long b, long long n) {     long long r = 1;     if (n <= 0) n += mod - 1;     b %= mod;     for (; n; n >>= 1, b = b * b % mod)       if (n & 1) r = r * b % mod;     return r;   }   long long pw[maxn];   void init() {     fac[1] = fac[0] = finv[0] = 1;     for (int i = 2; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;     finv[maxn - 1] = qp(fac[maxn - 1], mod - 2);     for (int i = maxn - 2; i >= 1; --i) finv[i] = finv[i + 1] * (i + 1) % mod;   }   long long C(int n, int m) {     return n >= m ? fac[n] * finv[n - m] % mod * finv[m] % mod : 0;   }   long long A(int n, int m) { return n >= m ? fac[n] * finv[n - m] % mod : 0; }   int main() {     int n, m, a, b;     cin >> n >> m >> a >> b;     init();     long long res = 0;     pw[0] = 1;     for (int i = 1; i < maxn; ++i) pw[i] = pw[i - 1] * m % mod;     for (int i = 0; i <= n - 2; ++i) {       long long tmp = A(n - 2, i) * C(m - 1, i) % mod * pw[n - 2 - i] % mod *                       (i + 2) % mod * qp(n, n - i - 3) % mod;       res = (res + tmp) % mod;     }     cout << res << endl;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:60000000 )   using namespace std;   const long double eps = 1e-9;   const int inf = (1 << 30) - 1;   const long long inf64 = ((long long)1 << 62) - 1;   const long double pi = 3.1415926535897932384626433832795;   template <class T>   T sqr(T x) {     return x * x;   }   int n, m, k;   vector<pair<int, int> > a;   vector<int> g[300500];   int u[300500];   vector<int> q;   void go(int v) {     u[v] = 1;     for (int i = 0; i < (int)(g[v].size()); i++)       if (u[g[v][i]] == 0)         go(g[v][i]);       else if (u[g[v][i]] == 1) {         cout << -1 << endl;         exit(0);       }     u[v] = 2;     q.push_back(v);   }   int main() {     cin >> n >> m;     k = m;     for (int i = 0; i < (int)(n); i++) {       a.clear();       for (int j = 0; j < (int)(m); j++) {         int x;         scanf( %d , &x);         if (x != -1) a.push_back(make_pair(x, j));       }       sort(a.begin(), a.end());       if (a.size() == 0) continue;       int l = 0;       int r = l;       while (r + 1 < (int)a.size() && a[r + 1].first == a[l].first) r++;       while (r + 1 < (int)a.size()) {         int l2 = r + 1;         int r2 = l2;         while (r2 + 1 < (int)a.size() && a[r2 + 1].first == a[l2].first) r2++;         for (int j = l; j <= r; j++) g[a[j].second].push_back(k);         for (int j = l2; j <= r2; j++) g[k].push_back(a[j].second);         k++;         l = l2;         r = r2;       }     }     memset(u, 0, sizeof(u));     q.clear();     for (int i = 0; i < (int)(m); i++)       if (!u[i]) go(i);     for (int i = (int)(q.size()) - 1; i >= 0; i--)       if (q[i] < m) printf( %d  , q[i] + 1);     cout << endl;     return 0;   }
#include <bits/stdc++.h>   inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   inline void sub(long long &a, long long b) {     a -= b;     if (a < 0) a += 1000000007;   }   inline void add(long long &a, long long b) {     a += b;     if (a >= 1000000007) a -= 1000000007;   }   template <typename T>   inline T const &MAX(T const &a, T const &b) {     return a > b ? a : b;   }   template <typename T>   inline T const &MIN(T const &a, T const &b) {     return a < b ? a : b;   }   inline long long qp(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % 1000000007;       a = a * a % 1000000007, b >>= 1;     }     return ans;   }   inline long long qp(long long a, long long b, long long c) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % c;       a = a * a % c, b >>= 1;     }     return ans;   }   using namespace std;   const unsigned long long ba = 233;   const double eps = 1e-5;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int N = 1000 + 10, maxn = 1000000 + 10, inf = 0x3f3f3f3f;   vector<long long> v;   int main() {     long long n;     scanf( %lld , &n);     if (n % 3 != 0) return 0 * puts( 0 );     n /= 3;     for (long long i = 1; i * i <= n; i++) {       if (n % i == 0) {         v.push_back(i);         if (i * i != n) v.push_back(n / i);       }     }     sort(v.begin(), v.end());     int ans = 0;     for (int i = 0; i < v.size() && v[i] * v[i] * v[i] <= n; i++) {       for (int j = i; j < v.size() && v[i] * v[j] * v[j] <= n; j++) {         long long x = v[i], y = v[j], z = n / v[i] / v[j], a, b, c;         if (z < y || x * y * z != n) continue;         if ((x - y + z) % 2 != 0) continue;         b = (x - y + z) / 2;         a = x - b;         c = z - b;         if (a > b || a > c || b > c || a <= 0 || b <= 0 || c <= 0) continue;         set<int> s;         s.insert(a), s.insert(b), s.insert(c);         if (s.size() == 3)           ans += 6;         else if (s.size() == 2)           ans += 3;         else           ans += 1;       }     }     printf( %d n , ans);     return 0;   }