stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

#define INF 1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define arr array

#define _min(a) *min_element(a.begin(), a.end());

#define _max(a) *max_element(a.begin(), a.end());

#define _sort(x) sort(x.begin(), x.end())

#define _rsort(x) sort(x.rbegin(), x.rend())

#define _reverse(x) reverse(x.begin(), x.end())

#define _debug(x) cout << #x << " = " << x << endl;

#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;

#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()

#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()

typedef long long ll;

using namespace std;



void solve() {	 

	int n, cnt = 0; cin >> n;

	vector<int> a(n); for (auto &u : a) cin >> u;

	for (int i = 1; i < n - 1; ++i) {

		if (a[i] > a[i - 1] && a[i] < a[i + 1] || a[i] < a[i - 1] && a[i] > a[i + 1]) {

			++cnt;

		}

	}

	cout << cnt << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(nullptr);



    // int t; cin >> t;

    // while(t--) 

        solve();

}

// Faster C++ solution for the same problem (measured speedup: 5.34248624436292x):
#include<stdio.h>



int main()

{

    int i,j,a[30],n,temp=0;



    scanf("%d",&n);



    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }



    for(i=1;i<n-1;i++)

    {

        if(a[i-1]<a[i] && a[i]<a[i+1])

            temp++;



        else if(a[i-1]>a[i] && a[i]>a[i+1])

            temp++;

    }



    printf("%d",temp);



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

int main()

{

	int n;

	std::cin>>n;

	int arr[n];

	for(int i=0;i<n;i++)

	std::cin>>arr[i];

	int j=0;

	for(int i=1;i<n-1;i++)

	{

		if(arr[i]<arr[i-1] and arr[i]>arr[i+1])

		j++;

		else if(arr[i]>arr[i-1] and arr[i]<arr[i+1])

		j++;

	}

	std::cout<<j<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 5.237171575203605x):
#include<stdio.h>



int main()

{

    int i,j,a[30],n,temp=0;



    scanf("%d",&n);



    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }



    for(i=1;i<n-1;i++)

    {

        if(a[i-1]<a[i] && a[i]<a[i+1])

            temp++;



        else if(a[i-1]>a[i] && a[i]>a[i+1])

            temp++;

    }



    printf("%d",temp);



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main()  {

    int n;

    cin>>n;

    int a[n];

    

    for(int i=0; i<n;i++){

        cin>>a[i];

        }

    int c=0;

    for(int i=1; i<n-1;i++){

        if((a[i]<a[i-1]&&a[i]>a[i+1])||(a[i]>a[i-1] && a[i]<a[i+1]))

            c++;

        }

        cout<<c;

}

// Faster C++ solution for the same problem (measured speedup: 5.2272348000048865x):
#include<stdio.h>



int main()

{

    int i,j,a[30],n,temp=0;



    scanf("%d",&n);



    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }



    for(i=1;i<n-1;i++)

    {

        if(a[i-1]<a[i] && a[i]<a[i+1])

            temp++;



        else if(a[i-1]>a[i] && a[i]>a[i+1])

            temp++;

    }



    printf("%d",temp);



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;



using std::vector;



int main()

{

    int n;

    cin >> n;



    vector<int> numbers(n);



    for (int i = 0; i < n; i++)

    {

        cin >> numbers[i];

    }



    int count = 0;

    for (int i = 0; i < n-2; i++)

    {

        if((numbers[i] < numbers[i+1] && numbers[i+1] < numbers[i+2]) || (numbers[i] > numbers[i+1] && numbers[i+1] > numbers[i+2]))

        {

            count++;

        }

    }



    cout << count << endl;





    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2441551959679105x):
#include<stdio.h>



int main()

{

    int i,j,a[30],n,temp=0;



    scanf("%d",&n);



    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }



    for(i=1;i<n-1;i++)

    {

        if(a[i-1]<a[i] && a[i]<a[i+1])

            temp++;



        else if(a[i-1]>a[i] && a[i]>a[i+1])

            temp++;

    }



    printf("%d",temp);



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

void debug() {cout<<endl;}

template<typename T,typename... Args>

void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}

#define forn(i,a,b) for(int i=a;i<b;++i)

#define SZ(x) int(x.size())

#define pb push_back

#define F first

#define S second

#define endl "\n"

typedef long long ll;

