func_code_string: //   #include <bits/stdc++.h>   using namespace std;      #define fi first   #define se second   #define all(x) x.begin(), x.end()   #define lch (o << 1)   #define rch (o << 1 | 1)      typedef double db;   typedef long long ll;   typedef unsigned int ui;   typedef pair<int, int> pint;   typedef tuple<int, int, int> tint;      const int N = 1e5 + 5;   const int INF = 0x3f3f3f3f;   const ll INF_LL = 0x3f3f3f3f3f3f3f3f;      int a[N];   int mxsuf[N];      int main() {    ios::sync_with_stdio(0);       int n;    cin >> n;    for (int i = 1; i <= n; i++)     cin >> a[i];       vector<int> vec;    int pre = 1;    for (int i = 2; i < n; i++) {     int sgn1 = a[i] - a[i - 1];     sgn1 /= abs(sgn1);     int sgn2 = a[i + 1] - a[i];     sgn2 /= abs(sgn2);     if (sgn1 * sgn2 == -1) {      vec.push_back(i - pre + 1);      pre = i;     }    }    vec.push_back(n - pre + 1);       int m = vec.size();    for (int i = m - 1; i >= 0; i--)     mxsuf[i] = max(mxsuf[i + 1], vec[i]);       int dir = a[2] - a[1];    dir /= abs(dir);    int ans = 0;    int mxpre = 0;    for (int i = 0; i < m; i++) {     if (i - 2 >= 0)      mxpre = max(mxpre, vec[i - 2]);     if (dir == -1 && i > 0) {      int mx = max(vec[i - 1], vec[i]);      int mn = min(vec[i - 1], vec[i]);      bool flag = (mxpre >= mx);      if (i + 1 < m)       flag |= mxsuf[i + 1] >= mx;      flag |= (mn % 2 == 0);      flag |= (mn % 2 == 1) && (mn < mx);      ans += !flag;     }     dir *= -1;    }       cout << ans << endl;       return 0;   }   