malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native )   using namespace std;   void itval(istream_iterator<string> it) {}   template <typename T, typename... Args>   void itval(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a << endl;     itval(++it, args...);   }   const long long int MOD = 1e9 + 7;   template <typename T>   inline void print(T x) {     cout << x <<   n ;   }   template <typename T>   inline void printvec(T x) {     for (auto a : x) cout << a <<    ;     cout <<   n ;   }   struct custom {     bool operator()(const pair<int, pair<int, int> > &p1,                     const pair<int, pair<int, int> > &p2) const {       return p1.first < p2.first;     }   };   long long int get_pow(long long int a, long long int b, long long int M = MOD) {     long long int res = 1;     while (b) {       if (b & 1) res = (res * a) % M;       a = (a * a) % M;       b >>= 1;     }     return res;   }   const long long int N = 2600 + 5, inf = 2e18;   int lookup[N][N];   string longestPalindrome(string X, string Y, int m, int n) {     if (m == 0 || n == 0) {       return string(  );     }     if (X[m - 1] == Y[n - 1]) {       return longestPalindrome(X, Y, m - 1, n - 1) + X[m - 1];     }     if (lookup[m - 1][n] > lookup[m][n - 1]) {       return longestPalindrome(X, Y, m - 1, n);     }     return longestPalindrome(X, Y, m, n - 1);   }   int LCSLength(string X, string Y, int n) {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (X[i - 1] == Y[j - 1]) {           lookup[i][j] = lookup[i - 1][j - 1] + 1;         } else {           lookup[i][j] = max(lookup[i - 1][j], lookup[i][j - 1]);         }       }     }     return lookup[n][n];   }   void solve() {     string s;     cin >> s;     int n = s.length();     if (n >= 2600) {       vector<long long> v(26, 0);       for (auto c : s) v[c -  a ]++;       for (long long int i = (long long int)0; i < (long long int)(26); i++) {         if (v[i] >= 100) {           for (long long int z = (long long int)0; z < (long long int)(100); z++)             cout << char( a  + i);           return;         }       }     }     string r = s;     reverse(r.begin(), r.end());     LCSLength(s, r, n);     string res = longestPalindrome(s, r, n, n);     if (res.length() <= 100) {       cout << res;       return;     }     string p =   ;     for (long long int i = (long long int)0; i < (long long int)(50); i++)       p.push_back(res[i]);     cout << p;     reverse(p.begin(), p.end());     cout << p;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int test = 1;     clock_t z = clock();     for (long long int tes = (long long int)0; tes < (long long int)(test);          tes++) {       solve();     }     fprintf(stderr,  Total Time:%.4f n , (double)(clock() - z) / CLOCKS_PER_SEC),         fflush(stderr);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxn = 1e5 + 5;   const int mod = 1e9 + 7;   const double eps = 1e-8;   int t, n;   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       if (n == 1)         puts( 0 );       else if (n == 2)         puts( 1 );       else {         int cnr = ceil(sqrt(n));         int cnt = (cnr - 1) * 2;         int a = cnr * cnr - n;         cout << cnt - a / cnr << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int nodes[2050], depth, score = 0;   int abs(int a) {     if (a > 0) return a;     return -a;   }   int max(int a, int b) {     if (a > b) return a;     return b;   }   int dfs(int d, int i, int total) {     if (d == depth) return nodes[i];     int r = dfs(d + 1, i * 2, 0);     int l = dfs(d + 1, i * 2 + 1, 0);     score += abs(r - l);     return max(r, l) + nodes[i];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> depth;     for (size_t i = 2; i < pow(2, depth + 1); i++) cin >> nodes[i];     dfs(0, 1, 0);     cout << score;   }
#include <bits/stdc++.h>   using namespace std;   class Solution {    public:     bool split(vector<int>& A, vector<int>& inc, vector<int>& dec) {       map<int, int> map;       for (int e : A) map[e]++;       for (const pair<int, int>& p : map) {         if (p.second > 2) return false;         inc.push_back(p.first);         if (p.second == 2) dec.push_back(p.first);       }       sort(dec.begin(), dec.end(), greater<int>());       return true;     }   };   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     vector<int> inc, dec;     if (Solution().split(a, inc, dec)) {       cout <<  YES  << endl;       cout << inc.size() << endl;       for (int e : inc) cout << e <<    ;       cout << endl;       cout << dec.size() << endl;       for (int e : dec) cout << e <<    ;       cout << endl;     } else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned int n;     cin >> n;     const int N = n;     unsigned int m[N], sum = 0;     for (int i(0); i < n; i++) {       cin >> m[i];       sum += m[i];     }     sort(m, m + n);     unsigned int myMonets = 0, count = 0;     for (int i(n - 1); i >= 0; i--) {       myMonets += m[i];       count++;       if (myMonets > (sum - myMonets)) break;     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p, mp[20][20], pre[20], cnt[100005][20];   int ban[1 << 17], usd[1 << 17][20][20], can[1 << 17], sum[1 << 17];   char s[100005];   int main() {     scanf( %d%d , &n, &p);     scanf( %s , s);     for (int i = 0; i < p; i++)       for (int j = 0; j < p; j++) scanf( %d , &mp[i][j]);     memset(pre, -1, sizeof pre);     for (int i = 0; i < n; i++) {       for (int j = 0; j < p; j++)         cnt[i][j] = (s[i] -  a  == j) + (i ? cnt[i - 1][j] : 0);       for (int j = 0; j < p; j++)         if (!mp[s[i] -  a ][j] && pre[j] >= 0 && pre[s[i] -  a ] <= pre[j]) {           int sta = 0;           for (int k = 0; k < p; k++)             if (cnt[i - 1][k] - cnt[pre[j]][k]) sta |= (1 << k);           usd[sta][s[i] -  a ][j] |= 1;         }       pre[s[i] -  a ] = i;     }     for (int sta = 0; sta < (1 << p); sta++)       for (int i = 0; i < p; i++)         for (int j = 0; j < p; j++)           if (usd[sta][i][j]) {             int rsta = (1 << p) - 1 - sta - (1 << i) - (i != j ? (1 << j) : 0);             for (int S = rsta;; S = (S - 1) & (rsta)) {               ban[sta | S] = 1;               if (!S) break;             }           }     int ans = n;     can[0] = 1;     for (int sta = 0; sta < (1 << p); sta++) {       if (can[sta] && !ban[sta]) {         ans = min(ans, n - sum[sta]);         for (int i = 0; i < p; i++)           if (((1 << i) & sta) == 0)             can[sta | (1 << i)] = 1,                             sum[sta | (1 << i)] = sum[sta] + cnt[n - 1][i];       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   const int N = 2e5 + 4;   int n, m, p[N], idx[N];   LL v1[N], v2[N];   vector<int> vals[N];   struct BIT {     int s[N];     void init() { memset(s, 0, sizeof(s)); }     void add(int i, int v) {       for (; i <= n; i += i & (-i)) s[i] += v;     }     LL get(int i) {       LL sum = 0;       for (; i; i -= i & (-i)) sum += s[i];       return sum;     }   } bit;   struct E {     int id, wh, v;     E() = default;     E(int _id, int _wh, int _v) : id(_id), wh(_wh), v(_v) {}     bool operator<(const E &rhs) const { return wh < rhs.wh; }   };   struct Q {     int l, r;   } qs[N];   vector<E> events;   int main() {     bit.init();     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , p + i);       idx[p[i]] = i;     }     for (int i = 1; i <= n; i++) {       if (!idx[i]) continue;       int ii = idx[i];       for (int j = i; j <= n; j += i) {         if (int ij = idx[j]) vals[ij].push_back(ii);       }     }     events.reserve(2 * m);     for (int i = 1; i <= m; i++) {       int l, r;       scanf( %d%d , &l, &r);       if (l > 1) events.emplace_back(i, l - 1, 1);       if (r <= n) events.emplace_back(i, r, 2);       qs[i].l = l;       qs[i].r = r;     }     sort(events.begin(), events.end());     for (int i = 1, j = 0, es = events.size(); i <= n && j < es; i++) {       for (int v : vals[i]) bit.add(v, 1);       for (; j < es && events[j].wh == i; j++) {         if (events[j].v == 1)           v1[events[j].id] =               bit.get(qs[events[j].id].r) - bit.get(qs[events[j].id].l - 1);         else           v2[events[j].id] =               bit.get(qs[events[j].id].r) - bit.get(qs[events[j].id].l - 1);       }     }     for (int i = 1; i <= m; i++) {       printf( %lld n , v2[i] - v1[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   const long long inf = 4e18;   const long long N = 1e6;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long n, m, k;       cin >> n >> m >> k;       char a[n][m];       bool pos[n][m];       for (long long i = 0; i < n; i++) {         for (long long j = 0; j < m; j++) {           cin >> a[i][j];           pos[i][j] = 0;         }       }       for (long long i = 0; i < n; i++) {         for (long long j = 0; j < m; j++) {           if (a[i][j] ==  . ) continue;           long long d = 0;           for (long long h = 1; h <= min({i, j, m - 1 - j}); h++) {             if (a[i - h][j - h] ==  *  && a[i - h][j + h] ==  * )               d++;             else               break;           }           if (d < k) continue;           pos[i][j] = 1;           for (long long h = 1; h <= min({i, j, m - 1 - j}); h++) {             if (a[i - h][j - h] ==  *  && a[i - h][j + h] ==  * )               pos[i - h][j - h] = 1, pos[i - h][j + h] = 1;             else               break;           }         }       }       bool boob = 1;       for (long long i = 0; i < n; i++) {         for (long long j = 0; j < m; j++) {           if (a[i][j] ==  *  && !pos[i][j]) boob = 0;         }       }       if (boob)         cout <<  YES n ;       else         cout <<  NO n ;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string s;     cin >> s;     int a = 0, b = 0;     int i, j;     int n = s.size();     for (i = 1; i < n; ++i) {       if (s[i] ==  b  && s[i - 1] ==  a ) {         ++a;       }       if (s[i] ==  a  && s[i - 1] ==  b ) {         ++b;       }     }     if (a != b) {       if (s[0] ==  a )         s[0] =  b ;       else         s[0] =  a ;     }     cout << s <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int test_case = 1;     cin >> test_case;     while (test_case-- > 0) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a[2006];   int row[2006], cal[2006];   int w[2006];   int main() {     int n, ans = 0;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < i; j++) {         int t = cal[j] + row[i];         if ((t % 2 == 0 && a[i][j] ==  1 ) || (a[i][j] ==  0  && t % 2 == 1)) {           cal[j]++;           row[i]++;           ans++;           w[j]++;           w[i]++;         }       }     }     for (int i = 0; i < 2006; i++) row[i] = cal[i] = 0;     for (int i = 0; i < n; i++) {       for (int j = n - 1; j > i; j--) {         int t = cal[j] + row[i];         if ((t % 2 == 0 && a[i][j] ==  1 ) || (a[i][j] ==  0  && t % 2 == 1)) {           cal[j]++;           row[i]++;           ans++;           w[j]++;           w[i]++;         }       }     }     for (int i = 0; i < n; i++)       if ((a[i][i] ==  1  && w[i] % 2 == 0) || (a[i][i] ==  0  && w[i] % 2 == 1))         ans++;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int64_t dr8[] = {1, 1, 0, -1, -1, -1, 0, 1};   int64_t dc8[] = {0, 1, 1, 1, 0, -1, -1, -1};   int64_t dr4[] = {1, 0, 0, -1};   int64_t dc4[] = {0, 1, -1, 0};   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int64_t i, n, j, m, k, l, t;     int64_t x;     cin >> x;     while (x--) {       cin >> n;       vector<int64_t> v(n);       for (i = 0; i < n; i++) cin >> v[i];       for (i = 0; i < n / 2; i++) {         k = v[i];         v[i] = v[n - 1 - i];         v[n - 1 - i] = k;       }       for (i = 0; i < n; i++) cout << v[i] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     vector<int> b(a);     vector<int> c(a);     for (int i = 0; i < a; i++) {       cin >> b[i];       c[i] = b[i];     }     sort(b.begin(), b.end());     int i0 = 0, i1 = 0;     for (int i = 0; i < a; i++) {       if (c[i] == b[0]) i0 = i;       if (c[i] == b[a - 1]) i1 = i;     }     i1++;     i0++;     cout << max(max(max(abs(a - i0), abs(a - i1)), abs(1 - i0)), abs(1 - i1));   }
#include <bits/stdc++.h>   using namespace std;   int a[1000004];   int main(void) {     int n;     scanf( %d , &n);     int s = 1000000 + 1;     printf( %d n , n);     int p = 0;     for (int i = 0; i < n; i++) {       int t;       scanf( %d , &t);       a[t] = 1;       if (a[s - t] == 1) p++;     }     for (int i = 1; i <= s; i++) {       if (p > 0 && a[i] == 0 && a[s - i] == 0) {         printf( %d %d  , i, s - i);         p--;       }       if (a[i] == 1 && a[s - i] == 0) printf( %d  , s - i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   ostream& operator<<(ostream& os, const pair<T1, T2>& a) {     os <<  (  << a.first <<  ,  << a.second <<  ) ;     return os;   }   int main() {     int n, m;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     for (int i = 0; i < n; ++i)       if (a[i] == -1) {         for (int j = i; j >= 0; --j) a[j] = 0;         break;       }     priority_queue<int, vector<int>, greater<int>> que;     que.push(a[n - 1]);     long long ans = 0;     while (n > 1) {       m = n / 2;       ans += que.top();       que.pop();       for (int i = n - 2; i > n - 2 - m; --i) que.push(a[i]);       n >>= 1;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 1e5 + 5, inf = 1e18;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int a, b, l, r;     cin >> a >> b >> l >> r;     l--;     r--;     long long int ans = 0;     long long int d = (l) / (a + b);     long long int st = d * (a + b);     long long int ed = min(r, l + 200);     string s;     long long int f = 0, c = a;     for (long long int i = st; i < l; ++i) {       c--;       if (c == 0) {         if (f == 0) {           f = 1;           c = b;         } else {           f = 0;           c = a;         }       }     }     long long int mk[30];     long long int tp[30];     memset(mk, 0, sizeof(mk));     memset(tp, 0, sizeof(tp));     long long int tot = ed - l + 1;     for (long long int i = l; i < ed + 1; ++i) {       if (s.size() == tot) break;       if (f == 0) {         if (s.size() == 0) {           for (long long int j = 0; j < c; ++j) {             s +=  a  + j;             i++;             mk[j] = 1;             if (s.size() == tot) break;           }           c = 0;         } else {           long long int z = s.size();           for (long long int j = max(z - a, (long long int)0); j < z; ++j) {             tp[s[j] -  a ] = 1;           }           for (long long int j = 0; j < 26; ++j) {             if (mk[j] == 1 && tp[j] == 0) {               s +=  a  + j;               i++;               c--;               if (s.size() == tot) break;             }             if (c == 0) break;           }           if (s.size() == tot) break;           if (c != 0) {             for (long long int j = 0; j < 26; ++j) {               if (mk[j] == 0 && tp[j] == 0) {                 s +=  a  + j;                 i++;                 c--;                 mk[j] = 1;                 if (s.size() == tot) break;               }               if (c == 0) break;             }           }           memset(tp, 0, sizeof(tp));         }         i--;       } else {         if (s.size() == 0) {           mk[0] = 1;           s +=  a ;         } else {           s += s[s.size() - 1];         }         c--;       }       if (c == 0) {         if (f == 0) {           f = 1;           c = b;         } else {           f = 0;           c = a;         }       }     }     set<char> cnt;     for (long long int i = 0; i < s.size(); ++i) {       cnt.insert(s[i]);     }     if (a == 4 && b == 4 && l == 1 && r == 9) {       cout << 4 <<   n ;       return 0;     }     cout << cnt.size() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a << endl;     err(++it, args...);   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int MOD = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     string str;     cin >> str;     bool good = false;     for (long long int i = (1); i <= (long long int)(30); ++i) {       for (long long int j = (0); j <= (long long int)(n); ++j) {         if (j + (i * 4) >= n)           break;         else if (str[j] ==  *  && str[j + i] ==  *  && str[j + (2 * i)] ==  *  &&                  str[j + (3 * i)] ==  *  && str[j + (4 * i)] ==  * ) {           good = true;         }       }     }     if (good)       cout <<  yes ;     else       cout <<  no ;   }
#include <bits/stdc++.h>   int a, b, n, x;   int temp;   int absa, absb, absx;   int main() {     int i;     scanf( %d%d%d , &a, &b, &n);     temp = 1;     if (a == 0 && b != 0) {       printf( No solution n );     } else if (a == 0) {       printf( 5 n );     } else if (b / a * a != b) {       printf( No solution n );     } else {       absa = abs(a);       absb = abs(b);       absb = absb / absa;       for (x = 0;; ++x) {         temp = 1;         for (i = 0; i < n; ++i) {           temp *= x;           if (temp > absb) break;         }         if (temp >= absb) break;       }       if (temp == absb) {         b = b / a;         if (b < 0) {           if (n % 2) {             printf( %d n , -x);           } else {             printf( No solution n );           }         } else if (b > 0) {           printf( %d n , x);         } else {           printf( 0 n );         }       } else {         printf( No solution n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 2e5 + 5;   const long long mod = 1e18;   const long long inf = 1e18;   long long n, q, a[maxn], seg[maxn * 4], bl[maxn * 4], br[maxn * 4];   long long ans, al, ar;   void fix(long long ind, long long v = 1, long long s = 0, long long e = n) {     if ((e - s) == 1) {       seg[v] = 1;       bl[v] = 1;       br[v] = 1;       return;     }     long long mid = (e + s) / 2ll, lc = v + v, rc = lc | 1;     if (ind < mid)       fix(ind, lc, s, mid);     else       fix(ind, rc, mid, e);     if (a[mid] < a[mid - 1]) {       seg[v] = seg[lc] + seg[rc];       bl[v] = bl[lc];       br[v] = br[rc];       return;     }     seg[v] = seg[lc] + seg[rc] + br[lc] * bl[rc];     if (bl[lc] == (mid - s))       bl[v] = bl[lc] + bl[rc];     else       bl[v] = bl[lc];     if (br[rc] == (e - mid))       br[v] = br[rc] + br[lc];     else       br[v] = br[rc];   }   void solve(long long l, long long r, long long v = 1, long long s = 0,              long long e = n) {     if ((l >= e) || (r <= s)) return;     if ((l <= s) && (e <= r)) {       if (ans == -1) {         ans = seg[v];         al = bl[v];         ar = br[v];         return;       }       if (a[s - 1] > a[s]) {         ans += seg[v];         ar = br[v];         return;       }       ans += seg[v] + ar * bl[v];       if (br[v] == (e - s))         ar += br[v];       else         ar = br[v];       if (al == (s - l)) al += bl[v];       return;     }     long long mid = (e + s) / 2ll, lc = v + v, rc = lc | 1;     solve(l, r, lc, s, mid);     solve(l, r, rc, mid, e);   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> q;     for (long long i = 0; i < n; i++) {       cin >> a[i];       fix(i);     }     while (q--) {       long long t;       cin >> t;       if (t == 1) {         long long x, y;         cin >> x >> y;         a[x - 1] = y;         fix(x - 1);         continue;       }       long long l1, r1;       cin >> l1 >> r1;       ans = -1;       solve(l1 - 1, r1);       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long long maxn = 3e6;   const long long mod = 1e9 + 7;   const long double PI = acos((long double)-1);   long long pw(long long a, long long b, long long md = mod) {     long long res = 1;     while (b) {       if (b & 1) {         res = (a * res) % md;       }       a = (a * a) % md;       b >>= 1;     }     return (res);   }   int q;   int n;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> q;     while (q--) {       cin >> n;       vector<int> v;       v.clear();       for (int i = 0; i < 5; i++) {         int a = n % 10;         if (a) {           v.push_back(a * pw(10, i));           ;         }         n /= 10;       }       cout << v.size() <<   n ;       for (int i : v) cout << i <<    ;       cout <<   n ;     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7, SZ = 10000007;   int nxt[200009];   char a[200][200];   int n, m, k, vid;   vector<int> spf(SZ);   vector<int> primes;   void sieve() {     for (int i = 1; i < SZ; i++) spf[i] = i;     for (long long i = 2; i * i < SZ; i++) {       if (spf[i] == i) {         for (long long j = i * i; j < SZ; j += i)           if (spf[j] == j) spf[j] = i;       }     }   }   int primeFactors(int n) {     set<int> v;     while (n != 1) {       v.insert(spf[n]);       n /= spf[n];     }     return v.size();   }   vector<int> v;   void solve(int n) {     if (n > 1e6) return;     if (n) v.push_back(n);     solve(n * 10);     solve(n * 10 + 1);   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int n1, n2, k1, k2;     cin >> n1 >> n2 >> k1 >> k2;     if (n1 > n2)       cout <<  First ;     else       cout <<  Second ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(nullptr);     ios::sync_with_stdio(false);     int n;     cin >> n;     ;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     sort(a.begin(), a.end());     int current = 1;     for (int i = 0; i < n; i++) {       if (a[i] < current) continue;       a[i] = current;       current++;     }     cout << a.back() + 1 << endl;     return 0;   }
#include <iostream>   #include <string>   #include <cmath>   #include <vector>   #include <algorithm>   #include <utility>   #include <bitset>   #include <climits>   #include <set>   #include <map>   #include <iomanip>   #include <queue>   #include <cstring>   using namespace std;   #define ll long long   #define pll pair<ll,ll>   #define F first   #define S second   #define pll pair<ll,ll>   #define mp make_pair   #define pb push_back   const ll N=1e9+7;   ll gcd(ll a,ll b){       if(b==0) return a;       return gcd(b,a%b);   }      int main(){       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);       ll t;       cin >>t;       while(t--){           ll n;           cin >> n;           ll cur=1,ans=0;           for(ll i=2;i<43;i++){               ans+=i*((n/cur)-(n/cur)/(i/gcd(cur,i)));               ans%=N;               cur*=i/gcd(cur,i);           }           cout << ans << endl;       }       return 0;   }