typedef pair<int, int> pii;



int main() {

    ios::sync_with_stdio(0); cin.tie(0);

    int n;

    cin >> n;

    int v[n];

    forn(i, 0, n) {

        cin >> v[i];

    }

    int ans = 0;

    forn(i, 1, n-1) {

        int aux[3] = {v[i-1], v[i], v[i+1]};

        sort(aux, aux+3);

        if (v[i] == aux[1]) ans++;

    }

    cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.306843519280154x):
#include<stdio.h>



int main()

{

    int i,j,a[30],n,temp=0;



    scanf("%d",&n);



    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }



    for(i=1;i<n-1;i++)

    {

        if(a[i-1]<a[i] && a[i]<a[i+1])

            temp++;



        else if(a[i-1]>a[i] && a[i]>a[i+1])

            temp++;

    }



    printf("%d",temp);



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main() {

	int N;

	cin>>N;

	int p[N+2];

	for(int i=1;i<=N;i++) {

		cin>>p[i];

	}

	int cnt = 0, minVal,maxVal;

	for(int i=2;i<N;i++) {

		minVal = min(min(p[i-1], p[i]), p[i+1]);

		maxVal = max(max(p[i-1], p[i]), p[i+1]);

		if(p[i] > minVal and p[i]< maxVal) cnt++;

	}

	printf("%d\n",cnt);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.158263141633393x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;

#include <algorithm>

int main()

{



    vector<long int> a;

    int n;

    cin >> n;

    for (int i = 0, f; i < n; i++)

    {

        cin >> f;

        a.push_back(f);



    }

    int o = 0;

    for (int i = 1; i < n - 1; i++)

    {

        if(a[i] > a[i - 1] && a[i] < a[i + 1])

            o++;

        else if (a[i] > a[i + 1] && a[i] < a[i - 1])

            o++;

    }

    cout << o;





}

// Faster C++ solution for the same problem (measured speedup: 5.268581597437312x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:


#include <iostream>

#include <bits/stdc++.h>

#include <stdio.h>



using namespace std;



#define loop(i, a, b) for (int i = int(a); i <= int(b) - 1; i++)

#define rloop(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)

#define scfi1(v) scanf("%d", &v)

#define scfi2(v1, v2) scanf("%d %d", &v1, &v2)

#define scfll1(v) scanf("%I64d", &v);

#define scfll2(v1, v2) scanf("%I64d %I64d", &v1, &v2)

#define sz(v) int(v.size())

#define ALL(c) c.begin(), c.end()

#define pb push_back

#define mp make_pair

#define test(x) cout << #x << " => { " << (x) << " }\n";



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<vi> vvi;

typedef vector<bool> vb;

typedef vector<pii> vp;



int n,x,cnt=0;

vi a;

int main()

{

    scfi1(n);

    loop(i ,0 , n){

        scfi1(x);

        a.pb(x);

    }

    for(int i=1;i<n-1;i++)

    {

        if((a[i]<=a[i+1] && a[i]>=a[i-1])|| (a[i]>=a[i+1] && a[i]<=a[i-1]))

            cnt++;

    }

    cout<<cnt;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.222000938725494x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define INF 1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define arr array

#define _min(a) *min_element(a.begin(), a.end());

#define _max(a) *max_element(a.begin(), a.end());

#define _sort(x) sort(x.begin(), x.end())

#define _rsort(x) sort(x.rbegin(), x.rend())

#define _reverse(x) reverse(x.begin(), x.end())

#define _debug(x) cout << #x << " = " << x << endl;

#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;

#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()

#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()

typedef long long ll;

using namespace std;



void solve() {	 

	int n, cnt = 0; cin >> n;

	vector<int> a(n); for (auto &u : a) cin >> u;

	for (int i = 1; i < n - 1; ++i) {

		if (a[i] > a[i - 1] && a[i] < a[i + 1] || a[i] < a[i - 1] && a[i] > a[i + 1]) {

			++cnt;

		}

	}

	cout << cnt << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(nullptr);



    // int t; cin >> t;

    // while(t--) 

        solve();

}

// Faster C++ solution for the same problem (measured speedup: 5.3276435245118225x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:
#include<bits/stdc++.h>

int main()

{

	int n;

	std::cin>>n;

	int arr[n];

	for(int i=0;i<n;i++)

	std::cin>>arr[i];

	int j=0;

	for(int i=1;i<n-1;i++)

	{

		if(arr[i]<arr[i-1] and arr[i]>arr[i+1])

		j++;

		else if(arr[i]>arr[i-1] and arr[i]<arr[i+1])

		j++;

	}

	std::cout<<j<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 5.222621444993182x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main()  {

    int n;

    cin>>n;

    int a[n];

    

    for(int i=0; i<n;i++){

        cin>>a[i];

        }

    int c=0;

    for(int i=1; i<n-1;i++){

        if((a[i]<a[i-1]&&a[i]>a[i+1])||(a[i]>a[i-1] && a[i]<a[i+1]))

            c++;

        }

        cout<<c;

}

// Faster C++ solution for the same problem (measured speedup: 5.212712276561005x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;



using std::vector;



int main()

{

    int n;

    cin >> n;



    vector<int> numbers(n);



    for (int i = 0; i < n; i++)

    {

        cin >> numbers[i];

    }



    int count = 0;

    for (int i = 0; i < n-2; i++)

    {

        if((numbers[i] < numbers[i+1] && numbers[i+1] < numbers[i+2]) || (numbers[i] > numbers[i+1] && numbers[i+1] > numbers[i+2]))

        {

            count++;

        }

    }



    cout << count << endl;





    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.229585663568729x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

void debug() {cout<<endl;}

template<typename T,typename... Args>

void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}

#define forn(i,a,b) for(int i=a;i<b;++i)

#define SZ(x) int(x.size())

#define pb push_back

#define F first

#define S second

#define endl "\n"

typedef long long ll;

typedef pair<int, int> pii;



int main() {

    ios::sync_with_stdio(0); cin.tie(0);

    int n;

    cin >> n;

    int v[n];

    forn(i, 0, n) {

        cin >> v[i];

    }

    int ans = 0;

    forn(i, 1, n-1) {

        int aux[3] = {v[i-1], v[i], v[i+1]};

        sort(aux, aux+3);

        if (v[i] == aux[1]) ans++;

    }

    cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.292099823546095x):
#include<stdio.h>

int main()

{

    int n;scanf("%d",&n);

    int a[n+10],i,j,count=0;

    for(i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    for(i=1;i<n-1;i++)

    {

       if(a[i]>a[i-1])

       {

           if(a[i]<a[i+1])count++;

       }

       else if(a[i]<a[i-1])

       {

           if(a[i]>a[i+1])count++;

       }

    }

    printf("%d",count);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main() {

	int N;

	cin>>N;

	int p[N+2];

	for(int i=1;i<=N;i++) {

		cin>>p[i];

	}

	int cnt = 0, minVal,maxVal;

	for(int i=2;i<N;i++) {

		minVal = min(min(p[i-1], p[i]), p[i+1]);

		maxVal = max(max(p[i-1], p[i]), p[i+1]);

		if(p[i] > minVal and p[i]< maxVal) cnt++;

	}

	printf("%d\n",cnt);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.173301936875961x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;

#include <algorithm>

int main()

{



    vector<long int> a;

    int n;

    cin >> n;

    for (int i = 0, f; i < n; i++)

    {

        cin >> f;

        a.push_back(f);



    }

    int o = 0;

    for (int i = 1; i < n - 1; i++)

    {

        if(a[i] > a[i - 1] && a[i] < a[i + 1])

            o++;

        else if (a[i] > a[i + 1] && a[i] < a[i - 1])

            o++;

    }

    cout << o;





}

// Faster C++ solution for the same problem (measured speedup: 5.283942023551118x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}
// Slower C++ solution:


#include <iostream>

#include <bits/stdc++.h>

#include <stdio.h>



using namespace std;



#define loop(i, a, b) for (int i = int(a); i <= int(b) - 1; i++)

#define rloop(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)

#define scfi1(v) scanf("%d", &v)

#define scfi2(v1, v2) scanf("%d %d", &v1, &v2)

#define scfll1(v) scanf("%I64d", &v);

#define scfll2(v1, v2) scanf("%I64d %I64d", &v1, &v2)

#define sz(v) int(v.size())

#define ALL(c) c.begin(), c.end()

#define pb push_back

#define mp make_pair

#define test(x) cout << #x << " => { " << (x) << " }\n";



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<vi> vvi;

typedef vector<bool> vb;

typedef vector<pii> vp;



int n,x,cnt=0;

vi a;

int main()

{

    scfi1(n);

    loop(i ,0 , n){

        scfi1(x);

        a.pb(x);

    }

    for(int i=1;i<n-1;i++)

    {

        if((a[i]<=a[i+1] && a[i]>=a[i-1])|| (a[i]>=a[i+1] && a[i]<=a[i-1]))

            cnt++;

    }

    cout<<cnt;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.237225560021011x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define INF 1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define arr array

#define _min(a) *min_element(a.begin(), a.end());

#define _max(a) *max_element(a.begin(), a.end());

#define _sort(x) sort(x.begin(), x.end())

#define _rsort(x) sort(x.rbegin(), x.rend())

#define _reverse(x) reverse(x.begin(), x.end())

#define _debug(x) cout << #x << " = " << x << endl;

#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;

#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()

#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()

typedef long long ll;

using namespace std;



void solve() {	 

	int n, cnt = 0; cin >> n;

	vector<int> a(n); for (auto &u : a) cin >> u;

	for (int i = 1; i < n - 1; ++i) {

		if (a[i] > a[i - 1] && a[i] < a[i + 1] || a[i] < a[i - 1] && a[i] > a[i + 1]) {

			++cnt;

		}

	}

	cout << cnt << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(nullptr);



    // int t; cin >> t;

    // while(t--) 

        solve();

}

// Faster C++ solution for the same problem (measured speedup: 5.343176144289177x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

int main()

{

	int n;

	std::cin>>n;

	int arr[n];

	for(int i=0;i<n;i++)

	std::cin>>arr[i];

	int j=0;

	for(int i=1;i<n-1;i++)

	{

		if(arr[i]<arr[i-1] and arr[i]>arr[i+1])

		j++;

		else if(arr[i]>arr[i-1] and arr[i]<arr[i+1])

		j++;

	}

	std::cout<<j<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 5.237847875360174x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main()  {

    int n;

    cin>>n;

    int a[n];

    

    for(int i=0; i<n;i++){

        cin>>a[i];

        }

    int c=0;

    for(int i=1; i<n-1;i++){

        if((a[i]<a[i-1]&&a[i]>a[i+1])||(a[i]>a[i-1] && a[i]<a[i+1]))

            c++;

        }

        cout<<c;

}

// Faster C++ solution for the same problem (measured speedup: 5.227909816979775x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;



using std::vector;



int main()

{

    int n;

    cin >> n;



    vector<int> numbers(n);



    for (int i = 0; i < n; i++)

    {

        cin >> numbers[i];

    }



    int count = 0;

    for (int i = 0; i < n-2; i++)

    {

        if((numbers[i] < numbers[i+1] && numbers[i+1] < numbers[i+2]) || (numbers[i] > numbers[i+1] && numbers[i+1] > numbers[i+2]))

        {

            count++;

        }

    }



    cout << count << endl;





    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.244832397951686x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

void debug() {cout<<endl;}

template<typename T,typename... Args>

void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}

#define forn(i,a,b) for(int i=a;i<b;++i)

#define SZ(x) int(x.size())

#define pb push_back

#define F first

#define S second

#define endl "\n"

typedef long long ll;

typedef pair<int, int> pii;



int main() {

    ios::sync_with_stdio(0); cin.tie(0);

    int n;

    cin >> n;

    int v[n];

    forn(i, 0, n) {

        cin >> v[i];

    }

    int ans = 0;

    forn(i, 1, n-1) {

        int aux[3] = {v[i-1], v[i], v[i+1]};

        sort(aux, aux+3);

        if (v[i] == aux[1]) ans++;

    }

    cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.307528816496684x):
#include<stdio.h>

int main()

{

    int num,i,j,k,big=-1,avg,max,total=0,count[50];

    scanf("%d",&max);

    for(i=0;i<max;i++)

    {

        scanf("%d",&count[i]);

    }

    for(i=1;i<max-1;i++)

    {

        if(count[i]>count[i-1] && count[i]<count[i+1])

        {

            total++;

        }

        else if(count[i]<count[i-1] && count[i]>count[i+1])

        {

            total++;

        }

    }

    printf("%d",total);

    return 0;

}