malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<bool> flag_pr(10001000, 0), flag_pal(10001000, 0);   vector<long long> prime_upto(10001000, 0), palin_upto(10001000, 0);   int gcd(int a, int b) {     if (a % b == 0)       return b;     else       return gcd(b, a % b);   }   bool isPalin(int num) {     int ret = 0, n = num;     while (n > 0) {       int val = (n / 10) * 10;       int dig = n - val;       ret = ret * 10 + dig;       n /= 10;     }     if (ret == num)       return true;     else       return false;   }   void init() {     flag_pr[2] = 1;     for (int i = 3; i * i < 10001000; i += 2)       if (!flag_pr[i])         for (int j = 2 * i; j < 10001000; j += i) flag_pr[j] = 1;     prime_upto[2] = 1;     for (int i = 3; i < 10001000; i++) {       if (i & 1) {         prime_upto[i] = prime_upto[i - 1] + (flag_pr[i] == 0 ? 1 : 0);       } else {         prime_upto[i] = prime_upto[i - 1];       }     }     for (int i = 1; i < 10001000; i++) {       if (i == 1)         palin_upto[i] = 1;       else {         palin_upto[i] = palin_upto[i - 1] + isPalin(i);       }     }     return;   }   void solve() {     int p, q;     cin >> p >> q;     int g = gcd(p, q);     p /= g;     q /= g;     int ret = -1;     for (int i = 1; i < 10001000; i++) {       if (q * prime_upto[i] <= p * palin_upto[i]) {         ret = max(ret, i);       }     }     cout << ret <<   n ;     return;   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     cin >> a >> b;     int count = 0;     for (int i = 0; (1LL << i) / 2 <= b; i++) {       for (int j = 0; j < i - 1; j++) {         long long n = (1LL << i) - 1 - (1LL << j);         if (a <= n && n <= b) count++;       }     }     cout << count <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int func(vector<vector<long long int>> &d, vector<int> &v, int i,                      int k) {     if (d[k][i - 1] != 0) return d[k][i - 1];     if (k && (i + v[i - 1] <= d[0].size())) {       d[k][i - 1] = -1;       long long int y = func(d, v, i + v[i - 1], 1 - k);       if (y != -1) y += v[i - 1];       return d[k][i - 1] = y;     } else if (k)       return d[k][i - 1] = v[i - 1];     else if (i - v[i - 1] > 0) {       d[k][i - 1] = -1;       long long int y = func(d, v, i - v[i - 1], 1 - k);       if (y != -1) y += v[i - 1];       return d[k][i - 1] = y;     } else       return d[k][i - 1] = v[i - 1];   }   int main() {     long long int n, x, y, k = 1;     cin >> n;     vector<int> v;     v.push_back(0);     for (int i = 0; i < n - 1; i++) {       cin >> x;       v.push_back(x);     }     vector<vector<long long int>> d(2, vector<long long int>(n, 0));     for (int i = 1; i < n; i++) {       y = 0;       v[0] = i;       d[1][0] = d[0][0] = -1;       y = func(d, v, v[0] + 1, 0);       if (y != -1) y += i;       cout << y << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long int, long long int> mp;   int main() {     int n, c = 0, x = 0, a[200], i, j;     cin >> n;     for (i = 0; i < n; i++) {       cin >> a[i];       c += a[i];     }     if (n == 1) x = 1;     if (n == 2 && a[0] == a[1]) x = 1;     if (x == 1)       cout << -1;     else {       cout << 1 << endl;       for (i = 0; i < n; i++) {         if (2 * a[i] != c) {           cout << i + 1;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxN = 5e4 + 7;   const int inf = 1e5 + 7;   const long long mod = 1e5 + 7;   const long long infll = 1e18 + 7;   long long a[mxN], b[mxN];   map<long long, bool> mp;   int n;   bool check = false;   bool ok(long long x) {     for (int i = 1; i <= n; i++) a[i] = b[i];     mp.clear();     for (int i = 1; i <= n; i++) {       if (a[i] <= x) {         if (mp[a[i]] == true) {           while (mp[a[i]] == true && a[i] != 1) {             a[i] /= 2;           }           if (mp[a[i]] == true) return false;         }         mp[a[i]] = true;       } else {         while ((a[i] > x || mp[a[i]] == true) && a[i] != 1) {           a[i] /= 2;         }         if (mp[a[i]] == true) return false;         mp[a[i]] = true;       }       if (check == true) cout << a[i] <<    ;     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++) b[i] = a[i];     long long l = 0;     long long r = infll;     while (l + 1 < r) {       long long m = (l + r) / 2;       if (ok(m))         r = m;       else         l = m;     }     check = true;     ok(r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   int n, a[300100], q;   struct node {     int x;     int val;   };   bool operator<(node a, node b) { return a.val < b.val; }   priority_queue<node> heap;   set<int> tree;   int main() {     n = read(), q = read();     for (int i = 1; i <= n; ++i) {       a[i] = read();       tree.insert(a[i]);     }     sort(a + 1, a + 1 + n);     for (int i = 1; i < n; ++i) {       heap.push({a[i], a[i + 1] - a[i]});     }     if (tree.size() <= 2) {       puts( 0 );     } else {       cout << (*(--tree.end())) - (*tree.begin()) - heap.top().val << endl;     }     for (int i = 1; i <= q; ++i) {       int t = read(), p = read();       if (t == 0) {         set<int>::iterator it;         it = tree.lower_bound(p);         set<int>::iterator lst = it;         lst--;         if (it != tree.end()) {           set<int>::iterator nxt = it;           nxt++;           heap.push({(*lst), (*nxt) - (*lst)});           tree.erase(it);         }       } else {         tree.insert(p);         set<int>::iterator it;         it = tree.lower_bound(p);         set<int>::iterator nxt = it;         nxt++;         set<int>::iterator lst = it;         lst--;         heap.push({(*lst), (*it) - (*lst)});         heap.push({(*it), (*nxt) - (*it)});       }       bool flag = false;       do {         flag = false;         int x = heap.top().x, val = heap.top().val;         set<int>::iterator it;         it = tree.find(x);         set<int>::iterator nxt = it;         if (it != tree.end()) nxt++;         if (it == tree.end() || nxt == tree.end()) {           heap.pop();           flag = true;         } else {           if (val != (*nxt) - (*it)) {             heap.pop();             flag = true;           }         }       } while (flag && heap.size());       if (tree.size() <= 2) {         puts( 0 );       } else {         cout << (*(--tree.end())) - (*tree.begin()) - heap.top().val;         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 2e5 + 15;   inline long long read() {     long long x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 1) + (x << 3) + c -  0 ;       c = getchar();     }     return x * f;   }   long long T, n, tot, last, len[maxn], size[maxn], link[maxn], nxt[maxn][30];   inline long long extend(long long last, long long x) {     long long now = ++tot, pos = last, tmp, cln;     len[now] = len[pos] + 1;     size[now]++;     while (pos != 0 && nxt[pos][x] == 0) nxt[pos][x] = now, pos = link[pos];     if (!pos) {       link[now] = 1;       return now;     }     tmp = nxt[pos][x];     if (len[tmp] == len[pos] + 1) {       link[now] = tmp;       return now;     }     cln = ++tot;     len[cln] = len[pos] + 1;     for (long long i = 1; i <= 26; i++) nxt[cln][i] = nxt[tmp][i];     link[cln] = link[tmp];     link[tmp] = link[now] = cln;     while (pos != 0 && nxt[pos][x] == tmp) nxt[pos][x] = cln, pos = link[pos];     return now;   }   string s;   long long beg[maxn], nex[maxn], to[maxn], e;   inline void add(long long x, long long y) {     e++;     nex[e] = beg[x];     beg[x] = e;     to[e] = y;   }   long long val[maxn], k;   inline void dfs(long long x) {     for (long long i = beg[x]; i; i = nex[i]) dfs(to[i]), size[x] += size[to[i]];     val[size[x]] += (len[x] - len[link[x]]);   }   inline void pre() {     for (long long i = 0; i <= tot; i++) {       val[i] = beg[i] = len[i] = size[i] = link[i] = 0;       for (long long j = 1; j <= 26; j++) nxt[i][j] = 0;     }     e = tot = 0;   }   signed main() {     T = read();     while (T--) {       pre();       cin >> s;       n = s.size();       s =     + s;       last = ++tot;       for (long long i = 1; i <= n; i++) last = extend(last, s[i] - 96);       for (long long i = 2; i <= tot; i++) add(link[i], i);       dfs(1);       long long ans = 0;       for (long long i = n; i >= 1; i--) ans += val[i] * i * i;       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct poi {     int x, y;     poi operator-(poi p) { return (poi){x - p.x, y - p.y}; }     long long operator*(poi p) { return 1ll * x * p.y - 1ll * y * p.x; }   } A[205], a[205];   bool cmp(poi x, poi y) { return x * y > 0; }   bool turn(int x, int y, int z) { return (a[y] - a[x]) * (a[z] - a[y]) > 0; }   int b[205 << 1], v[205 * 205], f[205 * 205], tot;   int q[205][205], l[205], r[205];   int n, nn, m;   long long d[205][205][55], w[55], ans;   void add(int x, int y) { v[++tot] = y, f[tot] = b[x], b[x] = tot; }   void link(int x, int y) {     for (; l[x] < r[x] && turn(q[x][l[x]], x, y); ++l[x]) link(q[x][l[x]], y);     add(x + nn, y);     add(y, x);     q[y][r[y]++] = x;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d%d , &A[i].x, &A[i].y);     ans = 0;     for (int i = 1; i <= n; ++i) {       nn = 0;       for (int j = 1; j <= n; ++j)         if (i != j && A[i].x <= A[j].x) a[++nn] = A[j] - A[i];       sort(a + 1, a + nn + 1, cmp);       memset(b, 0, sizeof b);       tot = 0;       memset(l, 0, sizeof l);       memset(r, 0, sizeof r);       for (int j = 1; j <= nn - 1; ++j) link(j, j + 1);       for (int j = 1; j <= nn; ++j)         for (int k = b[j + nn]; k; k = f[k])           for (int p = 0; p <= m; ++p) d[j][v[k]][p] = 0;       for (int j = nn; j; --j) {         memset(w, 0, sizeof w);         int k = b[j + nn];         for (int p = b[j]; p; p = f[p]) {           d[v[p]][j][0] = 0;           d[v[p]][j][1] = a[v[p]] * a[j];           for (int u = 2; u <= m; ++u)             d[v[p]][j][u] = w[u - 1] > 0 ? w[u - 1] + a[v[p]] * a[j] : 0;           for (; k && turn(v[p], j, v[k]); k = f[k])             for (int u = 1; u <= m; ++u)               if (d[j][v[k]][u - 1] > w[u - 1])                 w[u - 1] = d[j][v[k]][u - 1],                       d[v[p]][j][u] = w[u - 1] + a[v[p]] * a[j];         }       }       for (int j = 1; j <= nn; ++j)         for (int k = b[j + nn]; k; k = f[k]) ans = max(ans, d[j][v[k]][m - 2]);     }     printf( %lld , ans >> 1);     puts(ans & 1 ?  .50  :  .00 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int a, b, c, d;       cin >> a >> b >> c >> d;       cout << max(a + b, c + d) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, sz;   int par[4000005];   int findpar(int x) {     if (par[x] == x) return par[x];     par[x] = findpar(par[x]);     return par[x];   }   int cr, cc;   int pr, pc;   void decode(int x) {     if (x < m) {       cr = 0;       cc = x;     } else if (x < m + n - 1) {       cr = x - m + 1;       cc = m - 1;     } else if (x < 2 * m + n - 2) {       cr = n - 1;       cc = m - 1 - (x - (m + n - 2));     } else {       cr = n - 1 - (x - (2 * m + n - 3));       cc = 0;     }   }   int encode(int r, int c) {     if (r == 0) return c;     if (c == m - 1) return m - 1 + r;     if (r == n - 1) return m + n - 2 + m - 1 - c;     if (c == 0) return 2 * m + n - 3 + n - 1 - r;   }   bool inrange(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }   void go(int r, int c, int dr, int dc) {     int x;     if (dr == -1 && dc == -1) x = min(r, c);     if (dr == -1 && dc == 1) x = min(r, m - 1 - c);     if (dr == 1 && dc == -1) x = min(n - 1 - r, c);     if (dr == 1 && dc == 1) x = min(n - 1 - r, m - 1 - c);     pr = r + x * dr;     pc = c + x * dc;   }   int main() {     cin >> n >> m;     sz = 2 * (n + m) - 4;     for (int i = 0; i < sz; ++i) par[i] = i;     for (int i = 0; i < sz; ++i) {       decode(i);       for (int dr = -1; dr <= 1; dr += 2)         for (int dc = -1; dc <= 1; dc += 2) {           if (inrange(cr + dr, cc + dc)) {             go(cr, cc, dr, dc);             int x = encode(pr, pc);             int px = findpar(x);             int pi = findpar(i);             if (px != pi) {               par[max(pi, px)] = min(pi, px);             }           }         }     }     set<int> st;     for (int i = 0; i < sz; ++i) st.insert(findpar(i));     cout << st.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long r;     cin >> r;     if ((r - 1) % 2 == 0 && r > 3)       cout << 1 <<     << (r - 3) / 2;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int const nmax = 3000;   int const modulo = 1000000007;   char v[1 + nmax][1 + nmax];   int dp[1 + nmax][1 + nmax];   int solve(int x, int y, int x2, int y2) {     for (int i = 1; i <= x2; i++)       for (int j = 1; j <= y2; j++) dp[i][j] = 0;     dp[x][y] = 1;     for (int i = 1; i <= x2; i++)       for (int j = 1; j <= y2; j++) {         dp[i][j] += dp[i - 1][j] + dp[i][j - 1];         if (modulo <= dp[i][j]) dp[i][j] -= modulo;         if (v[i][j] ==  # ) dp[i][j] = 0;       }     return dp[x2][y2];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> v[i][j];     int result = 1LL * solve(1, 2, n - 1, m) * solve(2, 1, n, m - 1) % modulo;     int result2 = 1LL * solve(1, 2, n, m - 1) * solve(2, 1, n - 1, m) % modulo;     cout << (modulo + result - result2) % modulo;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fastpow(int a, int b) {     int ans = 1;     for (; b; b >>= 1, a = a * a)       if (b & 1) ans = ans * a;     return ans;   }   int num;   int main() {     int n;     scanf( %d , &n);     string a;     cin >> a;     for (int i = 0; i < a.length(); i++) n += (a[i] -  0 ) * fastpow(10, i);     printf( %d , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     for (int z = 0; z < n; z++) {       long long a, b, c;       cin >> a >> b;       while ((c = a | a + 1) <= b) a = (a | a + 1);       cout << a << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   const double PI = atan(1.0) * 4;   const int di[4] = {-1, 0, 1, 0};   const int dj[4] = {0, -1, 0, 1};   const long long INF = (long long)2e18 + 50;   const int maximum = numeric_limits<int>::min();   const int minimum = numeric_limits<int>::max();   constexpr int N = 2e6, P = 1000000007;   int a[N + 1], b[N + 1];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     for (int i = 1; i <= N; ++i) {       a[i] = (2ll * a[i - 2] + a[i - 1]) % P;       if (b[i - 1] && b[i - 2]) {         a[i] = (a[i] + 1) % P;       } else {         b[i] = 1;       }     }     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       cout << 4ll * a[n] % P <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   const int N = 5050;   int a[N];   int dp[N][N];   int cnt[N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cerr.setstate(ios_base::failbit);     cin >> n >> k;     for (int i = 1; i < (n + 1); i++) cin >> a[i];     sort(a + 1, a + n + 1);     int j = n;     for (int i = (n + 1) - 1; i >= 1; i--) {       while (j > 0 && abs(a[j] - a[i]) <= 5) j--;       cnt[i] = i - j;     }     for (int i = 1; i < (n + 1); i++)       for (int j = 1; j < (k + 1); j++) {         int &ans = dp[i][j];         ans = max(ans, dp[i - 1][j]);         ans = max(ans, dp[i - cnt[i]][j - 1] + cnt[i]);       }     cout << dp[n][k] <<   n ;   }
#include  bits/stdc++.h    using namespace std;   #define ll long long   #define llu unsigned long long   #define PB push_back   #define F first   #define S second   #define sz(a) ((ll)a.size())   const ll MOD = 1000000007;   const ll INF = 1000000000000000007;   #ifdef ONLINE_JUDGE   #define ck(x...)   #endif      void AC_aaega(){    ll n;    cin>>n;    vector < vector < ll > > vv(n, vector < ll >(n, 0));    vector < ll > k1(10, INF);    vector < ll > k2(10, -1);    vector < ll > q1(10, INF);    vector < ll > q2(10, -1);    for(ll i =0;i<n;i++){     string s;     cin>>s;     for(ll j= 0;j<n;j++){      vv[i][j] = s[j] -  0 ;      k1[vv[i][j]] = min(k1[vv[i][j]], j);      k2[vv[i][j]] = max(k2[vv[i][j]], j);      q1[vv[i][j]] = min(q1[vv[i][j]], i);      q2[vv[i][j]] = max(q2[vv[i][j]], i);     }    }     ck(k1, k2, q1, q2);    for(ll i= 0;i<10;i++){     ll ans =0, ff =-1, ss = -1;     for(ll j =0;j<n;j++){      for(ll k =0;k<n;k++){       if(vv[j][k] == i){        if(ff == -1){         ff = k;        }        else{         ss = k;        }       }      }      if(ss != -1 && ff != -1){       ans = max(ans, (ss - ff) * max(j, n - 1 - j));       ck(j, ss, ff);      }      if(ff != -1){       ll qw = q1[i], wq = q2[i];       if(qw != INF && wq != -1){        ans = max(ans, max(abs(n-1-ff), ff) * max(j - qw, wq - j));       }       // else if(qw != -1){       //  ans = max(ans, max(abs(n-1-ff), ff) * j-qw);       // }      }      if(ss != -1){       ll qw = q1[i], wq = q2[i];       if(qw != INF && wq != -1){        ans = max(ans, max(abs(n-1-ss), ss) * max(j - qw, wq - j));       }       // else if(qw != -1){       //  ans = max(ans, max(abs(n-1-ff), ff) * j-qw);       // }      }      ff = ss = -1;     }     ck(ans);     for(ll j =0;j<n;j++){      for(ll k =0;k<n;k++){       if(vv[k][j] == i){        if(ff == -1){         ff = k;        }        else{         ss = k;        }       }      }      if(ss != -1 && ff != -1){       ans = max(ans, (ss - ff) * max(j, n - 1 - j));      }      if(ff != -1){       ll qw = k1[i], wq = k2[i];       if(qw != INF && wq != -1){        ans = max(ans, max(abs(n-1-ff), ff) * max(j - qw, wq - j));       }       ck(ff, qw, wq);       // else if(qw != -1){       //  ans = max(ans, max(abs(n-1-ff), ff) * j-qw);       // }      }      if(ss != -1){       ll qw = k1[i], wq = k2[i];       if(qw != INF && wq != -1){        ans = max(ans, max(abs(n-1-ss), ss) * max(j - qw, wq - j));       }       ck(ss, qw, wq);       // else if(qw != -1){       //  ans = max(ans, max(abs(n-1-ff), ff) * j-qw);       // }      }      ff = ss = -1;     }     cout<<ans<<   ;    }    cout<<  n ;   }      int main(){    ios_base::sync_with_stdio(0);    cin.tie(0);    cout.tie(0);    cerr.tie(0);    #ifndef ONLINE_JUDGE      freopen( /home/theviralv/Desktop/input.txt ,  r , stdin);      freopen( /home/theviralv/Desktop/output.txt ,  w , stdout);      freopen( /home/theviralv/Desktop/err.txt ,  w , stderr);    #endif    ll testcases = 1;    cin>>testcases;    while(testcases--){     AC_aaega();    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 0.001;   const int mod = 1000000007;   int main() {     int n, pos, l, r, ans;     scanf( %d%d%d%d , &n, &pos, &l, &r);     if (l == 1 && r == n)       ans = 0;     else if (l == 1)       ans = abs(pos - r) + 1;     else if (r == n)       ans = abs(pos - l) + 1;     else       ans = min(abs(pos - l), abs(pos - r)) + r - l + 2;     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int q, s1, s2, s3, w, m, e;     vector<long long int> v;     cin >> q;     long long int n;     for (int i = 0; i < q; i++) {       cin >> n;       long long int a[n];       s1 = 0;       s2 = 0;       s3 = 0;       for (int j = 0; j < n; j++) {         cin >> a[j];         if (a[j] % 3 == 0) {           s3++;         } else if (a[j] % 3 == 1) {           s1++;         } else if (a[j] % 3 == 2) {           s2++;         }       }       w = (s3 + min(s1, s2));       m = s1;       e = s2;       m -= min(s1, s2);       e -= min(s1, s2);       s1 = m;       s2 = e;       w += s1 / 3;       w += s2 / 3;       v.push_back(w);     }     for (int i = 0; i < q; i++) {       cout << v[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   const int inf = 1e9;   struct node {     int s, ind;   } f[maxn];   int sum[maxn];   int cmp(node a, node b) {     if (a.s == b.s) return a.ind < b.ind;     return a.s < b.s;   }   int main() {     int i, n, c, re = 0, value;     scanf( %d%d , &n, &c);     for (i = 1; i <= n; i++) {       scanf( %d , &f[i].s);       f[i].ind = i;       sum[i] = sum[i - 1] + (f[i].s == c);     }     sort(f + 1, f + n + 1, cmp);     for (i = 1; i <= n; i++) {       if (f[i].s == c) continue;       if (f[i].s != f[i - 1].s) {         value = 1;         re = max(re, value);         continue;       }       value -= (sum[f[i].ind - 1] - sum[f[i - 1].ind]);       if (value < 0) value = 0;       value++;       re = max(re, value);     }     printf( %d , re + sum[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void print_err() { cerr <<   n ; }   template <class T, class... Arg>   void print_err(T x, Arg &&...args) {     cerr << x <<    ;     print_err(args...);   }   template <class T>   void print_container(T &cont) {     for (auto iter : cont) {       cerr << iter <<    ;     }     cerr <<   n ;   }   int mod = 998244353;   long long ceil(long long a, long long b) { return (a + b - 1) / b; }   long long gcd(long long a, long long b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   vector<int> d4x{0, 0, 1, -1};   vector<int> d4y{-1, 1, 0, 0};   vector<int> d8x{0, 0, 1, -1, 1, 1, -1, -1};   vector<int> d8y{1, -1, 0, 0, -1, 1, 1, -1};   vector<long long> B(1e5 + 1, -1), C(1e5 + 1, -1);   void solve(int test) {     ;     int n;     cin >> n;     vector<int> A(n);     for (int &a : A) {       cin >> a;     }     long long ans = 0;     vector<long long> dp1, dp2;     int j;     long long val;     for (int i = n - 1; i >= 0; --i) {       for (auto iter : dp1) {         j = iter;         val = B[j];         if (val < 0) {           ;         }         if (val > 0) {           if (j >= A[i]) {             if (C[A[i]] == -1) {               dp2.push_back(A[i]);               C[A[i]] = val;               C[A[i]] %= mod;             } else {               C[A[i]] += val;               C[A[i]] %= mod;             }           } else {             if (C[A[i] / ceil(A[i], j)] == -1) {               dp2.push_back(A[i] / ceil(A[i], j));               C[A[i] / ceil(A[i], j)] = val;               ans += (i + 1) * (ceil(A[i], j) - 1) * val;               ans %= mod;               C[A[i] / ceil(A[i], j)] %= mod;             } else {               C[A[i] / ceil(A[i], j)] += val;               ans += (i + 1) * (ceil(A[i], j) - 1) * val;               ans %= mod;               C[A[i] / ceil(A[i], j)] %= mod;             }           }         }         B[j] = -1;       }       dp1.clear();       swap(dp1, dp2);       swap(B, C);       if (B[A[i]] == -1) {         dp1.push_back(A[i]);         B[A[i]] = 1;       } else {         B[A[i]]++;         B[A[i]] %= mod;       }     }     for (int j : dp1) {       B[j] = -1;     }     cout << ans << endl;   }   int main() {     int i = 1;     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int test_cases;     cin >> test_cases;     for (i = 1; i <= test_cases; ++i) solve(i);     return 0;   }