malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m;   int l[5005], r[5005], v[105][105], t[105][105];   double res[105], c[5005], f[105][105], cc[105][105];   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int a, b, x;       scanf( %d%d%d , &a, &b, &x);       l[i] = (--a);       r[i] = (--b);       c[i] = x;       v[a][b] = (v[a][b] == 0) ? x : min(v[a][b], x);       t[a][b]++;       t[b][a]++;     }     int k = n - 2;     for (int i = 1; i <= k; i++) {       for (int j = 0; j < n; j++) {         f[i][i] += t[j][i];         f[i][j] -= t[j][i];       }       f[i][n - 1] = -f[i][0];     }     for (int i = 1; i <= k; i++) {       int t = i;       while (!f[t][i] && t <= k) t++;       if (t > k) continue;       for (int j = i; j <= k + 1; j++) swap(f[i][j], f[t][j]);       for (int j = 1; j <= k; j++) {         if (j != i) {           double tt = f[j][i] / f[i][i];           for (int x = 1; x <= k + 1; x++) f[j][x] -= tt * f[i][x];         }       }     }     for (int i = 1; i <= k; i++) {       if (f[i][i] == 0) continue;       double x = f[i][i];       for (int j = 1; j <= k + 1; j++) f[i][j] /= x;       res[i] = f[i][k + 1];     }     res[0] = 1;     double mn = 1e9 + 7;     for (int i = 0; i < m; i++) {       double x = fabs(res[l[i]] - res[r[i]]);       if (x < 1e-10) continue;       mn = min(mn, c[i] / x);     }     double ans = 0;     for (int i = 0; i < m; i++) cc[l[i]][r[i]] = mn * (res[l[i]] - res[r[i]]);     for (int i = 0; i < m; i++) {       if (l[i] == 0) ans += cc[l[i]][r[i]];       if (r[i] == 0) ans -= cc[l[i]][r[i]];     }     printf( %.5lf n , ans);     for (int i = 0; i < m; i++) printf( %.5lf n , cc[l[i]][r[i]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1000000000000000;   const int mod = 1000000007;   int n, m, k;   int s[1000010];   long long a[1000010];   bool pos[1000010];   int lst[1000010];   long long get(int l) {     int r = 0;     int i = -1;     long long res = 0;     while (r < n) {       if (lst[r] <= i) {         return inf;       }       i = lst[r];       r = lst[r] + l;       ++res;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       cin >> s[i];     }     for (int i = 0; i < k; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       pos[i] = true;     }     for (int i = 0; i < m; i++) {       pos[s[i]] = false;     }     for (int i = 0; i < n; i++) {       if (pos[i]) {         lst[i] = i;       } else if (i) {         lst[i] = lst[i - 1];       } else         lst[i] = -1;     }     long long ans = inf;     for (int i = 0; i < k; i++) {       long long t = get(i + 1);       if (t != inf) {         ans = min(ans, a[i] * t);       }     }     if (ans == inf) {       ans = -1;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Pow10(int deg) {     int res = 1;     while (deg-- > 0) res *= 10;     return res;   }   int ToInt(const string& from) {     int res = 0;     for (int i = 0; i < ((int)(from).size()); ++i) res = 10 * res + from[i] -  0 ;     return res;   }   void Solve() {     string buf;     do {       getline(cin, buf);     } while (((int)(buf).size()) < 4);     string year = buf.substr(4);     int lo = 1988;     for (int i = ((int)(year).size()) - 1; i >= 0; --i) {       int add = Pow10(((int)(year).size()) - i);       int base = lo / add;       int rem = ToInt(year.substr(i));       while (base * add + rem <= lo) ++base;       lo = base * add + rem;     }     cout << lo <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     int q;     cin >> q;     while (q-- > 0) Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 1e5 + 1, mod = 1000000007;   vector<long long int> adj[N];   signed main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long int pro = 1, temp, t, n, i, m, k, j, l, r, mid, x, y, z, rem,                   carry = 0, ind, ans = 0, mx = -LONG_LONG_MAX,                   mn = LONG_LONG_MAX, cnt = 0, curr = 0, prev, sum = 0, flag = 0,                   i1 = -1, i2 = -1;     cin >> n >> m;     for (i = 1; i <= m; i++) {       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     if (n < 2 || m >= (n * (n - 1)) / 2) {       return cout <<  NO , 0;     }     cout <<  YES n ;     long long int a[n + 1], b[n + 1];     for (i = 1; i <= n; i++) {       b[i] = 1;     }     curr = 2;     for (i = 1; i <= n; i++) {       flag = 0;       for (auto it : adj[i]) {         if (b[it] == b[i]) {           flag = 1;           b[it] = curr;         }       }       if (flag) {         curr++;       }     }     vector<pair<long long int, long long int> > v;     v.push_back({-1, 0});     for (i = 1; i <= n; i++) {       v.push_back({b[i], i});     }     sort(v.begin(), v.end());     for (i = 1; i <= n; i++) {       a[v[i].second] = i;     }     for (i = 1; i <= n; i++) {       cout << a[i] <<    ;     }     cout << endl;     for (i = 1; i <= n; i++) {       cout << b[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimization( O3 )   using namespace std;   template <typename T>   inline void Cin(T& first) {     char c;     T sign = 1;     first = 0;     for (c = getchar(); c <  0  || c >  9 ; c = getchar())       if (c ==  - ) sign = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) first = first * 10 + c -  0 ;     first *= sign;   }   template <typename T>   inline void Out(T first) {     if (first > 9) Out(first / 10);     putchar(first % 10 +  0 );   }   template <typename T>   inline void Cout(T first, char c) {     if (first < 0) putchar( - );     first = abs(first);     Out(first);     putchar(c);   }   template <typename T, typename... Args>   inline void Cin(T& a, Args&... args) {     Cin(a);     Cin(args...);   }   template <typename T, typename... Args>   inline void Cout(T a, char c, Args... args) {     Cout(a, c);     Cout(args...);   }   const int N = 107;   const long double eps = 1e-8;   const long double e = 2.7182818284590452353602874713527;   int n, k, first[N], second[N];   long double low, high, mid, s, w, p[N], f[N][N];   void Enter() {     cin >> n >> k >> w;     w = 1 - w / 1000;     for (int i = 0; i <= n; ++i) cin >> first[i] >> second[i];   }   int SqrDis(int i) {     return (first[i] - first[0]) * (first[i] - first[0]) +            (second[i] - second[0]) * (second[i] - second[0]);   }   bool Check() {     for (int i = 1; i <= n; ++i) {       if ((long double)SqrDis(i) <= mid * mid)         p[i] = 1;       else         p[i] = pow(e, (1 - (long double)SqrDis(i) / (mid * mid)));     }     memset(&f, 0, sizeof f);     f[1][1] = p[1];     f[1][0] = 1 - p[1];     for (int i = 2; i <= n; ++i) {       f[i][0] = f[i - 1][0] * (1 - p[i]);       f[i][i] = f[i - 1][i - 1] * p[i];       for (int j = 1; j < i; ++j)         f[i][j] = f[i - 1][j - 1] * p[i] + f[i - 1][j] * (1 - p[i]);     }     s = 0;     for (int i = k; i <= n; ++i) s += f[n][i];     return s >= w;   }   void Solve() {     low = eps, high = 5000;     while (low + eps <= high) {       mid = (low + high) / 2.0;       if (Check())         high = mid - eps;       else         low = mid + eps;     }     cout << fixed << setprecision(9) << low;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( test                 .inp ,                r )) {       freopen(            test             .inp ,            r , stdin);       freopen(            test             .out ,            w , stdout);     }     Enter(), Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void maxtt(T& t1, T t2) {     t1 = max(t1, t2);   }   template <typename T>   void mintt(T& t1, T t2) {     t1 = min(t1, t2);   }   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  URDL ;   const long long MOD2 = (long long)998244353 * (long long)998244353;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int& x, int y, int mod = 998244353) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et(int x = -1) {     printf( %d n , x);     exit(0);   }   long long fastPow(long long x, long long y, int mod = 998244353) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }   pair<pair<int, int>, int> p[100035][4];   void cal(set<pair<pair<int, int>, int> >* S) {     n = (int)S[0].size();     if (n == 1) return;     set<pair<pair<int, int>, int> >::iterator it[4];     vector<int> vp(5, -(1 << 30));     for (int(j) = 0; (j) < (int)(4); (j)++) it[j] = S[j].begin();     for (int(cnt) = 1; (cnt) <= (int)(n); (cnt)++) {       for (int(j) = 0; (j) < (int)(4); (j)++)         maxtt(vp[j], (it[j]++)->first.second);       for (int(j) = 0; (j) < (int)(4); (j)++)         if (vp[j] <= it[j]->first.first) {           set<pair<pair<int, int>, int> > T[4];           auto it = S[j].begin();           for (int(i) = 0; (i) < (int)(cnt); (i)++) {             int id = it->second;             it++;             for (int(j) = 0; (j) < (int)(4); (j)++) {               T[j].insert(p[id][j]);               S[j].erase(p[id][j]);             }           }           cal(S);           cal(T);           return;         }     }     etp();   }   void fmain(int tid) {     scanf( %d , &n);     for (int(i) = 1; (i) <= (int)(n); (i)++) {       int a, b, c, d;       scanf( %d%d%d%d , &a, &b, &c, &d);       p[i][0] = {{a, c}, i};       p[i][1] = {{b, d}, i};       p[i][2] = {{-c, -a}, i};       p[i][3] = {{-d, -b}, i};     }     set<pair<pair<int, int>, int> > s[4];     for (int(i) = 1; (i) <= (int)(n); (i)++)       for (int(j) = 0; (j) < (int)(4); (j)++) s[j].insert(p[i][j]);     cal(s);     etp(1);   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int OHT = 100100;   const int MAXINF = (2 << 26);   const int MININF = (~(2 << 26));   int vis1[110], vis2[110];   int main() {     int n, m, i, j;     cin >> n >> m;     vector<pair<int, int> > v;     for (i = 2; i <= n; i++) v.push_back(make_pair(i, 1));     for (j = 1; j <= m; j++) v.push_back(make_pair(1, j));     cout << v.size() << endl;     for (i = 0; i < v.size(); i++)       cout << v[i].first <<     << v[i].second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   long long POW(long long a, long long b, long long MMM = MOD) {     long long ret = 1;     for (; b; b >>= 1, a = (a * a) % MMM)       if (b & 1) ret = (ret * a) % MMM;     return ret;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) {     if (a == 0 || b == 0) return a + b;     return a * (b / gcd(a, b));   }   int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};   int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};   tuple<int, int, int, int> query[100000];   int ans[100000];   map<int, vector<tuple<int, int, int> > > M;   int cc;   void upd(int i, vector<int>& tree, int k) {     int n = tree.size();     while (i < n) {       tree[i] += k;       i += (i & -i);     }   }   int sum(int i, vector<int>& tree) {     int c = 0;     while (i > 0) {       c += tree[i];       i -= (i & -i);     }     return c;   }   int main() {     int n;     scanf( %d , &n);     for (int(i) = (0); (i) <= (n - 1); (i) += (1)) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       if (x == 3)         M[z].push_back(tuple<int, int, int>(x, y, cc++));       else         M[z].push_back(tuple<int, int, int>(x, y, -1));     }     for (auto it = M.begin(); it != M.end(); it++) {       vector<tuple<int, int, int> > v = it->second;       int N = v.size();       vector<int> vv;       for (int(i) = (0); (i) <= (N - 1); (i) += (1)) vv.push_back(get<1>(v[i]));       sort(vv.begin(), vv.end());       vv.resize(unique(vv.begin(), vv.end()) - vv.begin());       for (int(i) = (0); (i) <= (N - 1); (i) += (1))         get<1>(v[i]) =             lower_bound(vv.begin(), vv.end(), get<1>(v[i])) - vv.begin();       vector<int> tree(N + 5, 0);       for (int(i) = (0); (i) <= (N - 1); (i) += (1)) {         int x, y, z;         tie(x, y, z) = v[i];         if (x == 1)           upd(y + 1, tree, 1);         else if (x == 2)           upd(y + 1, tree, -1);         else           ans[z] = sum(y + 1, tree);       }     }     for (int(i) = (0); (i) <= (cc - 1); (i) += (1)) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string n;     int index = 0;     cin >> n;     int l = n.length();     for (int i = l - 1; i > -1; i--) {       if (n[i] ==  4 )         index += pow(2, (l - 1 - i));       else         index += 2 * pow(2, (l - 1 - i));     }     cout << index << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 113;   int add(int x, int y) {     x += y;     if (x >= 1000000007) x -= 1000000007;     return x;   }   int sub(int x, int y) {     if (x < y) x += 1000000007;     x -= y;     return x;   }   int mul(int x, int y) { return (long long)x * y % 1000000007; }   int qpow(int x, int y, int p = 1000000007) {     int res = 1;     while (y) {       if (y & 1) res = mul(res, x);       x = mul(x, x);       y >>= 1;     }     return res;   }   vector<int> G[N];   int f[N][N][N], g[N], h[N], d[N][N], sz[N];   void dfs(int x, int fa) {     f[x][1][0] = 1;     sz[x] = 1;     for (int j = 0; j < G[x].size(); j++)       if (G[x][j] != fa) {         int v = G[x][j];         dfs(v, x);         memset(d, 0, sizeof d);         for (int xsz = sz[x]; xsz >= 1; xsz--) {           for (int xedges = sz[x]; xedges >= 0; xedges--) {             if (f[x][xsz][xedges]) {               for (int sonedges = sz[v]; sonedges >= 0; sonedges--) {                 for (int sonsz = sz[v]; sonsz >= 1; sonsz--)                   if (f[v][sonsz][sonedges]) {                     d[xsz][xedges + sonedges] =                         add(d[xsz][xedges + sonedges],                             mul(f[x][xsz][xedges], f[v][sonsz][sonedges]));                     d[xsz + sonsz][xedges + sonedges + 1] =                         add(d[xsz + sonsz][xedges + sonedges + 1],                             mul(mul(f[x][xsz][xedges], f[v][sonsz][sonedges]),                                 mul(qpow(mul(xsz, sonsz), 1000000007 - 2),                                     xsz + sonsz)));                   }               }             }           }         }         memcpy(f[x], d, sizeof f[x]);         sz[x] += sz[v];       }   }   int n;   int binom[N][N];   int main() {     binom[0][0] = 1;     for (int i = 1; i < N; i++) {       binom[i][0] = 1;       for (int j = 1; j <= i; j++) {         binom[i][j] = add(binom[i - 1][j], binom[i - 1][j - 1]);       }     }     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }     dfs(1, 0);     for (int num = 0; num < n; num++) {       for (int sz = 1; sz <= n; sz++) {         g[num] = add(g[num], f[1][sz][num]);       }       g[num] = mul(g[num], qpow(n, 1000000007 - 1 + n - num - 2));     }     for (int num = n - 1; num >= 0; num--) {       for (int _num = num; _num < n; _num++) {         h[num] = add(h[num], (_num - num) & 1                                  ? 1000000007 - mul(binom[_num][num], g[_num])                                  : mul(binom[_num][num], g[_num]));       }     }     for (int i = 0; i < n; i++) printf( %d  , h[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int res = 0, p = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) p = -1;       ch = getchar();     }     while (isdigit(ch)) res = res * 10 + ch -  0 , ch = getchar();     return res * p;   }   const int mod = 1e9 + 7;   int t;   int main() {     t = read();     while (t--) {       long long n = read() * 2;       long long x = 1;       for (int i = 3; i <= n; ++i) {         x = (x * i) % mod;       }       printf( %d n , x);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p, flag;   char s[1111];   int a[1111];   void dfs(int x) {     if (!x) {       flag = 0;       return;     }     while (1) {       a[x]++;       if (a[x] > p) {         dfs(x - 1);         a[x] = 0;         continue;       }       if (!(x > 1 && a[x] == a[x - 1] || x > 2 && a[x] == a[x - 2])) break;     }     if (x == n)       for (int i = 0; i < n; i++) s[i] = a[i + 1] - 1 +  a ;   }   int main() {     cin >> n >> p;     gets(s);     gets(s);     for (int i = 0; i < n; i++) a[i + 1] = s[i] -  a  + 1;     flag = 1;     dfs(n);     if (flag)       puts(s);     else       puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 998244353;   long long powmod(long long a, long long b) {     long long r = 1;     while (b) {       if (b & 1) r = (r * a) % mod;       a = (a * a) % mod, b >>= 1;     }     return r;   }   long long modd(long long a, long long b) { return ((a % b) + b) % b; }   long long extendedEuclid(long long a, long long b, long long& x, long long& y) {     long long xx = y = 0, yy = x = 1, t;     while (b) {       long long q = a / b;       a %= b;       swap(a, b);       t = xx;       xx = x - q * xx;       x = t;       t = yy;       yy = y - q * yy;       y = t;     }     return a;   }   long long modularInverse(long long a) {     long long x, y, d = extendedEuclid(a, mod, x, y);     if (d > 1) return -1;     return modd(x, mod);   }   long long f[300000], fi[300000];   long long binom(long long a, long long b) {     return (((f[a] * fi[a - b]) % mod) * fi[b]) % mod;   }   int n, k, h[300000];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout << fixed << setprecision(10);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> h[i];     f[0] = 1;     fi[0] = 1;     for (int i = 1; i <= n; i++)       f[i] = (f[i - 1] * i) % mod, fi[i] = modularInverse(f[i]);     int c = 0;     for (int i = 0; i < n; i++) c += h[i] != h[(i + 1) % n];     long long r = 0;     for (int s = 1; s <= c; s++) {       long long h = powmod(2, s);       if ((s & 1) == 0) h = (h + mod - binom(s, s / 2)) % mod;       h = (h * fi[2]) % mod;       h = (h * binom(c, s)) % mod;       r = (r + h * powmod(k - 2, c - s)) % mod;     }     r = (r * powmod(k, n - c)) % mod;     cout << r <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, b, cnt[105] = {0};     cin >> n;     vector<int> a;     for (int i = 0; i < n; i++) {       cin >> b;       a.push_back(b);       cnt[a[i]] = cnt[a[i]] + 1;     }     int y = 0;     int x;     x = *max_element(a.begin(), a.end());     for (int i = 0; i <= x; i++) {       if (cnt[i] >= y) {         y = cnt[i];       }     }     cout << y << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   inline bool chkmax(T& a, U b) {     return (a < b) ? (a = b, true) : false;   }   template <class T, class U>   inline bool chkmin(T& a, U b) {     return (a > b) ? (a = b, true) : false;   }   template <class T>   inline vector<T> uniq(vector<T> vec) {     sort((vec).begin(), (vec).end()),         vec.erase(unique((vec).begin(), (vec).end()), end(vec));     return vec;   }   void solve();   int main(int argc, char** argv) {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cout.setf(ios_base::fixed), cout.precision(10);     solve();     double times = (clock() * 1.0 / CLOCKS_PER_SEC);     do {     } while (0);   }   template <int NV>   class undirectedEulerPath {    public:     vector<int> path;     multiset<int> G[NV];     void addedge(int u, int v) { G[u].insert(v), G[v].insert(u); }     void dfs(int cur) {       while (!G[cur].empty()) {         int tar = *G[cur].begin();         G[cur].erase(G[cur].begin());         G[tar].erase(G[tar].find(cur));         dfs(tar);       }       path.push_back(cur);     }     bool get() {       int src = -1, odd = 0, tot = 0;       for (int i = 0; i < NV; i++) {         tot += G[i].size();         if (G[i].size() % 2 == 1) {           odd++, src = (~src) ? src : i;         }       }       if (odd != 0 && odd != 2) return false;       dfs(odd ? src : 0);       reverse(path.begin(), path.end());       return (int)path.size() == tot / 2 + 1;     }   };   undirectedEulerPath<202020> solver;   void solve() {     int n;     cin >> n;     vector<int> b(n - 1), c(n - 1);     for (int i = 0; i < n - 1; i++) cin >> b[i];     for (int i = 0; i < n - 1; i++) cin >> c[i];     for (int i = 0; i < n - 1; i++) {       if (b[i] > c[i]) do {           cout << ( -1 ) <<   n ;           return;         } while (0);     }     vector<int> index;     for (int i = 0; i < n - 1; i++) {       index.push_back(b[i]), index.push_back(c[i]);     }     index = uniq(index);     for (int i = 0; i < n - 1; i++) {       b[i] = lower_bound((index).begin(), (index).end(), b[i]) - index.begin();       c[i] = lower_bound((index).begin(), (index).end(), c[i]) - index.begin();       solver.addedge(b[i], c[i]);     }     if (solver.get()) {       for (auto& x : solver.path) cout << index[x] <<    ;     } else {       do {         cout << ( -1 ) <<   n ;         return;       } while (0);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, k, d[2000], s[2000], n = 0, big = 0, ans = 0;     cin >> m >> k;     for (int i = 0; i < m; i++) cin >> d[i];     for (int i = 0; i < m; i++) cin >> s[i];     for (int i = 0; i < m; i++) {       n += s[i];       if (s[i] > big) big = s[i];       while (n < d[i]) {         n += big;         ans += k;       }       n -= d[i];       ans += d[i];     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void rd(T &x) {     x = 0;     int f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       x = (x << 3) + (x << 1) + ch -  0 , ch = getchar();     x *= f;   }   const long long inf = 1e16;   const int maxn = 505;   int n;   long long f[maxn][maxn];   int nxt(int a, int b) {     int c = a + b;     if (c > n)       return c % n;     else       return c;   }   long long dfs(int l, int r) {     if (nxt(l, 1) == r) return 0;     if (f[l][r]) return f[l][r];     if (nxt(l, 2) == r) return l * nxt(l, 1) * nxt(l, 2);     long long res = inf;     int u = nxt(l, 1);     while (u != r) {       res = min(res, l * r * u + dfs(l, u) + dfs(u, r));       u = nxt(u, 1);     }     return f[l][r] = res;   }   int main() {     rd(n);     printf( %lld n , dfs(1, n));     return 0;   }