malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 155;   const int INF = 123456789;   struct edge {     int to, lim, pri, rev;     edge() : to(0), lim(0), pri(0), rev(0){};     edge(int to, int lim, int pri, int rev)         : to(to), lim(lim), pri(pri), rev(rev){};   };   vector<edge> nei[N];   char ss[105];   int hv[26];   int n, sl, s, t, cst, flw;   int d[N], f[N], p[N], v[N];   queue<int> q;   void add_edge(int x, int y, int l, int p) {     nei[x].push_back(edge(y, l, p, int(nei[y].size())));     nei[y].push_back(edge(x, 0, -p, int(nei[x].size()) - 1));   }   int spfa() {     for (int i = s; i <= t; i++) {       v[i] = 0;       d[i] = f[i] = INF;     }     d[s] = 0, v[s] = 1;     while (!q.empty()) q.pop();     q.push(s);     while (!q.empty()) {       int x = q.front();       q.pop();       v[x] = 0;       for (int i = 0; i < nei[x].size(); i++) {         int to = nei[x][i].to;         int lim = nei[x][i].lim;         int pri = nei[x][i].pri;         int rev = nei[x][i].rev;         if (lim == 0) continue;         if (d[to] > d[x] + pri) {           p[to] = rev;           d[to] = d[x] + pri;           f[to] = min(f[x], lim);           if (!v[to]) {             v[to] = 1;             q.push(to);           }         }       }     }     return d[t] != INF;   }   void mcmf() {     while (spfa()) {       flw += f[t];       cst += d[t] * f[t];       int x = t;       while (x != s) {         int r = p[x];         int to = nei[x][r].to;         int rev = nei[x][r].rev;         nei[x][r].lim += f[t];         nei[to][rev].lim -= f[t];         x = to;       }     }   }   int main() {     scanf( %s , &ss);     sl = strlen(ss);     int Sl = sl;     for (int i = 0; i < sl; i++) hv[ss[i] -  a ]++;     scanf( %d , &n);     s = 1;     t = n + 28;     for (int i = 0; i < 26; i++)       if (hv[i]) {         add_edge(n + 2 + i, t, hv[i], 0);         hv[i] = 0;       }     for (int i = 1; i <= n; i++) {       int x;       scanf( %s%d , ss, &x);       sl = strlen(ss);       for (int j = 0; j < sl; j++) hv[ss[j] -  a ]++;       add_edge(s, i + 1, x, 0);       for (int j = 0; j < 26; j++)         if (hv[j]) {           add_edge(i + 1, n + 2 + j, hv[j], i);           hv[j] = 0;         }     }     mcmf();     if (Sl == flw)       printf( %d n , cst);     else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1000000000000000;   bool sortCct(pair<long long, long long> a, pair<long long, long long> b) {     return a.first > b.first;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, i, t, g, c = 0;     cin >> n;     vector<long long> ct(n);     vector<pair<long long, long long> > ctt(n);     map<long long, long long> fr;     for (i = 0; i < n; i++) cin >> ct[i];     for (i = 0; i < n; i++) {       cin >> t;       ctt[i] = pair<long long, long long>(t, ct[i]);     }     sort(ctt.begin(), ctt.end(), sortCct);     fr[INF] = 1;     for (i = 0; i < n; i++) {       pair<long long, long long> k = ctt[i];       auto it = fr.lower_bound(k.second);       g = max(k.second, it->second);       c += (g - k.second) * k.first;       if (g == it->second and g == it->first)         fr.erase(it);       else if (g == it->second)         it->second++;       else if (g == it->first) {         fr[it->first - 1] = it->second;         fr.erase(it);       } else {         fr[g - 1] = it->second;         it->second = g + 1;       }     }     cout << c <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     char ch[105][105], ss[105][105];     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> ch[i];     }     for (int i = 0; i < n; i++) {       string s = ch[i], gu;       if (i % 2 == 0) {         for (int j = 0; j < m; j++) {           if (j % 2 == 0 && ch[i][j] !=  - ) {             gu +=  B ;           } else if (ch[i][j] !=  - ) {             gu +=  W ;           } else {             gu +=  - ;           }         }       } else {         for (int j = 0; j < m; j++) {           if (j % 2 == 0 && ch[i][j] !=  - ) {             gu +=  W ;           } else if (ch[i][j] !=  - ) {             gu +=  B ;           } else {             gu +=  - ;           }         }       }       cout << gu <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e9 + 7, N1 = 1e7 + 5, N2 = 1e6 + 3, N3 = 1e5 + 3;   long long binpow(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a;       a = a * a;       b >>= 1;     }     return res;   }   void solve() {     long long x, y;     cin >> x >> y;     if (y < x * 2)       cout <<  YES ;     else       cout <<  NO ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t1 = 1;     cin >> t1;     while (t1--) {       solve();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1 << 12 | 5, Q = 1 << 16 | 5;   int n, q, B, a[N], p[N], cnt, id[Q];   vector<pair<int, int>> opt;   struct node {     int n;     vector<int> pos;     vector<vector<int>> id;     node(int _n = 0) {       n = _n;       pos.resize(n);       id.resize(n);       for (auto &v : id) {         v.resize(n);       }     }     inline int get(int l, int r) {       l = lower_bound(pos.begin(), pos.end(), l) - pos.begin();       r = upper_bound(pos.begin(), pos.end(), r) - pos.begin() - 1;       return l <= r ? id[l][r] : 0;     }   } sqr[N];   inline int merge(int x, int y) {     int res;     if (x && y) {       opt.push_back({x, y});       res = ++cnt;     } else {       res = x | y;     }     return res;   }   node solve(int l, int r, int s) {     if (l == r) {       node res(1);       res.pos = {p[s + l]};       res.id = {{p[s + l]}};       return res;     }     int mid = l + r >> 1;     node x = solve(l, mid, s);     node y = solve(mid + 1, r, s);     node z(x.n + y.n);     merge(x.pos.begin(), x.pos.end(), y.pos.begin(), y.pos.end(), z.pos.begin());     for (int i = 0; i < z.n; ++i) {       for (int j = i; j < z.n; ++j) {         int l = z.pos[i], r = z.pos[j];         z.id[i][j] = merge(x.get(l, r), y.get(l, r));       }     }     return z;   }   int main() {     scanf( %d%d , &n, &q);     B = sqrt(q);     cnt = n;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       p[a[i]] = i;     }     for (int i = 1, j = 1; i <= n; i += B, ++j) {       sqr[j] = solve(0, min(i + B - 1, n) - i, i);     }     for (int t = 1; t <= q; ++t) {       int l, r;       scanf( %d%d , &l, &r);       for (int i = 1, j = 1; i <= n; i += B, ++j) {         id[t] = merge(id[t], sqr[j].get(l, r));       }     }     printf( %d n , cnt);     for (auto x : opt) {       printf( %d %d n , x.first, x.second);     }     for (int t = 1; t <= q; ++t) {       printf( %d%c , id[t],    n [t == q]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, o = 0, e = 0;     cin >> n;     vector<long long> a(n);     for (long long i = 0; i < n; ++i) {       cin >> a[i];     }     for (long long i = 0; i < n; ++i) {       if (a[i] % 2 != i % 2) {         if (a[i] % 2 == 0)           e++;         else           o++;       }     }     if (o == e) {       cout << o <<   n ;     } else {       cout << -1 <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1 << 18;   bool a[N];   vector<int> res;   int x, n;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> x;     res.push_back(0);     a[0] = true;     for (int i = 1; i <= int((1 << n) - 1); i++) {       if (a[i ^ x]) continue;       res.push_back(i);       a[i] = true;     }     cout << res.size() - 1 <<   n ;     for (int i = 1; i <= int(res.size() - 1); i++) {       int t = res[i] ^ res[i - 1];       cout << t <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> adj[100005];   long long sn[100005], an[100005], level[100005];   long long got = 1;   void dfs(long long u, long long par, long long carry) {     if (sn[u] != -1 && sn[u] < carry) got = 0;     level[u] = level[par] + 1;     if (sn[u] != -1) {       an[u] = sn[u] - carry;       carry = sn[u];     } else       an[u] = 0;     for (auto it : adj[u]) {       if (it != par) dfs(it, u, carry);     }   }   void dfs2(long long u, long long par, long long carry) {     if (level[u] & 1) {       if (u != 1) {         an[u] = sn[u] - carry;         carry = sn[u];       }     } else {       long long mn = 1e15 + 7;       for (auto it : adj[u])         if (it != par) mn = min(mn, sn[it]);       if (mn != 1e15 + 7) {         an[u] = mn - carry;         carry = mn;       } else         an[u] = 0;     }     for (auto it : adj[u])       if (it != par) dfs2(it, u, carry);   }   int main() {     long long i, j, k;     long long n, m;     cin >> n;     for (i = 2; i <= n; i++) {       cin >> m;       adj[m].push_back(i);       adj[i].push_back(m);     }     for (i = 1; i <= n; i++) cin >> sn[i];     dfs(1, 0, sn[1]);     if (!got) {       cout << -1 << endl;       return 0;     }     dfs2(1, 0, sn[1]);     an[1] = sn[1];     long long ans = 0;     for (i = 1; i <= n; i++) ans += an[i];     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class Graph {     vector<int>* adjList;     vector<bool> init;     vector<bool> goal;     bool* visited;     int n;     vector<int> operate;       public:     Graph(int n) {       adjList = new vector<int>[n];       visited = new bool[n]();       this->n = n;     }     void initialise(bool value) { init.push_back(value); }     void goals(bool value) { goal.push_back(value); }     void edge(int u, int v) {       adjList[u].push_back(v);       adjList[v].push_back(u);     }     void print() {       for (int j = 0; j < operate.size(); ++j) {         cout << operate[j] << endl;       }     }     int achieveGoal(int root, int op1, int op2) {       int total = 0;       visited[root] = true;       int operations = op1;       if (operations & 1 == 1) {         init[root] = !init[root];       }       if (init[root] != goal[root]) {         init[root] = !init[root];         ++operations;         total += 1;         operate.push_back(root + 1);       }       for (int i = 0; i < adjList[root].size(); ++i) {         if (!visited[adjList[root][i]])           total += achieveGoal(adjList[root][i], op2, operations);       }       return total;     }   };   int main() {     int n, u, v;     cin >> n;     Graph g(n);     for (int i = 1; i < n; ++i) {       cin >> u >> v;       g.edge(u - 1, v - 1);     }     for (int i = 0; i < n; ++i) {       cin >> u;       g.initialise(u);     }     for (int i = 0; i < n; ++i) {       cin >> v;       g.goals(v);     }     cout << g.achieveGoal(0, 0, 0) << endl;     g.print();   }
#include <bits/stdc++.h>   using namespace std;   int countdigits(int n) {     int i, b = 0;     while (n) {       b++;       n = n / 10;     }     return b;   }   int main() {     int t, i, n, x, cnt = 0;     cin >> t;     for (i = 0; i < t; i++) {       cin >> n;       cnt = countdigits(n);       n = n % 10;       if (cnt == 1) {         x = (n - 1) * 10 + 1;       }       if (cnt == 2) {         x = (n - 1) * 10 + 3;       }       if (cnt == 3) {         x = (n - 1) * 10 + 6;       }       if (cnt == 4) {         x = (n - 1) * 10 + 10;       }       cout << x << endl;       x = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a, b;   int used[100005], d[100005];   vector<int> g[100005];   void bfs(int node) {     memset(used, 0, sizeof(used));     memset(d, 0, sizeof(d));     queue<int> q;     q.push(node);     used[node] = 1;     while (!q.empty()) {       int cur = q.front();       q.pop();       for (int i = 0; i < g[cur].size(); i++) {         int to = g[cur][i];         if (!used[to]) {           q.push(to);           d[to] = d[cur] + 1;           used[to] = 1;         }       }     }   }   int main() {     scanf( %d , &n);     scanf( %d , &m);     while (m--) {       scanf( %d , &a);       scanf( %d , &b);       g[a].push_back(b);       g[b].push_back(a);     }     bfs(1);     int start = 1, dis = 0;     for (int i = 2; i <= n; i++) {       if (dis < d[i]) {         dis = d[i];         start = i;       }     }     bfs(start);     int ans = 0;     for (int i = 1; i <= n; i++) {       ans = max(ans, d[i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct targ {     long long x, r;     int id, s;   } tar[10004];   bool _x(targ a, targ b) { return a.x < b.x; }   bool _id(targ a, targ b) { return a.id < b.id; }   int fd(int l, int r, long long x) {     if (l == r) return l;     int m = l + r >> 1;     if (tar[m].x < x)       return fd(m + 1, r, x);     else       return fd(l, m, x);   }   int cnt = 0;   void sl(int now, int p, long long x, long long y) {     if ((x - tar[p].x) * (x - tar[p].x) + y * y <= tar[p].r * tar[p].r)       tar[p].s = now, cnt++;   }   int main() {     int n, m;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld%lld , &tar[i].x, &tar[i].r);       tar[i].id = i;       tar[i].s = -1;     }     sort(tar + 1, tar + n + 1, _x);     scanf( %d , &m);     long long x, y;     for (int i = 1; i <= m; i++) {       scanf( %lld%lld , &x, &y);       int p = fd(1, n, x);       if (tar[p].s == -1) sl(i, p, x, y);       if (p - 1 && tar[p - 1].s == -1) sl(i, p - 1, x, y);     }     sort(tar + 1, tar + n + 1, _id);     cout << cnt << endl;     for (int i = 1; i <= n; i++) {       printf( %d%c , tar[i].s,    n [i == n]);     }   }
#include <bits/stdc++.h>   using namespace std;   long long f[2][1000005];   long long h[1000005];   int n;   int main() {     scanf( %d , &n);     for (int i = (0); i < (n); i++) scanf( %lld , h + i);     long long res = 0;     for (int i = (1); i < (n + 1); i++) {       long long mx = h[i - 1] - 1;       f[1][i] = h[i - 1] - 1;       if (i != 1) {         if (h[i - 1] >= h[i - 2]) {           long long mn = h[i - 1] - h[i - 2] + 1;           f[1][i] += (mx - mn + 1) * f[0][i - 1];         } else {           long long mn = 1;           f[1][i] += (mx - mn + 1) * f[0][i - 1];         }       }       f[1][i] %= 1000000007ll;       res += f[1][i];       if (i != n) {         long long mn = h[i - 1] >= h[i] ? h[i - 1] - h[i] + 1 : 1;         f[0][i] += mx - mn + 1;         if (i != 1) {           if (h[i - 1] >= h[i - 2]) {             long long MN = max(mn, h[i - 1] - h[i - 2] + 1);             f[0][i] += (mx - MN + 1) * f[0][i - 1];           } else {             f[0][i] += (mx - mn + 1) * f[0][i - 1];           }         }       }       f[0][i] %= 1000000007ll;     }     printf( %lld n , res % 1000000007ll);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, mod = 998244353;   int add(int a, int b) {     a += b;     if (a >= mod) {       a -= mod;     }     return a;   }   int sub(int a, int b) {     a -= b;     if (a < 0) {       a += mod;     }     return a;   }   int mul(long long a, int b) { return (a * b) % mod; }   int pwr(int x, int e) {     int res = 1;     while (e) {       if (e & 1) {         res = mul(res, x);       }       x = mul(x, x);       e /= 2;     }     return res;   }   struct tournament {     vector<int> p;     int h = 0, i;   };   vector<tournament> get_pairs(int a, int l, int r);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int k, a, h;     cin >> k >> a >> h;     vector<tournament> v1, v2;     v1 = get_pairs(a, 1, (1 << (k - 1)));     v2 = get_pairs(a, (1 << (k - 1)) + 1, (1 << k));     for (int tc = 0; tc < 2; ++tc) {       int sz = v1.size();       map<int, int> mp;       for (int i = 0; i < sz; ++i) {         mp[sub(h, add(v1[i].h, mul(v1[i].i, a)))] = i;       }       for (int i = 0; i < sz; ++i) {         int val = add(v2[i].h, mul(v2[i].i, mul(a, a)));         if (mp.find(val) != mp.end()) {           int ti = mp[val], tj = i;           int winner = v1[ti].i;           int second = v2[tj].i;           if (tc == 1) {             swap(ti, tj);           }           vector<int> ans = v1[ti].p;           for (auto& pos : v2[tj].p) {             ans.push_back(pos);           }           ans[winner - 1] = 1;           ans[second - 1] = 2;           for (auto& pos : ans) {             cout << pos <<    ;           }           cout <<   n ;           return 0;         }       }       swap(v1, v2);     }     cout << -1 <<   n ;   }   vector<tournament> get_pairs(int a, int l, int r) {     int n = (r - l + 1), tot = (1 << (n - 1));     vector<int> ids(n);     vector<tournament> ans;     iota(ids.begin(), ids.end(), l);     for (int ch = 0; ch < tot; ++ch) {       int mask = ch;       tournament t;       t.p.resize(n, 0);       queue<int> q;       for (int i = 0; i < n; ++i) {         q.push(i);       }       int cur_rank = n + 1, rank_cnt = n / 2;       while (q.size() > 1) {         int p1 = q.front();         q.pop();         int p2 = q.front();         q.pop();         if (mask & 1) {           t.p[p2] = cur_rank;           t.h = add(t.h, mul(ids[p2], pwr(a, cur_rank)));           q.push(p1);         } else {           t.p[p1] = cur_rank;           t.h = add(t.h, mul(ids[p1], pwr(a, cur_rank)));           q.push(p2);         }         mask /= 2;         --rank_cnt;         if (rank_cnt == 0) {           cur_rank = ((cur_rank - 1) / 2) + 1;           rank_cnt = (cur_rank - 1) / 2;         }       }       t.i = ids[q.front()];       ans.push_back(t);     }     return ans;   }
#include <bits/stdc++.h>   using namespace std;   const int sz = 1e5 + 10, mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, i, j;     long long k, cost = 0;     string s;     cin >> n >> k >> s;     int last[n + 1][26];     long long dp[n][n + 1], f[n + 1];     memset(last, -1, sizeof(last));     memset(dp, 0, sizeof(dp));     memset(f, 0, sizeof(f));     for (i = 0; i <= n; i++) {       for (j = 0; j < i; j++) {         last[i][s[j] -  a ] = j;       }     }     dp[0][1] = 1;     for (i = 1; i < n; i++) {       for (int len = 1; len <= n; len++) {         if (i + 1 < len) break;         if (len == 1) {           dp[i][len] = 1;           continue;         }         dp[i][len] = 0;         for (j = 0; j < 26; j++) {           int x = last[i][j];           if (x != -1) {             dp[i][len] += dp[x][len - 1];           }         }       }     }     f[0] = 1;     for (i = 0; i < 26; i++) {       if (last[n][i] != -1) {         for (int len = 1; len <= n; len++) {           f[len] += dp[last[n][i]][len];         }       }     }     bool foo = false;     for (int len = n; len >= 0; len--) {       if (k - f[len] <= 0) {         cost += 1LL * k * (n - len);         foo = true;         break;       } else {         cost += 1LL * f[len] * (n - len);         k -= f[len];       }     }     if (foo)       cout << cost <<   n ;     else       cout <<  -1 n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, d, m, A[101];     while (cin >> n >> d) {       int sum = 0;       for (int i = 0; i < n; i++) {         cin >> A[i];       }       cin >> m;       sort(A, A + n);       if (m > n) {         for (int i = 0; i < n; i++) {           sum += A[i];         }         sum -= ((m - n) * d);       } else {         for (int i = 0; i < m; i++) {           sum += A[i];         }       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int res[100000];     memset(res, -1, sizeof(res));     cin >> n;     vector<pair<pair<long long, long long>, int> > v;     for (int(i) = 0; (i) < (n); (i)++) {       long long x, r;       cin >> x >> r;       v.push_back(pair<pair<long long, long long>, int>(           pair<long long, long long>(x, r), i));     }     sort(v.begin(), v.end());     int m;     cin >> m;     int ret = 0;     for (int(i) = 0; (i) < (m); (i)++) {       long long x, y;       cin >> x >> y;       int l = 0, r = n - 1;       while (l <= r) {         int mid = (l + r) / 2;         if (x < v[mid].first.first - v[mid].first.second) {           r = mid - 1;           continue;         }         if (x > v[mid].first.first + v[mid].first.second) {           l = mid + 1;           continue;         }         if ((x - v[mid].first.first) * (x - v[mid].first.first) + y * y <=             v[mid].first.second * v[mid].first.second) {           if (res[v[mid].second] == -1) {             ret++;             res[v[mid].second] = i + 1;           }         }         if (mid > 0) {           if ((x - v[mid - 1].first.first) * (x - v[mid - 1].first.first) +                   y * y <=               v[mid - 1].first.second * v[mid - 1].first.second) {             if (res[v[mid - 1].second] == -1) {               ret++;               res[v[mid - 1].second] = i + 1;             }           }         }         if (mid < n - 1) {           if ((x - v[mid + 1].first.first) * (x - v[mid + 1].first.first) +                   y * y <=               v[mid + 1].first.second * v[mid + 1].first.second) {             if (res[v[mid + 1].second] == -1) {               ret++;               res[v[mid + 1].second] = i + 1;             }           }         }         break;       }     }     cout << ret << endl;     for (int(i) = 0; (i) < (n); (i)++) {       cout << res[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.141592653589793238463;   int x[1009], y[1009], t[1009];   double p[1009];   double dp[1009][1009];   int n;   double sol(int i, int prev) {     if (i == n) return 0;     if (dp[i][prev] == dp[i][prev]) return dp[i][prev];     bool can = true;     if (prev == n)       can = true;     else {       int dt = t[i] - t[prev];       int dx = abs(x[i] - x[prev]);       int dy = abs(y[i] - y[prev]);       can = (dt >= hypot(dx, dy));     }     if (!can) return dp[i][prev] = sol(i + 1, prev);     return dp[i][prev] = max(sol(i + 1, prev), p[i] + sol(i + 1, i));   }   struct target {     int x, y, t;     double p;     bool operator<(const target &other) const { return t < other.t; }   };   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     cin >> n;     vector<target> v;     for (int i = 0; i < (n); i++) {       int x, y, t;       cin >> x >> y >> t;       double p;       cin >> p;       v.push_back({x, y, t, p});     }     sort(v.begin(), v.end());     for (int i = 0; i < (n); i++)       x[i] = v[i].x, y[i] = v[i].y, t[i] = v[i].t, p[i] = v[i].p;     memset((dp), (-1), sizeof(dp));     printf( %.10f n , sol(0, n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 100005;   int cnt[MAX_N];   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int n;     cin >> n;     vector<int> vec(n);     for (int i = 0; i < (int)(n); ++i) {       cin >> vec[i];     }     int m1 = -1, m2 = -2;     int id1 = -1, id2 = -1;     for (int i = 0; i < (int)(n); ++i) {       if (vec[i] > m1) {         cnt[i] -= 1;         m2 = m1, id2 = id1;         m1 = vec[i], id1 = i;       } else if (vec[i] > m2) {         cnt[id1] += 1;         m2 = vec[i], id2 = i;       }     }     vector<pair<int, int> > res;     for (int i = 0; i < (int)(n); ++i) {       res.push_back(pair<int, int>(cnt[i], -vec[i]));     }     sort((res).begin(), (res).end(), greater<pair<int, int> >());     cout << -res[0].second <<   n ;     return 0;   }