malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     register long long w = 1, x = 0, ch = getchar();     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) w = -1;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch -  0 ;     return x * w;   }   const long long MAXN = (long long)7e2 + 10;   const long long MOD = (long long)1e9 + 7;   const long long INF = 0x3f3f3f3f3f3f3f3f;   char s[MAXN];   long long n, ans, digit[MAXN], Dec[MAXN], divv[MAXN][10], f[MAXN][MAXN][10][2];   inline void Init() {     cin >> s + 1;     n = strlen(s + 1);     for (register long long i = 1; i <= n; i++) {       digit[i] = s[i] -  0 ;     }   }   inline void DP() {     Dec[0] = 1;     for (register long long i = 1; i <= n; i++) {       Dec[i] = Dec[i - 1] * 10 % MOD;     }     for (register long long i = 0; i <= 9; i++) {       f[0][0][i][1] = 1;     }     for (register long long i = 0; i < n; i++) {       for (register long long j = 0; j <= i; j++) {         for (register long long x = 1; x <= 9; x++) {           for (register long long l = 0; l <= 1; l++) {             for (register long long k = 0; k <= (l ? digit[i + 1] : 9); k++) {               f[i + 1][j + (k >= x)][x][(k == digit[i + 1]) && l] +=                   f[i][j][x][l];               f[i + 1][j + (k >= x)][x][(k == digit[i + 1]) && l] %= MOD;             }           }         }       }     }     for (register long long x = 1; x <= 9; x++) {       for (register long long j = 1; j <= n; j++) {         for (register long long i = j; i <= n; i++)           divv[j][x] = (divv[j][x] + f[n][i][x][1] + f[n][i][x][0]) % MOD;       }     }     for (register long long i = 1; i <= n; i++) {       for (register long long x = 1; x <= 9; x++) {         ans = (ans + (divv[i][x] - divv[i][x + 1] + MOD) % MOD * Dec[i - 1] %                          MOD * x % MOD) %               MOD;       }     }     printf( %lld n , ans);   }   signed main() {     Init();     DP();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[20];   int main() {     memset(dp, 0, sizeof(dp));     long long n, i, dig;     cin >> dig;     cin >> n;     while (n != 0) {       long long r = n % 10;       if (r == 0 || r == 1) {         n = n / 10;         continue;       }       if (r >= 9) dp[3] += 2;       if (r >= 8) dp[2] += 3;       if (r >= 7) dp[7] += 1;       if (r >= 6) {         dp[2] += 1;         dp[3] += 1;       }       if (r >= 5) dp[5] += 1;       if (r >= 4) dp[2] += 2;       if (r >= 3) dp[3] += 1;       if (r >= 2) dp[2] += 1;       n = n / 10;     }     vector<long long> v;     while (dp[7] >= 1 && dp[5] >= 1 && dp[3] >= 2 && dp[2] >= 4) {       v.push_back(7);       dp[7] -= 1;       dp[5] -= 1;       dp[3] -= 2;       dp[2] -= 4;     }     while (dp[5] >= 1 && dp[3] >= 1 && dp[2] >= 3) {       v.push_back(5);       dp[5] -= 1;       dp[3] -= 1;       dp[2] -= 3;     }     while (dp[3] >= 1 && dp[2] >= 1) {       v.push_back(3);       dp[3] -= 1;       dp[2] -= 1;     }     while (dp[2] >= 1) {       v.push_back(2);       dp[2] -= 1;     }     for (i = 0; i < v.size(); i++) {       cout << v.at(i);     }   }
#include <bits/stdc++.h>   #pragma gcc optimize( Ofast )   using namespace std;   inline void input(int &_x) {     _x = 0;     int _tmp = 1;     char _tc = getchar();     while ((_tc <  0  || _tc >  9 ) && _tc !=  - ) _tc = getchar();     if (_tc ==  - ) _tc = getchar(), _tmp = -1;     while (_tc >=  0  && _tc <=  9 ) _x = _x * 10 + (_tc - 48), _tc = getchar();     _x *= _tmp;   }   int root[400009], tag[400009];   int aa[100009];   inline void build(int id, int l, int r) {     if (l == r) {       root[id] = aa[l];       return;     }     int mid = (l + r) >> 1;     build((id << 1), l, mid);     build((id << 1) + 1, mid + 1, r);     root[id] = max(root[(id << 1)], root[(id << 1) + 1]);   }   inline void push(int id) {     root[id] += tag[id];     tag[(id << 1)] += tag[id];     tag[(id << 1) + 1] += tag[id];     tag[id] = 0;   }   inline void modify(int id, int l, int r, int ql, int qr, int v) {     if (tag[id]) push(id);     if (ql <= l && r <= qr) {       tag[id] += v;       push(id);       return;     }     if (qr < l || r < ql) return;     int mid = (l + r) >> 1;     modify((id << 1), l, mid, ql, qr, v);     modify((id << 1) + 1, mid + 1, r, ql, qr, v);     root[id] = max(root[(id << 1)], root[(id << 1) + 1]);   }   int n, m;   vector<int> seg[100009];   bitset<100009> vis;   inline bool cmp(int a, int b) { return aa[a] < aa[b]; }   signed main() {     int ma = -1;     input(n);     input(m);     for (int i = 1; i < n + 1; ++i) input(aa[i]), ma = max(ma, aa[i]);     vector<pair<int, int> > v(m), w;     for (auto &i : v) input(i.first), input(i.second);     for (int i = 1; i < n + 1; ++i) w.emplace_back(aa[i], i);     sort((w).begin(), (w).end());     int ans = -1, p = 0;     build(1, 1, n);     for (int i = 1; i < n + 1; ++i)       for (int j = 0; j < m; ++j)         if (v[j].first <= i && i <= v[j].second) seg[i].emplace_back(j);     for (int _ = 0; _ < n; ++_) {       int i = w[_].second;       if (ans > ma - (aa[i] - (int)(seg[i]).size())) continue;       int cnt = 0;       for (auto &j : seg[i]) modify(1, 1, n, v[j].first, v[j].second, -1), ++cnt;       if (root[1] - (aa[i] - cnt) > ans) {         ans = root[1] - (aa[i] - cnt);         p = i;       }       for (auto &j : seg[i]) modify(1, 1, n, v[j].first, v[j].second, 1);     }     cout << ans <<   n  << (int)(seg[p]).size() <<   n ;     for (auto &i : seg[p]) cout << i + 1 <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k = 100000000, t;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 1; i < n; i++) {       t = max(a[i - 1], a[i]);       k = min(t, k);     }     cout << min(min(a[0], a[n - 1]), k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int ar1[100], ar2[100];     memset(ar1, 0, sizeof(ar1));     memset(ar2, 0, sizeof(ar2));     string s1, s2;     cin >> s1 >> s2;     int t;     cin >> t;     vector<pair<pair<int, char>, pair<int, char> > > v(t);     for (int i = 0; i < t; i++)       cin >> v[i].first.first >> v[i].first.second >> v[i].second.first >>           v[i].second.second;     sort(v.begin(), v.end());     for (int i = 0; i < t; i++) {       if (v[i].first.second ==  a ) {         if (ar2[v[i].second.first] < 2) {           ar2[v[i].second.first] += (v[i].second.second ==  y ) ? 1 : 2;           if (ar2[v[i].second.first] >= 2)             cout << s2 <<     << v[i].second.first <<     << v[i].first.first                  << endl;         }       } else if (v[i].first.second ==  h ) {         if (ar1[v[i].second.first] < 2) {           ar1[v[i].second.first] += (v[i].second.second ==  y ) ? 1 : 2;           if (ar1[v[i].second.first] >= 2)             cout << s1 <<                      <<     << v[i].second.first <<     << v[i].first.first << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int arrmax = 200005;   char str[arrmax];   int reversetimes[arrmax / 2];   int main() {     int m, a, sum, len;     while (~scanf( %s %d , str, &m)) {       len = strlen(str);       memset(reversetimes, 0, 2 * len);       while (m--) {         scanf( %d , &a);         reversetimes[a - 1]++;       }       sum = 0;       for (int i = 0; i < len / 2; i++) {         sum += reversetimes[i];         if (sum & 1) swap(str[i], str[len - i - 1]);       }       printf( %s n , str);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   string res[101];   int dx[] = {0, 0, -1, 1};   int dy[] = {-1, 1, 0, 0};   inline bool in(int x, int y) {     if (x < 0 || y < 0 || x >= n || y >= m) return 0;     return 1;   }   int main(int argc, char **argv) {     cin >> n >> m;     for (int i = 0; i <= n - 1; i++) {       cin >> res[i];     }     int c = 1;     for (int i = 0; i <= n - 1; i++) {       c = i % 2;       for (int j = 0; j <= m - 1; j++) {         if (res[i][j] ==  . ) {           if (c)             res[i][j] =  B ;           else             res[i][j] =  W ;         }         if (c == 1)           c = 0;         else           c = 1;       }     }     for (int i = 0; i <= n - 1; i++) cout << res[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x, y, a, b, c, ans;   int main() {     cin >> x >> y;     if (x > y) swap(x, y);     a = b = c = x;     while (true) {       a = b + c - 1;       ans++;       if (a >= y) break;       b = a + c - 1;       ans++;       if (b >= y) break;       c = a + b - 1;       ans++;       if (c >= y) break;     }     cout << ans + 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[500011], L[500011], R[500011], aL[500011], aR[500011],       ans[500011];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (long long i = 1; i <= n; i++) cin >> a[i];     stack<pair<long long, long long> > st;     for (long long i = 1; i <= n; i++) {       while (!st.empty() && st.top().first >= a[i]) st.pop();       if (st.empty())         L[i] = 0;       else {         L[i] = st.top().second;       }       st.push(pair<long long, long long>(a[i], i));     }     while (!st.empty()) st.pop();     for (long long i = n; i >= 1; i--) {       while (!st.empty() && st.top().first >= a[i]) st.pop();       if (st.empty())         R[i] = n + 1;       else         R[i] = st.top().second;       st.push(pair<long long, long long>(a[i], i));     }     for (long long i = 1; i <= n; i++) {       aL[i] = aL[L[i]] + a[i] * (i - L[i]);     }     for (long long i = n; i >= 1; i--) {       aR[i] = aR[R[i]] + a[i] * (R[i] - i);     }     long long A = 0, pos = 0;     for (long long i = 1; i <= n; i++) {       if (aL[i] + aR[i] - a[i] > A) {         A = aL[i] + aR[i] - a[i];         pos = i;       }     }     ans[pos] = a[pos];     long long cur_min = ans[pos];     for (long long i = pos - 1; i >= 1; i--) {       ans[i] = min(a[i], cur_min);       cur_min = min(a[i], cur_min);     }     cur_min = ans[pos];     for (long long i = pos + 1; i <= n; i++) {       ans[i] = min(a[i], cur_min);       cur_min = min(a[i], cur_min);     }     for (long long i = 1; i <= n; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     string s;     cin >> n;     cin >> s;     map<char, long long int> M;     long long int i;     for (i = 0; i < n; i++) {       M[s[i]]++;     }     long long int z = n / 3;     if (M[ 0 ] < z) {       for (i = 0; i < n; i++) {         if (M[s[i]] > z && s[i] !=  0  && M[ 0 ] < z) {           M[s[i]]--;           s[i] =  0 ;           M[ 0 ]++;         }       }     }     if (M[ 2 ] < z) {       for (i = n - 1; i >= 0; i--) {         if (M[s[i]] > z && s[i] !=  2  && M[ 2 ] < z) {           M[s[i]]--;           s[i] =  2 ;           M[ 2 ]++;         }       }     }     if (M[ 1 ] < z) {       for (i = n - 1; i >= 0; i--) {         if (M[s[i]] > z && s[i] ==  0  && M[ 1 ] < z) {           M[s[i]]--;           s[i] =  1 ;           M[ 1 ]++;         }       }       for (i = 0; i < n; i++) {         if (M[s[i]] > z && s[i] ==  2  && M[ 1 ] < z) {           M[s[i]]--;           s[i] =  1 ;           M[ 1 ]++;         }       }     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char buf[100], name[100], op[100], tmp[100];   struct widget {     long long x, y;     bool finish;     int type, border, spacing;     vector<int> w;     widget(long long xx = 0, long long yy = 0, int t = 0) {       x = xx;       y = yy;       type = t;       w = vector<int>();       finish = false;       border = spacing = 0;     }     void gao(){};   } wid[110];   map<string, int> mp;   void gao(int id) {     if (wid[id].finish || wid[id].type == 0) return;     long long &x = wid[id].x;     long long &y = wid[id].y;     x = y = 0;     for (int i = 0; i < ((int)wid[id].w.size()); ++i) {       int z = wid[id].w[i];       gao(z);       if (wid[id].type == 1) {         x += wid[z].x + wid[id].spacing;         y = max(y, wid[z].y);       } else {         y += wid[z].y + wid[id].spacing;         x = max(x, wid[z].x);       }     }     wid[id].finish = true;     if (((int)wid[id].w.size()) == 0) return;     if (wid[id].type == 1) {       x += wid[id].border * 2 - wid[id].spacing;       y += wid[id].border * 2;     } else {       y += wid[id].border * 2 - wid[id].spacing;       x += wid[id].border * 2;     }   }   void solve() {     mp.clear();     int x, y, tot = 0;     for (int i = 0; i < n; ++i) {       scanf( %s , buf);       if (string(buf) ==  Widget ) {         scanf( %s , buf);         sscanf(buf,  %[^(](%d,%d) , name, &x, &y);         mp[name] = tot;         wid[tot++] = widget(x, y, 0);       } else if (string(buf) ==  HBox ) {         scanf( %s , buf);         mp[buf] = tot;         wid[tot++] = widget(-1, -1, 1);       } else if (string(buf) ==  VBox ) {         scanf( %s , buf);         mp[buf] = tot;         wid[tot++] = widget(-1, -1, 2);       } else {         sscanf(buf,  %[^.].%[^(](%[^)] , name, op, tmp);         int id = mp[name];         if (string(op) ==  set_border ) {           sscanf(tmp,  %d , &x);           wid[id].border = x;         } else if (string(op) ==  set_spacing ) {           sscanf(tmp,  %d , &x);           wid[id].spacing = x;         } else {           wid[id].w.push_back(mp[tmp]);         }       }     }     map<string, int>::iterator it = mp.begin();     for (; it != mp.end(); ++it) {       int id = it->second;       gao(id);       printf(            %s              %I64d                           %I64d              n ,           it->first.c_str(), wid[id].x, wid[id].y);     }     puts(  );   }   int main() {     while (scanf( %d , &n) != EOF) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[5], sum = 0;     for (int i = 0; i < 5; i++) {       cin >> a[i];       sum += a[i];     }     n = sum / 5;     if (sum == 0)       cout << -1;     else if (n * 5 == sum)       cout << n;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool b[150000] = {0};   bool dfs(int n, vector<set<int>>& v) {     b[n] = 1;     for (auto itr = v[n].begin(); itr != v[n].end(); itr++) {       if (!b[*itr])         if (v[n] != v[*itr]) return 0;       if (!b[*itr]) dfs(*itr, v);     }     return 1;   }   int main() {     int n, m;     cin >> n >> m;     vector<set<int>> v(n);     for (int i = 0; i < n; i++) v[i].insert(i);     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       v[a].insert(b);       v[b].insert(a);     }     bool r = 1;     for (int i = 0; i < n && r; i++) {       if (!b[i]) {         if (!dfs(i, v)) r = 0;       }     }     cout << (r ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3 * 1e5 + 10, maxm = (1 << 17), mod = 1e9 + 7;   const double PI = 3.14159265359;   vector<int> g[maxn];   int d[maxn];   bool r[maxn];   set<int> s;   int main() {     ios::sync_with_stdio(0);     int n, a, b, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> a >> b;       a--, b--;       g[a].push_back(b), g[b].push_back(a);     }     for (int i = 0; i < n; i++) {       d[i] = g[i].size();       if (g[i].size() > 1) s.insert(i);     }     while (s.size()) {       a = *s.begin();       s.erase(s.begin());       r[a] = !r[a], d[a] = g[a].size() - d[a];       for (int i = 0; i < g[a].size(); i++) {         b = g[a][i];         d[b] += (r[a] == r[b] ? 1 : -1);         if (d[b] > 1)           s.insert(b);         else           s.erase(b);       }     }     for (int i = 0; i < n; i++) cout << r[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int t, d, p, id;   } s[110];   int dp[2010];   vector<int> v[2010];   int cmp(node a, node b) { return a.d < b.d; }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &s[i].t, &s[i].d, &s[i].p), s[i].id = i;     }     sort(s + 1, s + n + 1, cmp);     for (int i = 1; i <= n; i++) {       if (s[i].d - s[i].t <= 0) continue;       for (int j = s[i].d - 1; j - s[i].t >= 0; j--) {         if (dp[j] < dp[j - s[i].t] + s[i].p) {           dp[j] = dp[j - s[i].t] + s[i].p;           v[j] = v[j - s[i].t];           v[j].push_back(s[i].id);         }       }     }     int best = 0, bestI = 0;     for (int i = 0; i <= 2000; i++) {       if (dp[i] > best) {         best = dp[i];         bestI = i;       }     }     printf( %d n , best);     printf( %d n , v[bestI].size());     for (int i = 0; i < v[bestI].size(); i++) printf( %d  , v[bestI][i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a;     int cnt = 0;     int sum = 0;     for (int i = 0; i < 2 * n - 1; ++i) {       int x;       cin >> x;       a.push_back(abs(x));       if (x < 0) cnt++;       sum += abs(x);     }     cnt %= n;     queue<int> q;     vector<bool> used(n + 1, false);     used[cnt] = 1;     q.push(cnt);     int c = cnt;     while (!q.empty()) {       int u = q.front();       q.pop();       if (!used[n - u]) {         used[n - u] = 1;         q.push(n - u);         c = min(c, n - u);       }       for (int i = 1; i <= u; ++i) {         int to = u - i + n - i;         to %= n;         if (to >= 0 && !used[to]) {           used[to] = 1;           q.push(to);           c = min(c, to);         }       }     }     sort(a.begin(), a.end());     if (c == 0) {       cout << sum;     } else {       for (int i = 0; i < c; ++i) {         sum -= 2 * a[i];       }       cout << sum;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char **argv) {     ios_base::sync_with_stdio(false);     cin.tie(0);     int m, n;     cin >> n >> m;     vector<string> s(n);     vector<pair<int, int>> t(n, {-1, -1});     for (int i = 0; i < n; i++) cin >> s[i];     bool ok = true;     for (int i = 0; i < n; i++) {       int k = 0;       for (int j = 0; j < m; j++) {         if (s[i][j] ==  X ) {           if (!j || s[i][j - 1] ==  . ) k++;           if (t[i].first < 0) t[i].first = j;           t[i].second = j;         }       }       if (k > 1) ok = false;     }     int k = 0;     pair<int, int> u({-1, -1});     for (int i = 0; i < n; i++) {       if (t[i].first < 0) continue;       if (!i || t[i - 1].first < 0) k++;       if (u.first < 0) u = t[i];       if (u != t[i]) ok = false;     }     if (k > 1) ok = false;     cout << (ok ?  YES  :  NO ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ii = pair<int, int>;   using vi = vector<int>;   using vvi = vector<vi>;   using vii = vector<ii>;   using vb = vector<bool>;   using ll = long long;   template <typename A, typename B>   istream &operator>>(istream &in, pair<A, B> &p) {     in >> p.first >> p.second;     return in;   }   template <typename T>   istream &operator>>(ifstream &in, vector<T> &v) {     for (int i = 0; i < (int)v.size(); ++i) {       in >> v[i];     }     return in;   }   int main() {     int n, k;     cin >> n >> k;     vector<set<int>> times(n);     for (int i = 0; i < k; ++i) {       int x;       cin >> x;       x--;       times[x].insert(i);     }     int res = 0;     for (int x = 0; x < n; ++x) {       if (times[x].empty()) {         res += 3;         if (x == 0) res--;         if (x == n - 1) res--;       } else {         int t = *times[x].begin();         if (x != n - 1 && times[x + 1].lower_bound(t) == times[x + 1].end())           res++;         if (x != 0 && times[x - 1].lower_bound(t) == times[x - 1].end()) res++;       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool fun(int x, int y) { return x > y; }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ;     int n, s;     cin >> n >> s;     if (s <= n) {       cout << 1 <<   n ;     }     if (s > n && s % n == 0) {       cout << s / n <<   n ;     }     if (s > n && s % n != 0) {       cout << s / n + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream& operator<<(ostream& os, vector<T> V) {     os <<  [  ;     for (auto v : V) os << v <<    ;     return os <<  ] ;   }   template <class T>   ostream& operator<<(ostream& os, set<T> S) {     os <<  {  ;     for (auto s : S) os << s <<    ;     return os <<  } ;   }   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> P) {     return os <<  (  << P.first <<  ,  << P.second <<  ) ;   }   template <class L, class R>   ostream& operator<<(ostream& os, map<L, R> M) {     os <<  {  ;     for (auto m : M) os <<  (  << m.F <<  :  << m.S <<  ) ;     return os <<  } ;   }   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   long long const M = 1e9;   bool check(long long v, long long n, long long k) {     long long s = n;     long long d = k;     while (n / k >= 1) {       s = s + n / k;       k = k * d;     }     return (s >= v);   }   int main() {     long long n, k;     cin >> n >> k;     long long l = 0;     long long r = M;     while (r - l > 1) {       long long mid = (l + r) >> 1;       if (check(n, mid, k))         r = mid;       else         l = mid;     }     cout << r <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double ans;   long long one, two;   map<pair<long long, long long>, pair<long long, long long> > o, t;   map<pair<long long, long long>, pair<long long, long long> >::iterator ii;   void add(long long a, long long b, long long c, long long ind) {     pair<long long, long long> p = make_pair(a, b);     if (c > o[p].first && ind != t[p].second) {       t[p] = o[p];       o[p] = {c, ind};     }     if (c > t[p].first && ind != o[p].second) t[p] = {c, ind};   }   int main() {     long long n, i, j;     cin >> n;     for (i = 1; i <= n; i++) {       long long a, b, c;       cin >> a >> b >> c;       long long t = min(a, min(b, c));       long double cur = 1.0 * t / 2;       if (cur > ans) {         ans = cur;         one = i;       }       add(a, b, c, i);       add(a, c, b, i);       add(b, a, c, i);       add(b, c, a, i);       add(c, a, b, i);       add(c, b, a, i);     }     for (ii = t.begin(); ii != t.end(); ii++) {       long long cur = ii->second.first + o[ii->first].first;       long long Min = min(cur, min(ii->first.first, ii->first.second));       long double curans = 1.0 * Min / 2;       if (curans > ans) {         ans = curans;         one = ii->second.second;         two = o[ii->first].second;       }     }     if (one != 0 && two != 0)       cout <<  2 n  << one <<     << two;     else       cout <<  1 n  << one;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     for (int i = 0; i < t; ++i) {       int n, a[150000]{};       cin >> n;       for (int j = 0; j < n; ++j) {         cin >> a[j];       }       int min = a[n - 1], cnt = 0;       for (int j = n - 2; j >= 0; --j) {         if (a[j] < min) {           min = a[j];         } else if (a[j] > min) {           ++cnt;         }       }       cout << cnt <<   n ;     }     return 0;   }