malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, tot, X, Y, a[25][25], d[25], id[25][25];   double p[25], b[500][2], c[500][500], ans[25];   void work() {     scanf( %d %d %d %d , &n, &m, &X, &Y);     if (X == Y) {       for (int i = 1; i <= n; i++) printf( %.10lf  , 1.0 * int(i == X));       return;     }     for (int i = 1, x, y; i <= m; i++)       scanf( %d %d , &x, &y), a[x][y] = a[y][x] = 1, d[x]++, d[y]++;     for (int i = 1; i <= n; i++) scanf( %lf , &p[i]);     for (int i = 1; i <= n; i++)       for (int j = i; j <= n; j++) id[i][j] = id[j][i] = ++tot;     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++) {         int x = id[i][j];         double q = 1 - p[i] * p[j];         for (int k = 1; k <= n; k++)           if (a[i][k])             for (int l = 1; l <= n; l++)               if (a[j][l])                 c[x][id[k][l]] += (1 - p[i]) * (1 - p[j]) / d[i] / d[j] / q;         for (int k = 1; k <= n; k++)           if (a[i][k]) c[x][id[k][j]] += (1 - p[i]) * p[j] / d[i] / q;         for (int k = 1; k <= n; k++)           if (a[j][k]) c[x][id[i][k]] += p[i] * (1 - p[j]) / d[j] / q;       }     b[id[X][Y]][0] = 1;     for (int T = 5000; T; T--) {       for (int i = 1; i <= tot; i++)         for (int j = 1; j <= tot; j++) b[j][1] += b[i][0] * c[i][j];       for (int i = 1; i <= tot; i++) b[i][0] = b[i][1], b[i][1] = 0;       for (int i = 1; i <= n; i++) ans[i] += b[id[i][i]][0];     }     for (int i = 1; i <= n; i++) printf( %.10lf  , ans[i]);   }   int main() {     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h, w, ii, jj, ans = 0;     cin >> h >> w;     char a[505][505];     for (int i = 0; i < h; i++)       for (int j = 0; j < w; j++) cin >> a[i][j];     for (int i = 0; i < h; i++) {       for (int j = 0; j < w; j++) {         if (a[i][j] ==  * ) {           if ((i - 1 >= 0 && a[i - 1][j] ==  * ) &&               (j - 1 >= 0 && a[i][j - 1] ==  * ) &&               (i + 1 <= h - 1 && a[i + 1][j] ==  * ) &&               (j + 1 <= w - 1 && a[i][j + 1] ==  * )) {             ii = i;             jj = j;             ans = 1;             while (ii >= 0 && a[ii][jj] ==  * ) {               a[ii][jj] =  @ ;               ii--;             }             ii = i;             a[ii][jj] =  * ;             while (jj >= 0 && a[ii][jj] ==  * ) {               a[ii][jj] =  @ ;               jj--;             }             jj = j;             a[ii][jj] =  * ;             while (ii < h && a[ii][jj] ==  * ) {               a[ii][jj] =  @ ;               ii++;             }             ii = i;             a[ii][jj] =  * ;             while (jj < w && a[ii][jj] ==  * ) {               a[ii][jj] =  @ ;               jj++;             }             jj = j;             break;           }         }       }       if (ans == 1) break;     }     if (ans == 0) {       cout <<  NO ;       return 0;     }     for (int i = 0; i < h; i++) {       for (int j = 0; j < w; j++) {         if (a[i][j] ==  * ) ans = 0;       }     }     if (ans == 0) {       cout <<  NO ;     } else       cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   long long fac[100001];   long long inv_fac[100001];   int val[100001];   vector<int> cnt(53, 0);   int l[100001];   int r[100001];   long long keep[53][53];   long long dp[54][100001];   long long dp1[54][100001];   long long mod = 1e9 + 7;   inline void add(long long &a, long long b) {     a += b;     if (a >= mod) a -= mod;   }   inline void sub(long long &a, long long b) {     a -= b;     if (a < 0) a += mod;   }   long long pw(long long x, int p) {     if (p == 0) return 1;     if (p == 1) return x % mod;     long long temp = pw(x, p / 2);     temp = (temp * temp) % mod;     if (p % 2 == 0) return temp;     temp = (x * temp) % mod;     return temp;   }   void calc() {     fac[0] = fac[1] = 1;     inv_fac[0] = inv_fac[1] = 1;     for (int i = 2; i <= 100000; i++) {       fac[i] = (i * fac[i - 1]) % mod;       inv_fac[i] = pw(fac[i], mod - 2);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     int q;     cin >> q;     for (int i = 0; i < q; i++) cin >> l[i] >> r[i];     int n = s.size();     int mx = n / 2;     calc();     for (int i = 0; i < n; i++) {       if (s[i] >=  a  && s[i] <=  z ) {         val[i + 1] = int(s[i] -  a ) + 1;         cnt[int(s[i] -  a ) + 1]++;       } else {         val[i + 1] = 26 + int(s[i] -  A ) + 1;         cnt[26 + int(s[i] -  A ) + 1]++;       }     }     for (int i = 1; i <= 52; i++) {       int temp = cnt[i];       if (temp > n / 2 || cnt[i] == 0) {         continue;       }       temp = n / 2 - temp;       for (int w = 0; w <= mx; w++) dp[0][w] = dp1[53][w] = 0;       dp[0][0] = dp1[53][0] = 1;       for (int k = 1; k <= 52; k++) {         if (k == i || cnt[k] == 0) {           for (int w = 0; w <= mx; w++) dp[k][w] = dp[k - 1][w];           continue;         }         for (int w = 0; w <= mx; w++) {           dp[k][w] = dp[k - 1][w];           if (w >= cnt[k]) add(dp[k][w], dp[k - 1][w - cnt[k]]);         }       }       for (int k = 52; k >= 1; k--) {         if (k == i || cnt[k] == 0) {           for (int w = 0; w <= mx; w++) dp1[k][w] = dp1[k + 1][w];           continue;         }         for (int w = 0; w <= mx; w++) {           dp1[k][w] = dp1[k + 1][w];           if (w >= cnt[k]) add(dp1[k][w], dp1[k + 1][w - cnt[k]]);         }       }       for (int k = i; k <= 52; k++) {         if (k == i) {           keep[k][i] = dp[52][temp];           continue;         }         long long t1 = 0;         int rem = temp - cnt[k];         if (rem < 0) {           keep[k][i] = keep[i][k] = 0;           continue;         }         for (int w = 0; w <= rem; w++) {           long long t2 = (dp[k - 1][w] * dp1[k + 1][rem - w]) % mod;           add(t1, t2);         }         keep[i][k] = keep[k][i] = t1;       }     }     long long ans = (fac[n / 2] * fac[n / 2]) % mod;     for (int i = 1; i <= 52; i++) ans = (ans * inv_fac[cnt[i]]) % mod;     ans = (2 * ans) % mod;     for (int i = 0; i < q; i++) {       int x = val[l[i]];       int y = val[r[i]];       long long temp = ans;       temp = (temp * keep[x][y]) % mod;       cout << temp << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100010, M = 100010, inf = 1e18;   long long m, n, p, d[N], a[M], f[M], sum[M], g[M], x[M], y[M];   inline long long read() {     char ch = getchar();     long long as = 0, f = 1;     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) f = -1;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) as = as * 10 + ch -  0 ;     return as;   }   long long q[M << 1], l, r;   long long as = inf;   int main() {     long long h, t;     n = read();     m = read();     p = read();     for (long long i = 1; i < n; i++) d[i] = read();     for (long long i = n - 2; i; i--) d[i] += d[i + 1];     for (long long i = 1; i <= m; i++) {       h = read();       t = read();       a[i] = t + d[h];     }     sort(a + 1, a + m + 1);     for (long long i = 1; i <= m; i++) sum[i] = sum[i - 1] + a[i], f[i] = inf;     for (long long i = 1; i <= p; i++) {       memcpy(g, f, sizeof(g));       l = M;       r = M;       for (long long j = 0; j <= m; j++) y[j] = g[j] + sum[j];       q[r] = 0;       for (long long j = 1; j <= m; j++) {         while (r > l)           if ((y[q[l + 1]] - y[q[l]]) <= a[j] * (q[l + 1] - q[l]))             l++;           else             break;         f[j] = min(g[j], -a[j] * q[l] + y[q[l]] + a[j] * j - sum[j]);         while (r > l)           if ((y[q[r]] - y[q[r - 1]]) * (j - q[r]) >=               (y[j] - y[q[r]]) * (q[r] - q[r - 1]))             r--;           else             break;         r++;         q[r] = j;       }       as = min(as, f[m]);     }     printf( %lld , as);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e5 + 5;   vector<pair<long long, long long>> v;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long x, y, bx, by, xs, ys, t, temp1, temp2, temp;     long long ax, ay;     int ans = 0;     cin >> x >> y >> ax >> ay >> bx >> by >> xs >> ys >> t;     while (x <= 5e16 && y <= 5e16) {       v.push_back({x, y});       x = ax * x + bx;       y = ay * y + by;     }     for (int i = 0; i < v.size(); i++) {       for (int j = i; j < v.size(); j++) {         temp = abs(v[i].first - v[j].first) + abs(v[i].second - v[j].second);         temp1 = abs(v[i].first - xs) + abs(v[i].second - ys);         temp2 = abs(xs - v[j].first) + abs(ys - v[j].second);         if (temp + temp1 <= t) {           ans = max(ans, j - i + 1);         }         if (temp + temp2 <= t) {           ans = max(ans, j - i + 1);         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[101010];   long long s[101010];   long long a[101010];   int main() {     ios_base::sync_with_stdio(0);     long long n, l;     cin >> n >> l;     for (int i = 1; i <= n; ++i) cin >> a[i];     sort(a + 1, a + n + 1);     if (n == 1) {       cout << fixed << setprecision(10) << (long double)max(a[1], l - a[1]);       return 0;     }     a[0] = 0;     long long ans = 0;     a[n + 1] = l;     for (int i = 1; i <= n + 1; ++i) ans = max(ans, a[i] - a[i - 1]);     ans = max(ans, max(a[1] * 2, (a[n + 1] - a[n]) * 2));     cout << fixed << setprecision(10) << (long double)(ans / 2.0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 501;   int dp[maxn][maxn];   int n;   int a[maxn];   int dp2[maxn];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i], dp[i][i] = a[i];     for (int len = 1; len <= n; len++) {       for (int i = 1; i <= n - len + 1; i++) {         for (int k = i; k < i + len - 1; k++) {           if (dp[i][k] != 0 && dp[i][k] == dp[k + 1][i + len - 1]) {             dp[i][i + len - 1] = dp[i][k] + 1;           }         }       }     }     for (int i = 1; i <= n; i++) {       dp2[i] = dp2[i - 1] + 1;       for (int j = 1; j < i; j++) {         if (dp[j][i] > 0) {           dp2[i] = min(dp2[i], dp2[j - 1] + 1);         }       }     }     printf( %d n , dp2[n]);     return 0;   }
#include <bits/stdc++.h>   const int N = 1000010, P = 1000000007;   int n, i, j, x, ans, po[N], a[N], f[N];   int main() {     scanf( %d , &n);     for (po[0] = i = 1; i <= n; i++) po[i] = 2 * po[i - 1] % P;     while (n--) scanf( %d , &x), a[x]++;     for (i = N - 1; i > 1; i--) {       for (j = i, x = 0; j < N; j += i) x += a[j];       if (x) {         f[i] = 1LL * x * po[x - 1] % P;         for (j = i + i; j < N; j += i) f[i] = (f[i] - f[j] + P) % P;         ans = (1LL * f[i] * i + ans) % P;       }     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a;   int x;   int main() {     while (cin >> x) {       a.push_back(x);     }     if (((a[3] - a[2]) == (a[2] - a[1])) && ((a[2] - a[1]) == (a[1] - a[0]))) {       cout << a[3] + a[3] - a[2] << endl;       return 0;     } else {       if (a[0] != 0) {         if (a[1] != 0) {           if (a[1] != a[0]) {             if ((((double)a[1] / a[0]) == ((double)a[2] / a[1])) &&                 (((double)a[2] / a[1]) == ((double)a[3] / a[2]))) {               if ((int)(a[3] * ((double)a[3] / a[2])) ==                   (a[3] * ((double)a[3] / a[2]))) {                 cout << a[3] * ((double)a[3] / a[2]) << endl;                 return 0;               }             }           }         }       }     }     cout << 42 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   istream& operator>>(istream& in, vector<T>& vec) {     for (auto& v : vec) {       in >> v;     }     return in;   }   template <class T>   ostream& operator<<(ostream& o, const vector<T>& vec) {     o <<  [ ;     for (const auto& v : vec) {       o << v <<    ;     }     o <<  ] n ;     return o;   }   int main() {     int n, m, t;     cin >> n >> m >> t;     vector<vector<int>> mat(n, vector<int>(m));     vector<vector<int>> bsm(m);     cin >> mat;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (mat[i][j] != 2) {           bsm[j].push_back(i);         }       }     }     while (t--) {       int colI, rowI = -1;       cin >> colI;       colI--;       while (true) {         int newRowI = n;         {           auto& bsv = bsm[colI];           int l = 0, r = bsv.size(), m;           while (l < r) {             m = (l + r) / 2;             if (bsv[m] < rowI) {               l = m + 1;             } else {               r = m;             }           }           if (l < bsv.size()) {             newRowI = bsv[l];             int i = l + 1;             for (; i < bsv.size() && bsv[i] == bsv[l]; i++) {             }             if (i < bsv.size()) {               for (int a = l; a < i; a++) {                 bsv[a] = bsv[i];               }             } else {               while (i-- > l) {                 bsv.pop_back();               }             }           }         }         rowI = newRowI;         if (rowI >= n) {           cout << colI + 1 <<    ;           break;         } else {           if (mat[rowI][colI] == 1) {             colI++;           } else {             colI--;           }         }       }     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   int n, m, ans[N], h[N];   bitset<N> a[N];   vector<int> e[N];   bool check1() {     for (int i = (int)(1); i <= (int)(n); i++)       if (e[i].size() & 1) return 0;     return 1;   }   void gauss() {     int it = 1;     for (int i = (int)(1); i <= (int)(n); i++) {       int j = it;       for (; j <= n; j++)         if (a[j][i]) break;       if (j > n) continue;       if (j > it) swap(a[j], a[it]);       h[it] = i;       for (int j = (int)(it + 1); j <= (int)(n); j++)         if (a[j][i]) a[j] ^= a[it];       it++;     }     int las = n + 1;     for (int i = (int)(it - 1); i >= (int)(1); i--) {       for (int j = (int)(h[i] + 1); j <= (int)(las - 1); j++) ans[j] = 0;       ans[h[i]] = a[i][0];       for (int j = (int)(1); j <= (int)(i - 1); j++)         if (a[j][h[i]]) a[j] ^= a[i];       las = h[i];     }     for (int i = (int)(1); i <= (int)(las - 1); i++) ans[i] = 0;   }   void solve() {     scanf( %d%d , &n, &m);     for (int i = (int)(1); i <= (int)(n); i++) e[i].clear();     for (int i = (int)(1); i <= (int)(m); i++) {       int x, y;       scanf( %d%d , &x, &y);       e[x].push_back(y);       e[y].push_back(x);     }     if (check1()) {       puts( 1 );       for (int i = (int)(1); i <= (int)(n); i++) printf( 1  );       puts(  );       return;     }     for (int i = (int)(1); i <= (int)(n); i++) {       a[i] = 0;       for (auto j : e[i]) a[i].set(j);       if (e[i].size() & 1) a[i].set(i), a[i].set(0);     }     memset(ans, 0, sizeof(ans));     gauss();     puts( 2 );     for (int i = (int)(1); i <= (int)(n); i++) printf( %d  , ans[i] + 1);     puts(  );   }   int main() {     int T;     scanf( %d , &T);     while (T--) solve();   }
#include <bits/stdc++.h>   #pragma warning(disable : 4786)   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   int A[100005];   int I[100005];   int D[100005];   int n;   int max(int a, int b) {     if (a > b) return a;     return b;   }   int ABS(int a) {     if (a < 0) return a = a * -1;     return a;   }   int main() {     int i, j, len, res, cur, res1;     while (scanf( %d , &n) != EOF) {       for (i = 0; i < n; i++) {         scanf( %d , &A[i]);       }       I[0] = 1;       for (i = 1; i < n; i++) {         if (A[i] > A[i - 1]) {           I[i] = I[i - 1] + 1;         } else {           I[i] = 1;         }       }       D[n - 1] = 1;       for (i = n - 1; i >= 0; i--) {         if (A[i] < A[i + 1]) {           D[i] = D[i + 1] + 1;         } else {           D[i] = 1;         }       }       res = 1;       for (i = 0; i < n; i++) {         if (i == 0) {           if (i + 1 < n) res = max(res, D[i + 1] + 1);         } else if (i == n - 1) {           if (i - 1 >= 0) res = max(res, I[i - 1] + 1);         } else {           int r = I[i - 1] + D[i + 1];           if (ABS(A[i - 1] - A[i + 1]) > 1 && A[i + 1] > A[i - 1]) {             res = max(res, r + 1);           }           res = max(res, I[i - 1] + 1);           res = max(res, D[i + 1] + 1);         }       }       printf( %d n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 998244353;   long long POW(long long a, long long b, long long MMM = MOD) {     long long ret = 1;     for (; b; b >>= 1, a = (a * a) % MMM)       if (b & 1) ret = (ret * a) % MMM;     return ret;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) {     if (a == 0 || b == 0) return a + b;     return a * (b / gcd(a, b));   }   int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};   int ddx[] = {-1, -2, 1, -2, 2, -1, 2, 1}, ddy[] = {-2, -1, -2, 1, -1, 2, 1, 2};   struct Edge {     int to, r;     Edge* ori;     Edge* rev;     Edge(int T, int R) { to = T, r = R; }   };   vector<Edge*> v[2605];   void addedge(int f, int t, int r) {     Edge* ori = new Edge(t, r);     Edge* rev = new Edge(f, 0);     ori->rev = rev;     rev->rev = ori;     v[f].push_back(ori);     v[t].push_back(rev);   }   const int S = 2603, T = 2604;   int level[2605], work[2605];   bool bfs() {     memset((level), -1, sizeof(level));     ;     level[S] = 0;     queue<int> q;     q.push(S);     while (!q.empty()) {       int x = q.front();       q.pop();       for (auto& nn : v[x]) {         int next = nn->to;         if (level[next] == -1 && nn->r > 0) {           level[next] = level[x] + 1;           q.push(next);         }       }     }     return level[T] != -1;   }   int dfs(int N, int des, int flow) {     if (N == des) return flow;     for (int& i = work[N]; i < v[N].size(); i++) {       int next = v[N][i]->to;       if (level[next] == level[N] + 1 && v[N][i]->r > 0) {         int df = dfs(next, des, min(v[N][i]->r, flow));         if (df > 0) {           v[N][i]->r -= df;           v[N][i]->rev->r += df;           return df;         }       }     }     return 0;   }   int main() {     int n, h, m;     scanf( %d%d%d , &n, &h, &m);     int ans = n * h * h;     for (int(i) = (0); (i) <= (n - 1); (i) += (1)) {       addedge(S, i * 51, h * h);       for (int(j) = (1); (j) <= (h); (j) += (1))         addedge(51 * i + j - 1, 51 * i + j, h * h - j * j);     }     for (int(i) = (0); (i) <= (m - 1); (i) += (1)) {       int x, y, z, w;       scanf( %d%d%d%d , &x, &y, &z, &w);       x--, y--;       for (int(j) = (x); (j) <= (y); (j) += (1))         addedge(51 * j + z, 2551 + i, 987654321);       addedge(2551 + i, T, w);     }     while (bfs()) {       memset((work), 0, sizeof(work));       ;       while (1) {         int f = dfs(S, T, 987654321);         if (f == 0) break;         ans -= f;       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int N = 1000005;   const double PI = 4 * atan(1);   const double eps = 1e-7;   long long x, y, z;   int main() {     ios::sync_with_stdio(0);     cin >> x >> y >> z;     long long ans = 0;     ans = x / z + y / z;     long long a, b;     a = x;     b = y;     long long c = (z - x % z) % z;     long long res = 0;     if (b >= c && ((a + c) / z + (b - c) / z) > ans) {       ans = ((a + c) / z + (b - c) / z);       res = c;     }     a = x;     b = y;     c = (z - y % z) % z;     if (a >= c && ((a - c) / z + (b + c) / z) > ans) {       ans = ((a + c) / z + (b - c) / z);       res = c;     } else if (a >= c && ((a - c) / z + (b + c) / z) == ans) {       res = min(res, c);     }     cout << ans <<     << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int a[N], b[N], d[N], used[N], dis[N], ANS[N], dlt[N];   int n, m, Y0, Y1, lft, ans;   vector<int> ch[N], fa[N];   priority_queue<pair<int, int>, vector<pair<int, int> >,                  greater<pair<int, int> > >       pq;   int ABS(int x) {     if (x >= 0)       return x;     else       return -x;   }   int lnk(int x, int y) {     ch[x].push_back(y);     fa[y].push_back(x);     return ABS(b[x] - a[y]);   }   int avi(int x) {     int ret = 0;     for (int i = 0; i < int(fa[x].size()); i++) {       int to = fa[x][i];       if (used[to] == -1 || used[to] == dis[x]) ret++;     }     return ret;   }   int main() {     scanf( %d%d%d%d , &n, &m, &Y0, &Y1);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= m; i++) scanf( %d , b + i);     for (int i = 1; i <= m; i++) used[i] = -1;     for (int i = 1; i <= n; i++) {       int x = lower_bound(b + 1, b + 1 + m, a[i]) - b - 1;       int y = x + 1;       if (x == 0)         dis[i] = lnk(y, i);       else if (y == m + 1)         dis[i] = lnk(x, i);       else if (a[i] - b[x] < b[y] - a[i])         dis[i] = lnk(x, i);       else if (a[i] - b[x] > b[y] - a[i])         dis[i] = lnk(y, i);       else {         dis[i] = lnk(x, i);         lnk(y, i);       }       if (avi(i) == 1) {         dlt[i] = 1;         pq.push(make_pair(dis[i], i));       }     }     lft = n;     while (!pq.empty()) {       int D = pq.top().first, x = pq.top().second, y;       pq.pop();       lft--;       if (avi(x) == 0) continue;       for (int i = 0; i < int(fa[x].size()); i++) {         y = fa[x][i];         if (used[y] == -1 || used[y] == D) break;       }       used[y] = D;       ANS[y]++;       for (int i = 0; i < int(ch[y].size()); i++) {         int to = ch[y][i];         if (dis[to] != D && !dlt[to] && avi(to) == 1) {           dlt[to] = 1;           pq.push(make_pair(dis[to], to));         }       }     }     for (int i = 1; i <= m; i++) ans += ANS[i];     ans += lft;     printf( %d n , n - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     char t[n + 1];     scanf( %s , t);     int i = 0, k = 1;     while (t[i] !=   0 ) {       printf( %c , t[i]);       i = i + k;       k++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3fll;   const long long M = 1e9 + 7;   const long long maxn = 1e6 + 7;   const double pi = acos(-1.0);   const double eps = 0.00000001;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   template <typename T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <typename T>   inline T powMM(T a, T b) {     T ret = 1;     for (; b; b >>= 1ll, a = (long long)a * a % M)       if (b & 1) ret = (long long)ret * a % M;     return ret;   }   int A[maxn];   map<int, int> S;   vector<int> del, ini[2], have[2];   int cnt[2], ans;   int main() {     int n, m, i, j;     scanf( %d%d , &n, &m);     m = min(m, n * 2);     for (i = 1; i <= n; i++) scanf( %d , &A[i]);     for (i = 1; i <= n; i++) {       if (S.count(A[i])) {         del.push_back(i);         ans++;       } else {         S[A[i]] = i, cnt[A[i] & 1]++;         ini[A[i] & 1].push_back(i);       }     }     for (i = 0; i < 2; i++) {       sort(ini[i].begin(), ini[i].end());       for (j = 0; j < (int)ini[i].size() - n / 2; j++) {         S.erase(A[ini[i][j]]);         cnt[i]--;         ans++;         del.push_back(ini[i][j]);       }     }     j = 0;     for (i = 1; i <= m; i++) {       if (!S.count(i)) {         if (cnt[i & 1] != n / 2) {           cnt[i & 1]++;           A[del[j++]] = i;         }       }     }     if (cnt[0] != n / 2 || cnt[1] != n / 2) return 0 * puts( -1 );     printf( %d n , ans);     for (i = 1; i <= n; i++) printf( %d  , A[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, mn, mx, ans = 0;     cin >> n >> a;     mn = mx = a;     for (int i = 1; i < n; i++) {       cin >> a;       if (a < mn) {         mn = a;         ans++;       }       if (a > mx) {         mx = a;         ans++;       }     }     cout << ans;   }