malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> x[100000], G[100000];   int n, a[100000], col[100000], cnt, p[2001][1000];   long long ret = 1, ret2 = 0;   long long gcd(long long r, long long s) {     if (s == 0) return r;     return gcd(s, r % s);   }   void dfs(int pos) {     if (col[pos] >= 1) return;     col[pos] = cnt;     G[cnt].push_back(pos);     for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i]);   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       a[i]--;       x[i].push_back(a[i]);       x[a[i]].push_back(i);     }     for (int i = 0; i < n; i++) {       if (col[i] >= 1) continue;       cnt++;       dfs(i);     }     for (int i = 1; i <= cnt; i++) {       for (int j = 0; j <= 2000; j++) {         for (int k = 0; k < 1000; k++) p[j][k] = 0;       }       for (int j : G[i]) p[0][j] = j;       for (int j = 0; j < 2000; j++) {         for (int k : G[i]) {           p[j + 1][k] = a[p[j][k]];         }       }       long long cnt2 = 0, cnt3 = 0;       for (int j = 1; j <= 1000; j++) {         bool OK = true;         for (int k = 0; k < n; k++) {           if (p[j][k] != p[2 * j][k]) OK = false;         }         if (OK == true) {           if (cnt2 == 0)             cnt2 = j;           else {             cnt3 = j;             break;           }         }       }       ret = ret / gcd(ret, cnt3 - cnt2) * (cnt3 - cnt2);       ret2 = max(ret2, cnt2);     }     long long B = ret;     while (ret2 > B) B += ret;     cout << B << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int MAXN = 50 + 10;   template <typename T>   inline void add(T& a, T b) {     a += b;     if (a >= MOD) a -= MOD;   }   int main() {     static long long g[MAXN][MAXN];     static long long f[MAXN][MAXN];     static long long F[MAXN][MAXN];     static long long inv[MAXN];     ios::sync_with_stdio(0);     int n, m;     cin >> n >> m;     inv[0] = inv[1] = 1;     for (int i = 2; i <= n; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;     f[0][1] = 1;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= i + 1; ++j) {         for (int p = 0; p <= i - 1; ++p) {           for (int q = j; q <= p + 1; ++q)             add(g[i][j], f[p][q] * f[i - 1 - p][j] % MOD);           for (int q = j + 1; q <= i - p; ++q)             add(g[i][j], f[p][j] * f[i - 1 - p][q] % MOD);         }         memset(F, 0, sizeof(F));         for (int k = 0; k <= n; ++k) {           for (int p = 1; p <= k + 1; ++p) {             long long c = 1;             for (int q = 1; k + q * i <= n; ++q) {               c = c * (g[i][j] + q - 1) % MOD * inv[q] % MOD;               add(F[k + q * i][p + q * j], f[k][p] * c % MOD);             }           }         }         for (int k = 0; k <= n; ++k)           for (int p = 1; p <= k + 1; ++p) add(f[k][p], F[k][p]);       }     }     cout << f[n][m] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long n;     cin >> n;     string s1, s2;     cin >> s1 >> s2;     long long a = 0, b = 0, c = 0, d = 0;     vector<long long> a1, b1, c1, d1;     for (long long i = 0; i < n; ++i) {       if (s1[i] ==  1  && s2[i] ==  1 ) {         d++;         d1.push_back(i + 1);       }       if (s1[i] ==  1  && s2[i] ==  0 ) {         c++;         c1.push_back(i + 1);       }       if (s1[i] ==  0  && s2[i] ==  1 ) {         b++;         b1.push_back(i + 1);       }       if (s1[i] ==  0  && s2[i] ==  0 ) {         a++;         a1.push_back(i + 1);       }     }     long long x;     for (long long i = 0; i <= min(b, n / 2); ++i) {       for (long long j = 0; j <= min(c, n / 2 - i); ++j) {         if (j < b - i) {           x = b - i - j;           if (x > d || (d - x) % 2) continue;           x = x + (d - x) / 2;           if (x + i + j > n / 2 || (n / 2 - (x + i + j)) > a) continue;         } else {           x = j - b + i;           if (x > d || (d - x) % 2) continue;           x = (d - x) / 2;           if (x + i + j > n / 2 || (n / 2 - (x + i + j)) > a) continue;         }         for (long long u = 0; u < i; ++u) {           cout << b1[u] <<    ;         }         for (long long u = 0; u < j; ++u) {           cout << c1[u] <<    ;         }         for (long long u = 0; u < x; ++u) {           cout << d1[u] <<    ;         }         for (long long u = 0; u < n / 2 - i - j - x; ++u) {           cout << a1[u] <<    ;         }         return 0;       }     }     cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int n, m;   map<int, bool> ma, mb;   int a[maxn], b[maxn];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (ma[a[i]] == true) {         printf( 0 n );         return 0;       }       ma[a[i]] = true;     }     int ans = 3;     for (int i = 1; i <= n; i++) {       b[i] = (a[i] & m);       if (ma[b[i]] == true && a[i] != b[i]) {         ans = min(ans, 1);         break;       }       if (mb[b[i]] == true) {         ans = min(ans, 2);       }       mb[b[i]] = true;     }     if (ans == 3) ans = -1;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1600 + 5;   const int dr[] = {0, 0, 1, -1, 1, -1, 1, -1};   const int dc[] = {1, -1, 0, 0, 1, 1, -1, -1};   int n, m, nr, nc, cnt, ct;   bool grid[MAX][MAX], x[MAX][MAX], y[MAX][MAX], z[MAX][MAX], val;   vector<int> ans;   pair<int, int> cur;   bool inside(int r, int c) {     if (r > 0 && r <= n && c > 0 && c <= m) return 1;     return 0;   }   void dfs(int r, int c) {     grid[r][c] = 0;     x[r][c] = 1;     for (int i = 0; i <= 3; i++) {       nr = r + dr[i], nc = c + dc[i];       if (!grid[nr][nc]) continue;       dfs(nr, nc);     }   }   void cs() {     for (int r = 1; r <= n; r++)       for (int c = 1; c <= m; c++) {         if (!x[r][c]) continue;         if (!inside(r - 1, c - 1)) continue;         if (!inside(r + 1, c + 1)) continue;         val = 1;         for (int k = 0; k <= 7; k++)           if (!x[r + dr[k]][c + dc[k]]) {             val = 0;             break;           }         if (val) {           y[r][c] = 1;           for (int k = 0; k <= 7; k++) y[r + dr[k]][c + dc[k]] = 1;         }       }   }   void cas() {     for (int r = 1; r <= n; r++)       for (int c = 1; c <= m; c++) {         if (!x[r][c]) continue;         if (!inside(r - 2, c - 2)) continue;         if (!inside(r + 2, c + 2)) continue;         val = 1;         for (int i = r - 2; i <= r + 2; i++)           for (int j = c - 2; j <= c + 2; j++)             if (!x[i][j]) {               val = 0;               break;             }         if (val)           for (int i = r - 2; i <= r + 2; i++)             for (int j = c - 2; j <= c + 2; j++) z[i][j] = 1;       }     for (int r = 1; r <= n; r++)       for (int c = 1; c <= m; c++) z[r][c] ^= y[r][c];   }   void cast() {     for (int r = 1; r <= n; r++)       for (int c = 1; c <= m; c++) {         if (!z[r][c]) continue;         if (!inside(r - 1, c - 1)) continue;         if (!inside(r + 1, c + 1)) continue;         val = 1;         for (int k = 0; k <= 7; k++)           if (!z[r + dr[k]][c + dc[k]]) {             val = 0;             break;           }         y[r][c] = val;       }   }   void df(int r, int c) {     ct++;     y[r][c] = 0;     for (int i = 0; i <= 7; i++) {       nr = r + dr[i], nc = c + dc[i];       if (!y[nr][nc]) continue;       df(nr, nc);     }   }   void hit() {     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (!y[i][j]) continue;         df(i, j);         cnt++;       }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> grid[i][j];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         if (!grid[i][j]) continue;         memset(x, 0, sizeof x);         memset(y, 0, sizeof y);         memset(z, 0, sizeof z);         dfs(i, j);         cs();         cas();         memset(y, 0, sizeof y);         cast();         cnt = 0;         hit();         ans.push_back(cnt);       }     sort(ans.begin(), ans.end());     cout << ans.size() << endl;     for (auto i : ans) cout << i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200200], b[200200];   set<pair<long long, long long> > s;   set<pair<long long, long long> >::iterator it, it2;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n, i;     cin >> n;     for (i = 0; i < n; i++) cin >> a[i], s.insert({a[i], i});     for (it = s.begin(); it != s.end();) {       it2 = it;       it2++;       if (it2 == s.end()) break;       if ((*it).first == (*it2).first) {         s.insert({(*it).first * 2, (*it2).second});         s.erase(it2);         it2 = it;         it++;         s.erase(it2);       } else         it++;     }     for (auto x : s) {       b[x.second] = x.first;     }     cout << s.size() << endl;     for (i = 0; i < n; i++) {       if (b[i]) cout << b[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 101010 * 2;   int a[maxn], n, m;   int b[maxn];   int p[maxn];   int query(int poin, long long l, bool dir) {     int tv;     int cir;     int las;     if (dir) {       tv = upper_bound(b + 1, b + 1 + n, b[poin] + l) - b - 1;       if (tv == poin) return p[poin];       cir = l / (b[tv] - b[poin]);       las = l % (b[tv] - b[poin]);       if (cir & 1)         return query(tv, las, !dir);       else         return query(poin, las, dir);     } else {       tv = lower_bound(b + 1, b + 1 + n, b[poin] - l) - b;       if (tv == poin) return p[poin];       cir = l / (b[poin] - b[tv]);       las = l % (b[poin] - b[tv]);       if (cir & 1)         return query(tv, las, !dir);       else         return query(poin, las, dir);     }     return 0;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       b[i] = a[i];     }     sort(b + 1, b + 1 + n);     for (int i = 1; i <= n; i++) {       p[lower_bound(b + 1, b + 1 + n, a[i]) - b] = i;     }     while (m--) {       int poin, l;       scanf( %d%d , &poin, &l);       poin = lower_bound(b + 1, b + 1 + n, a[poin]) - b;       int tv = upper_bound(b + 1, b + 1 + n, b[poin] + l) - b - 1;       printf( %d n , query(tv, l - (b[tv] - b[poin]), 0));     }   }
#include <bits/stdc++.h>   using namespace std;   int64_t nearest_power_of_2(int64_t a) {     int cnt = 0;     while (a / 2 != 0) {       a = a / 2;       cnt++;     }     return cnt;   }   int main() {     int64_t t;     cin >> t;     for (int i = 0; i < t; i++) {       int64_t n;       cin >> n;       vector<int64_t> v;       for (int j = 0; j < n; j++) {         int64_t k;         cin >> k;         v.push_back(k);       }       int64_t max = 0;       int64_t b = 0;       for (int j = 0; j < n - 1; j++) {         if (v[j + 1] < v[j]) {           b++;           int64_t d = v[j] - v[j + 1];           if (max < nearest_power_of_2(d)) {             max = nearest_power_of_2(d);           }           v[j + 1] = v[j];         }       }       if (max == 0 && b == 0) {         cout << 0 << endl;       } else {         cout << max + 1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int maxn = 2000;   const int maxm = 1000 * 10;   struct edge {     int v, w, next;   } e[maxm * 2];   struct node {     int d, u;     bool operator<(const node &b) const { return d > b.d; }   };   int head[maxn], d[maxn], d2[maxn];   int tot;   bool vis[maxn];   int g[maxn][maxn];   void add(int u, int v, int w) {     e[tot].v = v;     e[tot].w = w;     e[tot].next = head[u];     head[u] = tot++;   }   void dijkstra(int s, int t, int n, bool dir) {     for (int i = 1; i <= n; i++) {       if (dir)         d[i] = INF;       else         d2[i] = INF;     }     if (dir)       d[s] = 0;     else       d2[s] = 0;     memset(vis, 0, sizeof(vis));     priority_queue<node> q;     q.push(node{0, s});     while (!q.empty()) {       node temp = q.top();       q.pop();       int u = temp.u;       if (vis[u]) continue;       vis[u] = 1;       for (int i = head[u]; i != -1; i = e[i].next) {         int v = e[i].v;         int w = e[i].w;         if (dir) {           if (d[v] > d[u] + w) {             d[v] = d[u] + w;             q.push(node{d[v], v});           }         } else {           if (d2[v] > d2[u] + w) {             d2[v] = d2[u] + w;             q.push(node{d2[v], v});           }         }       }     }   }   int main() {     int n, m, s, t, u, v;     cin >> n >> m >> s >> t;     memset(head, -1, sizeof(head));     for (int i = 0; i < m; i++) {       cin >> u >> v;       g[u][v] = 1;       g[v][u] = 1;       add(u, v, 1);       add(v, u, 1);     }     dijkstra(s, t, n, true);     dijkstra(t, s, n, false);     long long ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++)         if (!g[i][j] && i != j) {           if (d[i] + d2[j] + 1 >= d[t] && d2[i] + d[j] + 1 >= d[t]) {             ans++;             g[i][j] = g[j][i] = true;           }         }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long n, h, f[100], g[100][100];   long long fun(long long x) {     int i;     if (f[x] > -1) return 0;     f[x] = 0;     for (i = 0; i < x; ++i) {       fun(i);       fun(x - i - 1);       f[x] += f[i] * f[x - i - 1];     }     return 0;   }   long long rec(long long x, long long d) {     int i;     if (g[x][d] > -1) return 0;     g[x][d] = 0;     if (d > x) return 0;     if (d == 1) {       g[x][d] = f[x];       return 0;     }     for (i = 0; i < x; ++i) {       rec(i, d - 1);       rec(x - i - 1, d - 1);       g[x][d] += g[i][d - 1] * f[x - i - 1] + g[x - i - 1][d - 1] * f[i] -                  g[i][d - 1] * g[x - i - 1][d - 1];     }     return 0;   }   int main() {     int i, j;     cin >> n >> h;     for (i = 0; i <= n; ++i) f[i] = -1;     f[0] = 1;     for (i = 0; i <= n; ++i)       for (j = 0; j <= n; ++j) g[i][j] = -1;     g[0][0] = 1;     fun(n);     rec(n, h);     cout << g[n][h] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long r;     cin >> r;     if (r % 2 == 0 || r == 1 || r == 3)       cout <<  NO ;     else {       long long x, y;       long long up = (r - 1);       for (int i = 1; i < 100000; i++) {         if ((up / i - i - 1) % 2 == 0) {           x = i;           y = (up / i - i - 1) / 2;           break;         }       }       cout << x <<     << y;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   const long long N = 100011;   void solve() {     long long n, ans = 0;     cin >> n;     pair<long long, long long> a[n + 17];     multiset<long long> s;     for (long long i = 1; i <= n; i++) cin >> a[i].first;     for (long long i = 1; i <= n; i++) cin >> a[i].second;     sort(a + 1, a + n + 1);     long long sum = 0;     long long mn = 0;     a[n + 1].first = -1;     for (long long ind = 1; ind <= n; ind++) {       mn += 1;       if (s.empty()) mn = a[ind].first;       long long j = ind;       while (a[j].first == mn) {         s.insert(a[j].second);         sum += a[j].second;         j += 1;       }       long long mx = *(--s.end());       sum -= mx;       s.erase(s.find(mx));       ans += sum;       ind = j - 1;     }     while (s.size()) {       int mx = *(--s.end());       sum -= mx;       s.erase(s.find(mx));       ans += sum;     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, c = 0;     string s;     cin >> n >> a >> b >> s;     bool turnA;     if (a > b)       turnA = true;     else       turnA = false;     for (int i = 0; i < s.size(); ++i) {       if (s[i] ==  . ) {         if ((i == 0 || s[i - 1] ==  * ) && a > b) {           s[i] =  a ;           c++;           a--;           turnA = false;         } else if ((i == 0 || s[i - 1] ==  * ) && a < b) {           s[i] =  b ;           c++;           b--;           turnA = true;         } else if (turnA && a > 0) {           s[i] =  a ;           c++;           a--;           turnA = false;         } else if (!turnA && b > 0) {           c++;           b--;           s[i] =  b ;           turnA = true;         } else           turnA = !turnA;       }     }     cout << c << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;      int main(){    long long int t,a1,b1,f1,a2,b2,f2,x;    cin>>t;    while(t--){     x=0;     cin>>a1>>a2>>b1>>b2>>f1>>f2;     if((a1==f1 && a2==f2) || (b1==f1 && b2==f2)){   //   cout<< a ;      cout<<0;      continue;     }     if(a1<b1)swap(a1,b1);     if(a2<b2)swap(a2,b2);     if(a1==b1 && b1==f1 ){      if(a2>f2 && f2>b2)x+=2;      x+=a2-b2;   //   cout<< b ;     }     else if(a2==b2 && b2==f2){      if(a1>f1 && f1>b1)x+=2;      x+=a1-b1;   //   cout<< c ;     } else {      x=a1+a2-b1-b2;   //   cout<< d ;     }     cout<<x<<endl;         }        return 0;   }
#include <bits/stdc++.h>   const int maxn = 5e5 + 5;   int fa[maxn], t[maxn], n, m, k, v, u, ev, eu;   int find(int n) { return n == fa[n] ? n : (fa[n] = find(fa[n])); }   void merge(int u, int v) {     ev = find(v);     eu = find(u);     if (ev != eu) {       fa[ev] = eu;       t[eu] += t[ev];     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) fa[i] = i, t[i] = 1;     for (int i = 0; i < m; ++i) {       scanf( %d , &k);       if (k) scanf( %d , &u);       for (int j = 0; j < k - 1; ++j) {         scanf( %d , &v);         merge(u, v);       }     }     for (int i = 1; i <= n; ++i) printf( %d  , t[find(i)]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   const int inf = 0x3f3f3f3f, N = 2e5 + 10;   const double pi = acos(-1);   using namespace std;   char s[N];   int num[N];   int main() {     int n, k;     while (cin >> n >> k) {       scanf( %s , s + 1);       memset(num, 0, sizeof(num));       for (int i = 1; s[i]; i++) {         if (s[i] ==  0 )           num[i] = num[i - 1] + 1;         else           num[i] = num[i - 1];       }       int ans = inf;       int last = 0;       if (k == 1) {         for (int i = 1; i <= n; i++) {           if (!last && s[i] ==  0 )             last = i;           else if (last && s[i] ==  0 ) {             ans = i - last;             break;           }         }       }       for (int i = 1; i <= n; i++) {         if (s[i] ==  1 ) continue;         int l = 1, r = n;         while (l <= r) {           int mid = (l + r) >> 1;           int st = max(1, i - mid);           int en = min(n, i + mid);           if (num[en] - num[st - 1] >= k + 1)             r = mid - 1;           else             l = mid + 1;         }         ans = min(ans, l);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10;   long long a[MAXN];   long long b[MAXN];   int n, m;   long long c2(long long x) { return (x * (x - 1)) / 2; }   long long f(int l) {     if (m < l * n) {       return -1;     }     for (int i = 1; i <= n; i++) {       if (a[i] < i * l + n * c2(l)) {         return -1;       }       b[i] = a[i] - (i * l + n * c2(l));     }     long long res = 0, f = m;     for (int i = l; i >= 1; i--) {       for (int j = n; j >= 1; j--) {         b[j] += j + (i - 1) * n;         if (b[j] >= f) {           res += f;           b[j] -= f;           f--;         } else {           res += b[j];           f = b[j] - 1;           b[j] = 0;         }       }     }     return res;   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     int L = 1, R = (m / n) + 1;     while (R - L > 5) {       int mid = (L + R) / 2;       if (f(mid) < f(mid + 1)) {         L = mid;       } else {         R = mid;       }     }     long long res = 0;     for (int i = L; i <= R; i++) {       res = max(res, f(i));     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long n, r;       cin >> n >> r;       long long int sum = 0;       if (n == 1) {         sum = 1;       } else if (n <= r) {         sum = ((n - 1) * (n)) / 2 + 1;       } else {         sum = (r * (r + 1)) / 2;       }       cout << sum << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, q, x, y, ans;   int main() {     cin >> n >> q;     while (q--) {       cin >> x >> y;       ans = 0;       if ((x & 1) == (y & 1)) {         ans += (x - 1) / 2 * n;         x = x % 2;         if (x)           ans += (y + 1) / 2;         else           ans += (y / 2) + (n / 2) + (n & 1);       } else {         ans += (n * n / 2) + (n & 1) + (x - 1) / 2 * n;         x = x % 2;         if (x)           ans += y / 2;         else           ans += (n / 2) + (y + 1) / 2;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, p, q, r;     cin >> n >> p >> q >> r;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     long long dp[n][3];     dp[0][0] = 1ll * p * a[0];     for (int i = 1; i < n; i++) {       dp[i][0] = max(dp[i - 1][0], 1ll * p * a[i]);     }     dp[0][1] = dp[0][0] + 1ll * q * a[0];     for (int i = 1; i < n; i++) {       dp[i][1] = max(dp[i - 1][1], dp[i][0] + 1ll * q * a[i]);     }     dp[0][2] = dp[0][1] + 1ll * r * a[0];     for (int i = 1; i < n; i++) {       dp[i][2] = max(dp[i - 1][2], dp[i][1] + 1ll * r * a[i]);     }     cout << dp[n - 1][2] <<   n ;   }