malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = -1;     for (; isdigit(ch); ch = getchar()) x = x * 10 + ch -  0 ;     return x * f;   }   const int N = 500005, INF = 1e9;   const double DINF = 1e18;   struct Edge {     int fr, to, nxt, cap;     double cost;   } e[N << 1];   int head[N], pre[N], q[N], En = 1, S, T, n;   double dis[N];   bool vis[N];   inline void add_edge(int u, int v, int f, double w) {     ++En;     e[En].fr = u, e[En].to = v, e[En].nxt = head[u], e[En].cap = f,     e[En].cost = w;     head[u] = En;     ++En;     e[En].fr = v, e[En].to = u, e[En].nxt = head[v], e[En].cap = 0,     e[En].cost = -w;     head[v] = En;   }   bool spfa() {     for (int i = 0; i <= T; ++i) dis[i] = DINF, vis[i] = false, pre[i] = 0;     int L = 1, R = 0;     dis[S] = 0, q[++R] = S, vis[S] = true, pre[S] = 0;     while (L <= R) {       int u = q[L++];       vis[u] = false;       for (int i = head[u]; i; i = e[i].nxt) {         int v = e[i].to;         if (dis[v] > dis[u] + e[i].cost && e[i].cap > 0) {           dis[v] = dis[u] + e[i].cost;           pre[v] = i;           if (!vis[v]) q[++R] = v;         }       }     }     return dis[T] != DINF;   }   void mcf() {     int Flow = 0;     double Cost = 0;     while (spfa()) {       int now = INF;       for (int i = T; i != S; i = e[pre[i]].fr) now = min(now, e[pre[i]].cap);       for (int i = T; i != S; i = e[pre[i]].fr)         e[pre[i]].cap -= now, e[pre[i] ^ 1].cap += now;       Flow += now;       Cost += 1.0 * now * dis[T];     }     if (Flow >= n - 1)       printf( %.10lf , Cost);     else       puts( -1 );   }   struct Node {     int x, y;   } A[N];   int sqr(int x) { return x * x; }   double dist(const Node &A, const Node &B) {     return sqrt(1.0 * (sqr(A.x - B.x) + sqr(A.y - B.y)));   }   int main() {     n = read();     for (int i = 1; i <= n; ++i) A[i].x = read(), A[i].y = read();     S = 0, T = n + n + 1;     for (int i = 1; i <= n; ++i) add_edge(S, i, 2, 0), add_edge(i + n, T, 1, 0);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         if (A[j].y > A[i].y) add_edge(j, i + n, 1, dist(A[i], A[j]));     mcf();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char s1[51], s2[51], op[50][5];   int memo1[50][50][26], memo2[50][50][26], memo3[50][50];   int check1(int l, int r, char c) {     if (l == r) return s1[l] == c;     int &ret = memo1[l][r][c -  a ];     if (ret == -1) {       ret = 0;       for (int i = l; i < r; ++i)         for (int j = 0; j < n; ++j)           if (op[j][0] == c && check1(l, i, op[j][3]) &&               check1(i + 1, r, op[j][4]))             ret = 1;     }     return ret;   }   int check2(int l, int r, char c) {     if (l == r) return s2[l] == c;     int &ret = memo2[l][r][c -  a ];     if (ret == -1) {       ret = 0;       for (int i = l; i < r; ++i)         for (int j = 0; j < n; ++j)           if (op[j][0] == c && check2(l, i, op[j][3]) &&               check2(i + 1, r, op[j][4]))             ret = 1;     }     return ret;   }   int solve(int pos1, int pos2) {     if (pos1 == -1 && pos2 == -1) return 0;     if (pos1 == -1 || pos2 == -1) return 51;     int &ret = memo3[pos1][pos2];     if (ret == -1) {       ret = 51;       for (int i = 0; i <= pos1; ++i)         for (int j = 0; j <= pos2; ++j)           for (char c =  a ; c <=  z ; ++c)             if (check1(i, pos1, c) && check2(j, pos2, c))               ret = min(ret, 1 + solve(i - 1, j - 1));     }     return ret;   }   int main() {     scanf( %s %s , s1, s2);     int L1 = strlen(s1), L2 = strlen(s2);     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %s , op[i]);     memset(memo1, -1, sizeof memo1);     memset(memo2, -1, sizeof memo2);     memset(memo3, -1, sizeof memo3);     int ans = solve(L1 - 1, L2 - 1);     printf( %d n , ans == 51 ? -1 : ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long is_query = -(1LL << 62);   struct Line {     long long m, b;     mutable function<const Line*()> succ;     bool operator<(const Line& rhs) const {       if (rhs.b != is_query) return m < rhs.m;       const Line* s = succ();       if (!s) return 0;       long long x = rhs.m;       return b - s->b < (s->m - m) * x;     }   };   struct HullDynamic : public multiset<Line> {     bool bad(iterator y) {       auto z = next(y);       if (y == begin()) {         if (z == end()) return 0;         return y->m == z->m && y->b <= z->b;       }       auto x = prev(y);       if (z == end()) return y->m == x->m && y->b <= x->b;       return (x->b - y->b) * (z->m - y->m) >= (y->b - z->b) * (y->m - x->m);     }     void insert_line(long long m, long long b) {       auto y = insert({m, b});       y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };       if (bad(y)) {         erase(y);         return;       }       while (next(y) != end() && bad(next(y))) erase(next(y));       while (y != begin() && bad(prev(y))) erase(prev(y));     }     long long eval(long long x) {       auto l = *lower_bound((Line){x, is_query});       return l.m * x + l.b;     }   } convex;   const int N = 2e5 + 5;   long long dp[N], arr[N];   int n;   int main() {     long long sum = 0, ans;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld , &arr[i]);       dp[i] = dp[i - 1] + arr[i];       sum += arr[i] * i;     }     ans = sum;     convex.insert_line(n, -dp[n]);     for (int i = n - 1; i >= 1; i--) {       long long best = 0;       long long e = dp[i] - i * arr[i] + sum;       ans = max(ans, convex.eval(arr[i]) + e);       convex.insert_line(i, -dp[i]);     }     convex.clear();     convex.insert_line(1, 0);     for (int i = 2; i <= n; i++) {       long long e = sum + dp[i - 1] - i * arr[i];       ans = max(ans, convex.eval(arr[i]) + e);       convex.insert_line(i, -dp[i - 1]);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct mat {     double a[3][3];     mat() {       for (int i = (int)(0); i <= (int)(2); ++i)         for (int j = (int)(0); j <= (int)(2); ++j) a[i][j] = 0;     }     mat operator*(const mat &b) const {       mat c;       for (int i = (int)(0); i <= (int)(2); ++i)         for (int j = (int)(0); j <= (int)(2); ++j)           for (int k = (int)(0); k <= (int)(2); ++k)             c.a[i][j] += a[i][k] * b.a[k][j];       return c;     }   };   struct node {     int id;     long long las;     mat pre;   };   vector<node> S;   mat bas[100005], f[40], org;   pair<double, double> p[100005];   int n;   long long m;   double b;   int main() {     scanf( %d%lld , &n, &m);     for (int i = (int)(1); i <= (int)(n); ++i) {       double x, y, v;       scanf( %lf%lf%lf , &x, &y, &v);       b = max(b, y * v);       p[i] = pair<double, double>(x * v, v);     }     sort(p + 1, p + n + 1, greater<pair<double, double> >());     org.a[2][0] = 1;     for (int i = (int)(1); i <= (int)(n); ++i) {       bas[i].a[1][1] = 1;       bas[i].a[2][2] = 1;       bas[i].a[0][0] = 1 - p[i].second;       bas[i].a[0][1] = p[i].second;       bas[i].a[0][2] = p[i].first;       bas[i].a[1][2] = b;     }     S.push_back((node){1, m, org});     for (int i = (int)(2); i <= (int)(n); ++i) {       for (;;)         if ((bas[i] * S.back().pre).a[0][0] >             (bas[S.back().id] * S.back().pre).a[0][0])           S.pop_back();         else           break;       if (!S.back().las) continue;       node tmp = S.back();       f[0] = bas[tmp.id];       for (int j = (int)(1); j <= (int)(35); ++j) f[j] = f[j - 1] * f[j - 1];       for (int j = (int)(35); j >= (int)(0); --j)         if (tmp.las - (1ll << j) >= 1)           if ((bas[i] * f[j] * tmp.pre).a[0][0] <=               (bas[tmp.id] * f[j] * tmp.pre).a[0][0]) {             tmp.pre = f[j] * tmp.pre;             tmp.las -= (1ll << j);           }       tmp.pre = f[0] * tmp.pre;       --tmp.las;       if (tmp.las) tmp.id = i;       S.push_back(tmp);     }     int id = S.back().id;     long long las = S.back().las;     mat ans = S.back().pre, x = bas[id];     for (; las; las /= 2, x = x * x)       if (las & 1) ans = x * ans;     printf( %.15lf n , ans.a[0][0]);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 110, MOD = 1e9 + 7;   long long dp[MAXN][2];   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(nullptr);     cout.tie(nullptr);     int n, k, d;     cin >> n >> k >> d;     dp[0][0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= min(k, i); j++) {         if (j >= d) {           dp[i][1] += (dp[i - j][0] + dp[i - j][1]);           dp[i][1] %= MOD;         } else {           dp[i][0] += dp[i - j][0];           dp[i][1] += dp[i - j][1];           dp[i][1] %= MOD;           dp[i][0] %= MOD;         }       }     }     cout << dp[n][1] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long me[10000][1001];   long long n, m;   long long d[10000];   long long g, r;   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (long long i = 0; i < m; i++) cin >> d[i];     sort(d, d + m);     cin >> g >> r;     queue<pair<long long, long long> > mq[2];     mq[1].push(pair<long long, long long>(0, g));     me[0][g] = 1;     int ini = 1;     while (!mq[0].empty() || !mq[1].empty()) {       while (!mq[ini % 2].empty()) {         pair<long long, long long> t = mq[ini % 2].front();         mq[ini % 2].pop();         long long i = t.first;         long long j = t.second;         long long np = me[i][j];         if (np == ini) {           if (j == 0) np++, j = g;           if (i && d[i] - d[i - 1] <= j &&               (me[i - 1][j - (d[i] - d[i - 1])] == 0 ||                me[i - 1][j - (d[i] - d[i - 1])] > np)) {             me[i - 1][j - (d[i] - d[i - 1])] = np;             mq[np % 2].push(                 pair<long long, long long>(i - 1, j - (d[i] - d[i - 1])));           }           if (i < m - 1 && d[i + 1] - d[i] <= j &&               (me[i + 1][j - (d[i + 1] - d[i])] == 0 ||                me[i + 1][j - (d[i + 1] - d[i])] > np)) {             me[i + 1][j - (d[i + 1] - d[i])] = np;             mq[np % 2].push(                 pair<long long, long long>(i + 1, j - (d[i + 1] - d[i])));           }         }       }       ini++;     }     long long res = -1;     for (int i = 0; i <= g; i++) {       if (me[m - 1][i]) {         long long can = (me[m - 1][i] - 1) * (g + r) + g - i;         if (res == -1 || can < res) res = can;       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 1;   int accept() {     int b[N] = {0};     int d[N] = {0};     int n;     cin >> n;     int mx, check;     for (int i = 0; i < n; i++) cin >> b[i];     sort(b, b + n);     for (int i = 1; i < n; i++) {       if (b[i] == b[i - 1]) {         cout <<  YES               <<   n ;         return 0;       }     }     cout <<  NO           <<   n ;     return 0;   }   int main() {     int t = 1;     cin >> t;     while (t--) {       accept();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 100010;   int arr[mx];   int main() {     string x;     int n, c = -1, temp = 0;     queue<int> stek;     map<int, int> visit;     cin >> n >> x;     for (int i = 0; i < n - 1; i++) {       if ((x[i] ==  o  and x[i + 1] ==  g ) ||           (x[i] ==  g  and x[i + 1] ==  o )) {         temp++;         if (c == -1 and x[i] ==  g ) {           temp = 0;           continue;         }         if (c == -1) c = i;       } else if (c != -1) {         if (x[i] ==  g  and temp == 1) {           temp = 0;           c = -1;           continue;         } else if (x[i] ==  g  and temp > 1) {           temp--;         }         stek.push(c);         visit[c] = temp;         temp = 0;         c = -1;       }     }     if (c != -1) {       if (x[n - 1] ==  g  and temp == 1) {       } else {         if (x[n - 1] ==  g  and temp > 1) {           temp--;         }         stek.push(c);         visit[c] = temp;         temp = 0;         c = -1;       }     }     for (int i = 0; i < n; i++) {       if (stek.front() == i) {         printf( *** );         i += visit[stek.front()];         stek.pop();       } else {         printf( %c , x[i]);       }     }     printf(  n );   }
#include <bits/stdc++.h>   const long long mod = 1e9 + 7;   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long n, m;   vector<long long> a, b, v, pat;   long long cal() {     v.clear();     for (long long i = 1; i < m; i++) v.push_back(a[i]);     v.push_back(1e18);     for (long long j = 1; j < n; j++) v.push_back(b[j]);     long long sz = v.size();     long long ans = 0;     pat.clear();     pat.resize(sz, 0);     for (long long i = 1; i < sz; i++) {       long long j = pat[i - 1];       while (j > 0 && v[j] != v[i]) j = pat[j - 1];       if (v[j] == v[i]) j++;       pat[i] = j;       if (j == m - 1) ans++;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     long long pre, cur;     b.clear();     b.resize(n);     for (long long i = 0; i < n; i++) {       cin >> b[i];       cur = b[i];       if (i) b[i] -= pre;       pre = cur;     }     a.clear();     a.resize(m);     for (long long i = 0; i < m; i++) {       cin >> a[i];       cur = a[i];       if (i) a[i] -= pre;       pre = cur;     }     if (m == 1) {       cout << n <<   n ;       return 0;     }     cout << cal() <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int num, skill;     cin >> num >> skill;     int A[num];     for (int i = 0; i < num; i++) cin >> A[i];     int k = 0;     while (A[k] <= skill && k < num) k++;     int soluve;     soluve = k;     int stay;     if (k == num) {       cout << num << endl;       return 0;     } else {       int z = num - 1;       while (A[z] <= skill && z >= 1) z--;       stay = num - z - 1;       soluve += stay;     }     cout << soluve << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize( inline )   int rd() {     register int k = 0;     char c = getchar();     while (c >  9  || c <  0 ) c = getchar();     while (c >=  0  && c <=  9 ) k = k * 10 + c - 48, c = getchar();     return k;   }   const int N = 100001;   struct Q {     int o, t, l, r;   } q[N];   struct C {     int x, v;   } c[N];   int n, m, p, l = 1, r, qn, cn, a[N], bl[N], ans[N], T, b[N << 1], B, v[N << 1],                sv[N], s;   bool cmp(register const Q& x, register const Q& y) {     return bl[x.l] != bl[y.l] ? x.l < y.l                               : (bl[x.r] == bl[y.r] ? x.t < y.t : x.r < y.r);   }   void Ins(register int p) { --sv[v[p]], ++sv[++v[p]]; }   void Del(register int p) { --sv[v[p]], ++sv[--v[p]]; }   void Set(register int t, register int i) {     if (q[i].l <= c[t].x && c[t].x <= q[i].r) Del(a[c[t].x]), Ins(c[t].v);     std::swap(a[c[t].x], c[t].v);   }   int main() {     B = n = rd(), m = rd(), p = pow(n, 0.66);     for (register int i = 1; i <= n; ++i) b[i] = a[i] = rd(), bl[i] = i / p;     for (register int i = 1; i <= m; ++i) {       if (rd() == 1)         ++qn, q[qn] = {qn, cn, rd(), rd()};       else         c[++cn] = {rd(), b[++B] = rd()};     }     std::sort(b + 1, b + B + 1), B = std::unique(b + 1, b + B + 1) - b - 1,                                  std::sort(q + 1, q + qn + 1, cmp);     for (register int i = 1; i <= n; ++i)       a[i] = std::lower_bound(b + 1, b + B + 1, a[i]) - b;     for (register int i = 1; i <= cn; ++i)       c[i].v = std::lower_bound(b + 1, b + B + 1, c[i].v) - b;     for (register int i = 1; i <= qn; ++i) {       while (l > q[i].l) Ins(a[--l]);       while (r < q[i].r) Ins(a[++r]);       while (l < q[i].l) Del(a[l++]);       while (r > q[i].r) Del(a[r--]);       while (T < q[i].t) Set(++T, i);       while (T > q[i].t) Set(T--, i);       for (s = 1; sv[s] > 0; ++s)         ;       ans[q[i].o] = s;     }     for (register int i = 1; i <= qn; ++i) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma optimize( -Ofast )   const int mod = 998244353;   struct num {     int x;     num(int x_ = 0) { x = x_; }   } G, _1[2222222], X[2222222], rot[2222222], inv[2222222];   inline bool operator<(const num x, const num y) { return x.x > y.x; }   inline num operator+(const num x, const num y) {     int z = x.x + y.x;     return z < mod ? num(z) : num(z - mod);   }   inline num operator-(const num x, const num y) {     int z = x.x - y.x;     return z >= 0 ? num(z) : num(z + mod);   }   inline num operator*(const num x, const num y) {     return num((long long)x.x * y.x % mod);   }   inline num operator*(const int x, const num y) {     return num((long long)x * y.x % mod);   }   inline num operator^(num x, int y) {     num z = num(1);     while (y) {       if (y & 1) {         z = z * x;       }       x = x * x;       y >>= 1;     }     return z;   }   void _(int n) {     inv[1] = num(1);     for (int i = 2; i <= n; i++) {       inv[i] = (mod - mod / i) * inv[mod % i];     }     for (int i = 2; i <= n; i <<= 1) {       rot[i] = G ^ ((mod - 1) / i);     }   }   void rader(num x[], int n) {     int i, j = 0, k;     for (register int i = 0; i != n; i++) {       if (i > j) {         swap(x[i], x[j]);       }       k = n >> 1;       while ((j ^= k) < k) {         k >>= 1;       }     }   }   void NTT(num x[], int n, int o) {     int k;     num r, u, v, w;     rader(x, n);     for (int l = 2; l <= n; l <<= 1) {       k = l >> 1;       r = rot[l];       for (int i = 0; i < n; i += l) {         w = num(1);         for (register int j = i; j < i + k; j++) {           u = x[j];           v = x[j + k] * w;           x[j] = u + v;           x[j + k] = u - v;           w = w * r;         }       }     }     if (o == -1) {       for (register int i = 0; i < n; i++) {         x[i] = x[i] * inv[n];       }       for (register int i = 1; i < (n >> 1); i++) {         swap(x[i], x[n - i]);       }     }   }   int main() {     int n, k, z[11], oo[11] = {0};     G = num(3);     scanf( %d%d , &n, &k);     n /= 2;     for (int i = 1; i <= k; i++) {       scanf( %d , &z[i]);       oo[z[i]] = 1;     }     for (int i = 0; i <= 9; i++) {       if (oo[i]) {         _1[i] = num(1);       }     }     int xxx = n;     n *= 10;     int S = 1;     while (S <= n) {       S <<= 1;     }     S <<= 1;     _(S);     X[0] = num(1);     NTT(_1, S, 1);     NTT(X, S, 1);     while (xxx) {       if (xxx & 1) {         for (register int i = 0; i < S; i++) {           X[i] = X[i] * _1[i];         }       }       for (register int i = 0; i < S; i++) {         _1[i] = _1[i] * _1[i];       }       xxx >>= 1;     }     NTT(X, S, -1);     num ans = num(0);     for (int i = 0; i <= S; i++) {       ans = ans + (X[i] * X[i]);     }     printf( %d , ans.x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100010;   vector<int> a[MAX], ans;   int x, y, n;   bool v[MAX], d[MAX], f[MAX], l[MAX], odd[MAX], even[MAX];   void DFS(int start) {     v[start] = true;     if (d[start] && odd[start]) {       f[start] = (1 - f[start]);     }     if (!d[start] && even[start]) {       f[start] = (1 - f[start]);     }     if (f[start] != l[start]) {       ans.push_back(start);       if (d[start]) {         odd[start] = (1 - odd[start]);       } else {         even[start] = (1 - even[start]);       }     }     int current;     for (int i = 0; i < a[start].size(); i++) {       current = a[start][i];       if (!v[current]) {         d[current] = (1 - d[start]);         odd[current] = odd[start];         even[current] = even[start];         DFS(current);       }     }   }   int main() {     cin >> n;     for (int i = 1; i < n; i++) {       cin >> x >> y;       a[x].push_back(y);       a[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       cin >> f[i];     }     for (int i = 1; i <= n; i++) {       cin >> l[i];     }     DFS(1);     cout << ans.size() <<   n ;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i] <<   n ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[3];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> a[0] >> a[1] >> a[2];     sort(a, a + 3);     if (a[0] + a[1] > a[2]) {       cout << 0 << endl;       return 0;     }     cout << a[2] - a[1] - a[0] + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<int> d;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t, n, a, k = 0;     cin >> t >> n;     int x[200] = {};     for (int i = 1; i <= t; ++i) {       cin >> a;       if (x[a] >= 1)         continue;       else {         x[a] += 1;         d.insert(i);       }     }     if (d.size() < n)       cout <<  NO n ;     else {       cout <<  YES n ;       for (auto i : d) {         k += 1;         cout << i <<    ;         if (k == n) break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline double sq(double a) { return a * a; }   int a, b;   int n;   complex<double> p1[1024], p2[1024];   double d[1024][1024];   int vis[1024];   double distanceSP(const complex<double>& s0, const complex<double>& s1,                     const complex<double>& p) {     if (s0.real() <= p.real() && p.real() <= s1.real()) {       return sq(p.imag() - s0.imag());     }     if (s0.imag() <= p.imag() && p.imag() <= s1.imag()) {       return sq(p.real() - s0.real());     }     return min(norm(s0 - p), norm(s1 - p));   }   double distanceSS(const complex<double>& s0, const complex<double>& s1,                     const complex<double>& t0, const complex<double>& t1) {     return min(min(distanceSP(s0, s1, t0), distanceSP(s0, s1, t1)),                min(distanceSP(t0, t1, s0), distanceSP(t0, t1, s1)));   }   double solve() {     for (int i = 0; i < (int)(n); i++)       for (int j = 0; j < (int)(i); j++) {         d[i][j] = d[j][i] = distanceSS(p1[i], p2[i], p1[j], p2[j]);       }     queue<pair<double, int> > q;     q.push(make_pair(0.0, 0));     vis[0] = 1;     double ans = -1;     while (!q.empty()) {       const pair<double, int> vv(q.front());       q.pop();       const double t = -vv.first;       const int at = vv.second;       if (ans >= 0 && t >= ans) break;       for (int i = 0; i < (int)(n); i++)         if (vis[i] == 0 && d[at][i] <= a * a) {           if (i == 1) {             const double nt = t + sqrt(d[at][i]);             if (ans == -1 || ans > nt) ans = nt;           } else {             vis[i] = 1;             q.push(make_pair(-t - a - b, i));           }         }     }     return ans;   }   int main() {     scanf( %d%d , &a, &b);     for (int i = 0; i < (int)(2); i++) {       int x, y;       scanf( %d%d , &x, &y);       p1[i] = p2[i] = complex<double>(x, y);     }     scanf( %d , &n);     for (int i = 0; i < (int)(n); i++) {       int x1, y1, x2, y2;       scanf( %d%d%d%d , &x1, &y1, &x2, &y2);       if (x1 > x2) swap(x1, x2);       if (y1 > y2) swap(y1, y2);       p1[i + 2] = complex<double>(x1, y1);       p2[i + 2] = complex<double>(x2, y2);     }     n += 2;     const double ans = solve();     if (ans < 0)       printf( %d n , -1);     else       printf( %.9f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pi = pair<int, int>;   using pll = pair<ll, ll>;   int n, k;   vector<int> x;   bool disjoint(int l1, int r1, int l2, int r2) { return r1 < l2 || r2 < l1; }   int main() {     ios_base::sync_with_stdio(false);     cout << setprecision(12);     cin.tie(nullptr);     cin >> n >> k;     x.resize(k);     for (int i = 0; i < int(k); i++) cin >> x[i], x[i]--;     vector<int> fst(n, -1), lst(n, k);     for (int i = 0; i < int(k); i++) lst[x[i]] = i;     for (int i = k - 1; i >= 0; i--) fst[x[i]] = i;     ll ans = 0;     for (int i = 0; i < int(n); i++)       if (fst[i] == -1) ans++;     for (int i = 0; i < int(n - 1); i++) {       if (fst[i] == -1 || fst[i + 1] == -1) {         ans += 2;         continue;       }       if (lst[i] < fst[i + 1]) ans++;       if (lst[i + 1] < fst[i]) ans++;     }     cout << ans << endl;   }