Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n - 2) {
		vector<P> tmp;
		tmp.push_back(make_pair(a[i],1)); tmp.push_back(make_pair(a[i + 1],2));
		tmp.push_back(make_pair(a[i + 2],3));
		sort(ALL(tmp));
		if (tmp[1].second == 2) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n - 2) {
		vector<P> tmp;
		tmp.push_back(make_pair(a[i],1)); tmp.push_back(make_pair(a[i + 1],2));
		tmp.push_back(make_pair(a[i + 2],3));
		sort(ALL(tmp));
		if (tmp[1].second == 2) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:109:2: error: stray '#' in program
  109 | }#include <iostream>
      |  ^
a.cc:109:3: error: 'include' does not name a type
  109 | }#include <iostream>
      |   ^~~~~~~
a.cc:148:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
  148 | template<class T> inline bool chmax(T& a, T b) {
      |                               ^~~~~
a.cc:40:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   40 | template<class T> inline bool chmax(T& a, T b) {
      |                               ^~~~~
a.cc:177:4: error: redefinition of 'long long int gcd(long long int, long long int)'
  177 | ll gcd(ll a, ll b) {
      |    ^~~
a.cc:69:4: note: 'long long int gcd(long long int, long long int)' previously defined here
   69 | ll gcd(ll a, ll b) {
      |    ^~~
a.cc:182:4: error: redefinition of 'long long int lcm(long long int, long long int)'
  182 | ll lcm(ll a, ll b) {
      |    ^~~
a.cc:74:4: note: 'long long int lcm(long long int, long long int)' previously defined here
   74 | ll lcm(ll a, ll b) {
      |    ^~~
a.cc:186:6: error: redefinition of 'bool prime(long long int)'
  186 | bool prime(ll n) {
      |      ^~~~~
a.cc:78:6: note: 'bool prime(long long int)' previously defined here
   78 | bool prime(ll n) {
      |      ^~~~~
a.cc:194:17: error: redefinition of 'const long long int MOD'
  194 | const long long MOD = 1000000007;
      |                 ^~~
a.cc:86:17: note: 'const long long int MOD' previously defined here
   86 | const long long MOD = 1000000007;
      |                 ^~~
a.cc:195:17: error: redefinition of 'const long long int INF'
  195 | const long long INF = 1LL << 60;
      |                 ^~~
a.cc:87:17: note: 'const long long int INF' previously defined here
   87 | const long long INF = 1LL << 60;
      |                 ^~~
a.cc:198:11: error: redefinition of 'const long long int MAX_N'
  198 | const int MAX_N = 100010;
      |           ^~~~~
a.cc:90:11: note: 'const long long int MAX_N' previously defined here
   90 | const int MAX_N = 100010;
      |           ^~~~~
a.cc:200:8: error: redefinition of 'int main()'
  200 | signed main() {
      |        ^~~~
a.cc:92:8: note: 'int main()' previously defined here
   92 | signed main() {
      |        ^~~~