malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int N = 1e6 + 5;   inline int readint() {     char c = getchar();     int ans = 0;     while (c <  0  || c >  9 ) {       c = getchar();     }     while (c >=  0  && c <=  9 ) {       ans = ans * 10 + c -  0 , c = getchar();     }     return ans;   }   vector<int> tree[N];   bool check[N];   int father[N][21];   int deep[N];   void dfs(int x, int level) {     for (int i = 0; father[father[x][i]][i]; i++) {       father[x][i + 1] = father[father[x][i]][i];     }     deep[x] = level;     for (int i = 0; i < tree[x].size(); i++) {       int to = tree[x][i];       if (to == father[x][0]) {         continue;       }       father[to][0] = x;       dfs(to, level + 1);     }   }   int main() {     int n, k;     n = readint(), k = readint();     int u, v;     for (int i = 1; i < n; i++) {       u = readint(), v = readint();       tree[u].push_back(v);       tree[v].push_back(u);     }     k = n - k;     k--, check[n] = 1;     dfs(n, 1);     for (int i = n - 1; i >= 1 && k; i--) {       int aim = -1;       int now = i;       if (check[i]) {         continue;       }       for (int j = 20; j >= 0; j--) {         if (father[now][j] == 0 || check[father[now][j]]) {           continue;         }         now = father[now][j];       }       if (deep[i] - deep[now] + 1 <= k) {         now = i;         while (now != 0 && !check[now]) {           check[now] = 1;           k--;           now = father[now][0];         }       }     }     for (int i = 1; i <= n - 1; i++) {       if (!check[i]) {         cout << i <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   const int32_t mod = 1e9 + 7;   using namespace std;   unordered_map<long long, long long> mp;   void fun(vector<long long>& v, long long idx, long long sum) {     if (idx == (long long)v.size()) {       mp[sum]++;       return;     }     fun(v, idx + 1, sum);     fun(v, idx + 1, sum - v[idx]);     fun(v, idx + 1, sum + v[idx]);   }   void solve(long long test) {     long long n;     cin >> n;     mp.clear();     vector<long long> v(n);     for (long long i = 0; i < n; i++) {       cin >> v[i];     }     fun(v, 0, 0);     if (mp[0] > 1)       cout <<  YES             <<   n ;     else       cout <<  NO             <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     cin >> t;     long long i = 1;     while (i <= t) {       solve(i);       i++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     list<int> L;     int N, M;     cin >> N >> M;     set<pair<int, int> > S;     for (int i = 0; i < M; ++i) {       int u, v;       cin >> u >> v;       S.insert(pair<int, int>(u, v));     }     L.push_back(1);     for (int i = 2; i <= N; ++i) {       list<int>::iterator it = L.begin();       while (it != L.end() && S.count(pair<int, int>(i, *it))) it++;       L.insert(it, i);     }     for (list<int>::iterator it = L.begin(); it != L.end(); ++it) {       cout << *it <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, ans = 0, n, k, a[100000];     scanf( %d%d , &n, &k);     for (i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     for (i = 0; i < k && a[i] < 0; ++i) a[i] *= -1;     if (i < k) {       sort(a, a + n);       k -= i;       if (k & 1) {         a[0] *= -1;       }     }     for (j = 0; j < n; ++j) {       ans += a[j];     }     printf(  n%d , ans);     return 0;   }
#include <bits/stdc++.h>      using namespace std;      typedef long long ll;      const ll DIM = 1e6 + 7;   const ll INF = 1e16 + 7;   const ll MODULO = 1e9 + 7;      ll n,m,nt,k,q;      ll val,val1,last,res,c0,c1,c2;      int main()   {       ios_base::sync_with_stdio();       cin.tie();       cout.tie();          cin>>nt;       for(int t=1; t<=nt; t++)       {              cin>>n;              res=0;           c0=0;           c1=0;           c2=0;              for(int i=1; i<=n; i++)           {               cin>>val;                  if(val%3==0)c0++;               else if(val%3==1)c1++;               else c2++;           }              for(int i=1; i<=2; i++)           {                  if(c0>n/3)               {                   val=c0-n/3;                   res+=val;                   c1+=val;                   c0-=val;               }                  if(c1>n/3)               {                   val=c1-n/3;                   res+=val;                   c2+=val;                   c1-=val;               }                  if(c2>n/3)               {                   val=c2-n/3;                   res+=val;                   c0+=val;                   c2-=val;               }           }              cout<<res<<endl;       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = acos(-1.0l);   const long long MOD = 1e9 + 7;   bool debug = 1;   const int N = 3e3 + 10;   int seg[2 * N];   int n, m;   void build() {     for (int i = n - 1; i > 0; i--) seg[i] = seg[i << 1] + seg[i << 1 | 1];   }   int qry(int l, int r) {     int ans = 0;     for (l += n, r += n; l < r; l >>= 1, r >>= 1) {       if (l & 1) ans += seg[l++];       if (r & 1) ans += seg[--r];     }     return ans;   }   void up(int pos, int x) {     for (seg[pos += n] = x; pos > 1; pos >>= 1) {       seg[pos >> 1] = seg[pos] + seg[pos ^ 1];     }   }   char mat[N][N];   int dpesq[N][N], dpdir[N][N], dpdia[N][N];   bool ok(int i, int j) { return i >= 0 and i < n and j >= 0 and j < m; }   vector<int> ev[N];   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) scanf(  %c , mat[i] + j);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int ant = 0;         if (j) ant = dpesq[i][j - 1];         if (mat[i][j] ==  z ) dpesq[i][j] = ant + 1;       }     }     for (int i = 0; i < n; i++) {       for (int j = m - 1; j >= 0; j--) {         int ant = 0;         if (j < m - 1) ant = dpdir[i][j + 1];         if (mat[i][j] ==  z ) dpdir[i][j] = ant + 1;       }     }     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < m; j++) {         int ant = 0;         if (ok(i + 1, j - 1)) ant = dpdia[i + 1][j - 1];         if (mat[i][j] ==  z ) dpdia[i][j] = ant + 1;       }     }     long long ans = 0;     for (int inic = 0; inic < n; inic++) {       int i = inic, j = 0;       memset(seg, 0, sizeof(seg));       for (int jj = 0; jj < m; jj++) ev[jj].clear();       while (ok(i, j)) {         for (auto it : ev[j]) {           up(it, 0);         }         if (mat[i][j] ==  z ) {           up(j, 1);           ev[j + dpdir[i][j]].push_back(j);           int mind = min(dpesq[i][j], dpdia[i][j]);           ans += qry(j - mind + 1, j + 1);         }         i--, j++;       }     }     for (int inicj = 1; inicj <= m - 1; inicj++) {       int i = n - 1, j = inicj;       memset(seg, 0, sizeof(seg));       for (int jj = 0; jj < m; jj++) ev[jj].clear();       while (ok(i, j)) {         for (auto it : ev[j]) {           up(it, 0);         }         if (mat[i][j] ==  z ) {           up(j, 1);           ev[j + dpdir[i][j]].push_back(j);           int mind = min(dpesq[i][j], dpdia[i][j]);           ans += qry(j - mind + 1, j + 1);         }         i--, j++;       }     }     cout << ans << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define pb push_back      int i,j,n,m,e;   vector<int>v,s;      int main()   {   #ifndef ONLINE_JUDGE    freopen( input.txt , r ,stdin);    freopen( output.txt , w ,stdout);   #endif       int t;    cin>>t;    while(t--)    {     int k,sum=0;     cin>>n>>k;     int a[n+5];        for(i=0;i<n;i++)     {      cin>>a[i];     }     sort(a,a+n);          for(i=0;i<n;i++)     {      sum+=a[i];      if(sum==k)v.pb(a[i]);      else s.pb(a[i]);     }     if(v.size()==0)     {      cout<< YES <<endl;            for(auto it : s)cout<<it<<   ;            cout<<endl;     }        else        {         for(auto it:v)s.pb(it);                   sum=0;         string ans= YES ;            for(auto it:s)         {          sum+=it;          if(sum==k)          {           ans= NO ;break;          }         }         if(ans== NO )cout<<ans<<endl;         else         {          cout<<ans<<endl;                for(auto it : s)cout<<it<<   ;cout<<endl;         }        }         v.clear();        s.clear();       }   }
#include <bits/stdc++.h>   using namespace std;   int l, r, p, prim[100], cnt, a[4000000], n, f[4000000], ans;   bool ok[4000000];   void DFS(int x, long long now) {     if (x > cnt) return;     while (now <= r) {       DFS(x + 1, now);       now = now * prim[x];       if (now <= r) a[++n] = now;     }   }   int main() {     scanf( %d%d%d , &l, &r, &p);     for (int i = 2; i <= p; ++i) {       bool OK = true;       for (int j = 2; j * j <= i; ++j)         if (i % j == 0) {           OK = false;           break;         }       if (OK) prim[++cnt] = i;     }     a[++n] = 1;     DFS(1, 1);     sort(a + 1, a + n + 1);     for (int i = 2; i <= n; ++i) f[i] = p + 1;     for (int q = 1; q <= p; ++q) {       int now = 1;       for (int i = 1; i <= n; ++i) {         long long tmp = a[i] * q;         while (now <= n && a[now] < tmp) ++now;         if (now > n) break;         if (a[now] == tmp && f[now] > f[i] + 1) {           f[now] = f[i] + 1;           if (f[now] + q <= p) ok[now] = 1;         }       }     }     for (int i = 1; i <= n; ++i)       if (a[i] >= l && ok[i]) ++ans;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   int main() {     int n;     long long a = 1, b = 1;     char s[10];     scanf( %d , &n);     for (int i = int(1); i <= int(n); ++i) {       scanf( %s , s);       if (strlen(s) == 4) {         a++;         b++;       } else {         if (s[0] ==  U  && s[1] ==  L ) b++;         if (s[0] ==  U  && s[1] ==  R ) a++;         if (s[0] ==  D  && s[1] ==  L ) a++;         if (s[0] ==  D  && s[1] ==  R ) b++;       }     }     cout << a * b << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long temp;     long long a[n];     int fg = 0;     for (int(i) = 0; (i) < (n); (i)++) {       cin >> temp;       fg++;       a[i] = temp;     }     sort(a, a + n);     for (int(i) = 0; (i) < (n - 1); (i)++) {       if (a[i] == a[i + 1]) continue;       if (a[i + 1] < 2 * a[i]) {         cout <<  YES n ;         return 0;       }     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, x, n, m;     scanf( %d%d%d%d , &k, &x, &n, &m);     for (int f1 = 0; f1 <= 1; f1++) {       for (int f2 = 0; f2 <= 1; f2++) {         for (int f3 = 0; f3 <= 1; f3++) {           int h1 = n, h2 = m;           if (f1) h1--;           if (f1 || f3) h2--;           if (f2) h1--, h2--;           if (!f2 && f3) h2--;           if (h1 < 0 || h2 < 0) continue;           for (int i = 0; i <= h1 / 2; i++) {             for (int j = 0; j <= h2 / 2; j++) {               long long las1 = i, las2 = j;               for (int t = 3; t <= k; t++) {                 long long tmp1 = las2, tmp2 = las1 + las2;                 las1 = tmp1, las2 = tmp2;                 if (t == 3 && f1) las2++;                 if (t >= 4 && t % 2 == 0 && f2) las2++;                 if (t >= 4 && t % 2 == 1 && f3) las2++;               }               if (las2 == x) {                 if (f2) printf( C );                 for (int h = 1; h <= i; h++) printf( AC );                 for (int h = 1; h <= h1 - 2 * i; h++) printf( Z );                 if (f1) printf( A );                 printf(  n );                 if (f1 || f3) printf( C );                 for (int h = 1; h <= j; h++) printf( AC );                 for (int h = 1; h <= h2 - 2 * j; h++) printf( Z );                 if (f2 || f3) printf( A );                 printf(  n );                 return 0;               }             }           }         }       }     }     printf( Happy new year! n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long inf = 1e9;   const long long N = 1000 + 5;   long long ar[N], done[N], cnt[N];   long long n;   long long mex() {     for (long long i = 0; i < n; i++) cnt[i] = 0;     for (long long i = 0; i < n; i++) cnt[ar[i]] = 1;     long long mex = 0;     while (cnt[mex]) mex++;     return mex;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     cin >> t;     while (t--) {       cin >> n;       for (long long i = 0; i < n; i++) {         cin >> ar[i];       }       vector<long long> ans;       while (1) {         long long m = mex();         if (m < n) {           ar[m] = m;           ans.push_back(m + 1);         } else {           long long ind = 0;           while (ind < n && ar[ind] == ind) ind++;           if (ind == n) break;           long long p = -1;           for (long long i = 0; i < n && p == -1; i++)             if (ar[i] == ind) p = i;           ar[p] = n;           ans.push_back(p + 1);         }       }       cout << ans.size() <<   n ;       for (auto &inx : ans) cout << inx <<    ;       cout <<   n ;     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:32100000 )   #pragma GCC optimize( O3 )   using namespace std;   void solve() {     int n, k;     string str;     cin >> n >> k >> str;     string need;     for (int i = 0; i < k - 1; i++) {       need +=  () ;     }     for (int i = 0; i < (n - 2 * k + 2) / 2; i++) {       need +=  ( ;     }     for (int i = 0; i < (n - 2 * k + 2) / 2; i++) {       need +=  ) ;     }     vector<pair<int, int>> ans;     for (int i = 0; i < n; i++) {       if (str[i] == need[i]) {         continue;       }       int pos = i + 1;       for (; pos < n && str[pos] != need[i]; pos++)         ;       ans.push_back({i, pos});       for (int j = 0; j < (pos - i + 1) / 2; j++) {         swap(str[i + j], str[pos - j]);       }     }     cout << ans.size() <<   n ;     for (auto &i : ans) {       cout << i.first + 1 <<     << i.second + 1 <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin.sync_with_stdio(0);     cout.sync_with_stdio(0);     cout.precision(9);     srand(time(0));     int q;     cin >> q;     while (q--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[111111];   int isp2[222222];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     for (int i = 1, p = 1; i < 222222; i *= 2, ++p) {       isp2[i] = p;     }     sort(a, a + n);     int ans = 1e9;     for (int dv = 0; a[n - 1] >= (1 << dv); ++dv) {       for (int mul = 0; mul <= dv + 1; ++mul) {         int val = a[n - 1];         for (int i = 0; i < dv; ++i) {           val /= 2;         }         for (int i = 0; i < mul; ++i) {           val *= 2;         }         int tot = 0;         for (int i = 0; i < n; ++i) {           int cur = a[i];           while (cur > 0 && !(val % cur == 0 && isp2[val / cur])) {             cur /= 2;             ++tot;           }           if (cur > 0) {             tot += isp2[val / cur] - 1;           } else {             tot = 1e9;             break;           }         }         ans = min(ans, tot);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   inline int read() {     int s = 0;     char c;     while ((c = getchar()) <  0  || c >  9 )       ;     do {       s = s * 10 + c -  0 ;     } while ((c = getchar()) >=  0  && c <=  9 );     return s;   }   int n, l, r, ql, qr;   long long ans;   int main() {     for (n = read(), l = r = read(); n--;) {       ql = read(), qr = read();       if (ql <= l && r <= qr) continue;       if (qr < l)         ans += l - qr, r = l, l = qr;       else if (r < ql)         ans += ql - r, l = r, r = ql;       else         l = ql > l ? ql : l, r = qr < r ? qr : r;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, a, b, v;     cin >> k >> a >> b >> v;     int x = (a + v - 1) / v;     int t, y;     t = b / (k - 1);     y = t * k;     while (y > x) {       b--;       t = b / (k - 1);       y = t * k;     }     int c;     c = b % (k - 1) + 1;     int m;     if (x > c + y)       m = x - (c + y);     else       m = 0;     if (y < x)       cout << m + t + 1;     else       cout << m + t;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 5, mum = 1e9 + 7;   int Pow(int A, long long B) {     int num = 1;     while (B) {       if (B & 1) num = 1LL * num * A % mum;       A = 1LL * A * A % mum;       B >>= 1;     }     return num;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, m, k, r, c, ax, ay, bx, by;     cin >> n >> m >> k >> r >> c >> ax >> ay >> bx >> by;     cout << (ax == bx && ay == by ? Pow(k, 1LL * n * m)                                   : Pow(k, 1LL * n * m - 1LL * r * c))          <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace ::std;   const int V = 1e5 + 25;   int arr[V];   map<int, int> mmap;   int main() {     int n;     cin >> n;     int mx = INT_MIN;     int mn = INT_MAX;     for (int i = 0; i < n; i++) {       cin >> arr[i];       mx = max(mx, arr[i]);       mn = min(mn, arr[i]);       mmap[arr[i]]++;     }     if (mx - mn < 2) {       cout << n << endl;       for (int i = 0; i < n; i++) {         cout << arr[i] <<    ;       }       cout << endl;       return 0;     }     int cnt = 0;     int a, b, c;     int p, q, r;     if (mmap.size() == 2) {       for (auto x : mmap) {         if (cnt == 0) p = x.first, a = x.second;         if (cnt == 1) r = x.first, c = x.second;         cnt++;       }       q = p + 1;       b = 0;     } else {       for (auto x : mmap) {         if (cnt == 0) p = x.first, a = x.second;         if (cnt == 1) q = x.first, b = x.second;         if (cnt == 2) r = x.first, c = x.second;         cnt++;       }     }     int b1 = b + 2 * min(a, c);     int a1 = a - min(a, c);     int c1 = c - min(a, c);     int b2 = b % 2;     int a2 = a + (b - b % 2) / 2;     int c2 = c + (b - b % 2) / 2;     int lhs = min(a1, a) + min(b1, b) + min(c1, c);     int rhs = min(a2, a) + min(b2, b) + min(c2, c);     if (lhs <= rhs) {       printf( %d n , lhs);       for (int i = 0; i < a1; i++) printf( %d  , p);       for (int i = 0; i < b1; i++) printf( %d  , q);       for (int i = 0; i < c1; i++) printf( %d  , r);     } else {       printf( %d n , rhs);       for (int i = 0; i < a2; i++) printf( %d  , p);       for (int i = 0; i < b2; i++) printf( %d  , q);       for (int i = 0; i < c2; i++) printf( %d  , r);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = atan(1.0) * 4.0;   const long long int MOD = 1e9 + 7;   const long long int INF = 1e5;   const long double EPS = 0.0000001;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     int a[1005], k;     a[0] = -1;     a[1] = 0;     for (int i = 2; i <= 1005; i++) {       a[i] = a[i - 1] + i - 1;     }     cin >> k;     if (k == 0) {       cout <<  a  << endl;       return 0;     }     char ch =  a ;     while (k > 0) {       int lb = lower_bound(a, a + 1005, k) - a;       if (a[lb] != k) lb--;       for (int i = 1; i <= lb; i++) cout << ch;       k -= a[lb];       ch++;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ull = unsigned long long;   int n, k, q;   int pref[200005];   int main() {     cin >> n >> k >> q;     int maxRight = 0;     for (int i = 0; i < n; ++i) {       int left, right;       cin >> left >> right;       maxRight = max(maxRight, right);       ++pref[left], --pref[right + 1];     }     for (int i = 1; i <= maxRight; ++i) {       pref[i] += pref[i - 1];     }     for (int i = 0; i <= 200001; ++i) {       pref[i] = (int)(pref[i] >= k);       pref[i] += pref[i - 1];     }     while (q--) {       int a, b;       cin >> a >> b;       cout << pref[b] - pref[a - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) cin >> arr[i];       bool prev = false;       for (int i = 0; true; i++) {         int change = 0;         if (i & 1) {           for (int j = 1; j < n - 1; j++) {             if (arr[j] > arr[j + 1]) {               swap(arr[j], arr[j + 1]);               change++;             }             j++;           }         } else {           for (int j = 0; j < n - 2; j++) {             if (arr[j] > arr[j + 1]) {               swap(arr[j], arr[j + 1]);               change++;             }             j++;           }         }         if (!change) {           if (prev) {             cout << i - 1 <<   n ;             break;           }           prev = true;         } else {           prev = false;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d;   long long f(long long k) { return (d * b * k - 2 * a) * (k + 1) / -2; }   int main() {     int t;     cin >> t;     while (t--) {       cin >> a >> b >> c >> d;       if (a > b * c) {         cout <<  -1 n ;         continue;       }       double k = a * 1.0 / (d * b) - 0.5;       cout << max(f(k), f(k + 1)) <<   n ;     }   }
#include <bits/stdc++.h>   int main(void) {     char a[100001];     long long current, jump[100001], n, i;     int flag = 1, visited[100001];     memset(visited, 0, sizeof(visited));     scanf( %lld , &n);     if (n == 1) {       printf( FINITE );       return 0;     }     scanf( %s , a);     for (i = 1; i <= n; i++) scanf( %lld , &jump[i]);     current = 1;     i = 1;     while (flag == 1) {       visited[current] = 1;       if (a[current - 1] ==  > ) {         current = current + jump[current];       } else {         current = current - jump[current];       }       if (current < 1 || current > n) {         flag = 0;         break;       }       if (visited[current] == 1) {         break;       }     }     if (flag == 0) {       printf( FINITE );     } else {       printf( INFINITE );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long arr1[26], arr2[26][26];   signed main() {     string s;     cin >> s;     long long n = s.length();     for (long long i = 0; i < n; i++) {       long long ct = s[i] -  a ;       for (long long j = 0; j < 26; j++) {         arr2[j][ct] += arr1[j];       }       arr1[ct]++;     }     long long ans = 0;     for (long long i = 0; i < 26; i++) ans = max(ans, arr1[i]);     for (long long i = 0; i < 26; i++) {       for (long long j = 0; j < 26; j++) {         ans = max(ans, arr2[i][j]);       }     }     cout << ans;   }