stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:


#include<bits/stdc++.h>

#include<iostream>

using namespace std;

int a[25],b[5];

int main()

{

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

	memset(a,0,sizeof(a));

	int n,sum=0;

	cin>>n;

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

	{

		cin>>a[i];

	}

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

	{

		b[0]=a[i-1];b[1]=a[i];b[2]=a[i+1];

		sort(b,b+3);

		if(b[1]==a[i])sum++; 	

	}

	cout<<sum;

	

	

	}

	

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

int main()

{

    int k;

    scanf("%d",&k);

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

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

    {

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

    }

    for(i=1;i<k-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);

    return 0;

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

using namespace std;

#define INS(x) x.begin(),x.end()

int a[25];

int main()

{

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

    int n;

    cin>>n;

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

        cin>>a[i];

    vector<int> b;

    int ans=0;

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

    {

        b.clear();

        for (int j=0;j<3;j++)

            b.push_back(a[i+j]);

        sort(INS(b));

        if (a[i]!=a[i+1]&&a[i+1]!=a[i+2]&&a[i+1]==b[1]) ans++;

    }

    cout<<ans<<'\n'; 

    return 0;

}

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

int main()

{

    int k;

    scanf("%d",&k);

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

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

    {

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

    }

    for(i=1;i<k-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);

    return 0;

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

#include<cstring>

#include<cstdio>

#include<cstdlib>

#include<map>

#include<ctime>

#include<algorithm>

#include<cmath>

#include<queue>

#include<set>

#include<stack>

#include<vector>

#include<bitset>

#include<string>

#define ll long long 

#define ull unsigned long long 

#define mem(a) memset(a,0,sizeof(a))

#define rint register int 

#define rll register long long 

#define rull register unsigned long long 

#define rchar register char

#define rstring register string 

#define rfloat register float

#define rdouble register double 

#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

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

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

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

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

#define lFor(i,a,b) for(ll i=a;i<b;i++)

#define lFOR(i,a,b) for(ll i=a;i<=b;i++)

#define lcFor(i,a,b) for(ll i=a;i>b;i--)

#define lcFOR(i,a,b) for(ll i=a;i>=b;i--)

using namespace std;

int main()

{

   int a[25],b[3];

   int n,ans=0;

   cin>>n;

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

 {

  cin>>a[i];

 }

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

 {

 b[0]=a[i-1];

 b[1]=a[i];

 b[2]=a[i+1];

  sort(b,b+3);

  if(b[1]==a[i])

  {

  	ans++; 

  }

     

 }

 cout<<ans;

 

 }

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

int main()

{

    int k;

    scanf("%d",&k);

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

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

    {

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

    }

    for(i=1;i<k-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);

    return 0;

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



using namespace std;





int main()

{

  int t;cin>>t;

  int arra[t];

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

  {

      cin>>arra[i];

  }

  int cnt=0;

  for(int j=1;j<t-1;j++)

  {

     if((arra[j-1]<arra[j] && arra[j]<arra[j+1])||(arra[j-1]>arra[j] && arra[j]>arra[j+1])) cnt++;

  }

    cout<<cnt<<endl;

}

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

int main()

{

    int k;

    scanf("%d",&k);

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

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

    {

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

    }

    for(i=1;i<k-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);

    return 0;

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

using namespace std;

int main(){

    int  n;

    cin>>n;

    int a[n];

    int counter=0;

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

    cin>>a[i];

}

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

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

        counter=counter+1;

    }

}

cout<<counter<<endl;

}


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

int main()

{

    int k;

    scanf("%d",&k);

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

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

    {

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

    }

    for(i=1;i<k-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);

    return 0;

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

#define fast_io ios::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int main(){

	fast_io;

	int n,s=0;

	cin>>n;

	int p[n];

	for(int i=0;i<n;i++) cin>>p[i];

	for(int i=1;i<n-1;i++) if(p[i-1]>p[i]&&p[i+1]<p[i]||p[i-1]<p[i]&&p[i+1]>p[i]) s++;

	cout<<s;

	return 0;

}

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

int main()

{

    int k;

    scanf("%d",&k);

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

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

    {

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

    }

    for(i=1;i<k-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);

    return 0;

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

using namespace std;

vector <int> numbers;

bool condition(int i){

	int max=numbers[i-1], min=max;

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

		if(numbers[j]>max) max = numbers[j];

		if(numbers[j]<min) min = numbers[j];

	}

	if (numbers[i] == min || numbers[i] == max) return false;

	return true; 

}



int main(){

	int n, x, cont=0;

	cin >> n;

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

		cin >>x;

		numbers.push_back(x);

	}

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

		if (condition(i)) cont++;

	}

	cout << cont;

	return 0;

}

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

int main()

{

    int k;

    scanf("%d",&k);

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

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

    {

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

    }

    for(i=1;i<k-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);

    return 0;

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

#include <vector>

#include <algorithm>



using namespace std;



int main()

{

	vector<int> v;

	int num,tmp,min = 0;

	cin >> num;

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

	{

		cin >> tmp;

		v.push_back(tmp);

	}

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

	{

		vector<int> v2 = { v[i - 1],v[i],v[i + 1] };

		sort(v2.begin(), v2.end());

		if (v2[1] == v[i])

			min++;

	}

	cout << min;

	system("pause");

	return 0;

}

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

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{     int n,i,j,s;

    while(~scanf("%d",&n)) 

  {  s=0;

  int a[n];

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

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

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

  	{

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

  	{

	  s++;

	  continue;}

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

  	s++;}

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

  	

  }

      

  

  

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

#include <string>

#include <algorithm>

using namespace std;



int main() {

    int len=0;

    cin >> len;

    int *var = new int[len];

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

        cin >> var[i];

    }

    int flag=0;//符合条件的数量

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

        int tmp[3];

        tmp[0] = var[i-1];

        tmp[1] = var[i];

        tmp[2] = var[i+1];

        sort(tmp,tmp+3);

        if(tmp[1] == var[i]){

            flag++;

        }

    }

    cout<<flag;

    return 0;

}

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

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{     int n,i,j,s;

    while(~scanf("%d",&n)) 

  {  s=0;

  int a[n];

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

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

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

  	{

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

  	{

	  s++;

	  continue;}

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

  	s++;}

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

  	

  }

      

  

  

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

#include <vector>

#include <algorithm>



using namespace std;



int main()

{

	vector<int> v;

	int num,tmp,min = 0;

	cin >> num;

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

	{

		cin >> tmp;

		v.push_back(tmp);

	}

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

	{

		vector<int> v2 = { v[i - 1],v[i],v[i + 1] };

		sort(v2.begin(), v2.end());

		if (v2[1] == v[i])

			min++;

	}

	cout << min;

	system("pause");

	return 0;

}

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

#include<string.h>

#include<math.h>

int main()

{

	int a, b, c, d, e, f, g, h, i, p;

	scanf("%d",&a);

	int z[30];

	b = 0;

	for (i = 0; i < a; i++)scanf("%d", &z[i]);

	for (i = 0; i < a - 2; i++)

	{

		if (z[i + 1] > z[i] && z[i + 1] < z[i + 2] || z[i + 1]<z[i] && z[i + 1]>z[i + 2])b++;

	}

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





	return 0;

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

#include <string>

#include <algorithm>

using namespace std;



int main() {

    int len=0;

    cin >> len;

    int *var = new int[len];

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

        cin >> var[i];

    }

    int flag=0;//符合条件的数量

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

        int tmp[3];

        tmp[0] = var[i-1];

        tmp[1] = var[i];

        tmp[2] = var[i+1];

        sort(tmp,tmp+3);

        if(tmp[1] == var[i]){

            flag++;

        }

    }

    cout<<flag;

    return 0;

}

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

#include<string.h>

#include<math.h>

int main()

{

	int a, b, c, d, e, f, g, h, i, p;

	scanf("%d",&a);

	int z[30];

	b = 0;

	for (i = 0; i < a; i++)scanf("%d", &z[i]);

	for (i = 0; i < a - 2; i++)

	{

		if (z[i + 1] > z[i] && z[i + 1] < z[i + 2] || z[i + 1]<z[i] && z[i + 1]>z[i + 2])b++;

	}

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





	return 0;

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

using namespace std;

const int maxn=1e5+10;

const int mod=1e6+3;

typedef long long ll;

#define inf 0x3f3f3f3f

#define mem(a,b) memset(a,b,sizeof(a))

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

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

#define pi acos(-1.0)

#define mid ((l+r)>>1)

#define lson rt<<1,l,mid

#define rson rt<<1|1,mid+1,r

void read(int &x)

{

	int f=1;x=0;

	char ch=getchar();

	while(ch<'0'||ch>'9')

	{

		if(ch=='-')f=-1;

		ch=getchar();

	}

	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();

	x*=f;

}

int a[maxn];

int main()

{

	int n;

	read(n);

	per(i,0,n)read(a[i]);

	int ans=0;

	rep(i,1,n-2)

	{

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

		ans++;

	}

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

}

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

#include<string.h>

#include<math.h>

int main()

{

	int a, b, c, d, e, f, g, h, i, p;

	scanf("%d",&a);

	int z[30];

	b = 0;

	for (i = 0; i < a; i++)scanf("%d", &z[i]);

	for (i = 0; i < a - 2; i++)

	{

		if (z[i + 1] > z[i] && z[i + 1] < z[i + 2] || z[i + 1]<z[i] && z[i + 1]>z[i + 2])b++;

	}

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





	return 0;

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

#include <vector>

#include <algorithm>



using namespace std;



int main()

{

	vector<int> v;

	int num,tmp,min = 0;

	cin >> num;

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

	{

		cin >> tmp;

		v.push_back(tmp);

	}

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

	{

		vector<int> v2 = { v[i - 1],v[i],v[i + 1] };

		sort(v2.begin(), v2.end());

		if (v2[1] == v[i])

			min++;

	}

	cout << min;

	system("pause");

	return 0;

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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

#include <string>

#include <algorithm>

using namespace std;



int main() {

    int len=0;

    cin >> len;

    int *var = new int[len];

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

        cin >> var[i];

    }

    int flag=0;//符合条件的数量

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

        int tmp[3];

        tmp[0] = var[i-1];

        tmp[1] = var[i];

        tmp[2] = var[i+1];

        sort(tmp,tmp+3);

        if(tmp[1] == var[i]){

            flag++;

        }

    }

    cout<<flag;

    return 0;

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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

using namespace std;

const int maxn=1e5+10;

const int mod=1e6+3;

typedef long long ll;

#define inf 0x3f3f3f3f

#define mem(a,b) memset(a,b,sizeof(a))

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

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

#define pi acos(-1.0)

#define mid ((l+r)>>1)

#define lson rt<<1,l,mid

#define rson rt<<1|1,mid+1,r

void read(int &x)

{

	int f=1;x=0;

	char ch=getchar();

	while(ch<'0'||ch>'9')

	{

		if(ch=='-')f=-1;

		ch=getchar();

	}

	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();

	x*=f;

}

int a[maxn];

int main()

{

	int n;

	read(n);

	per(i,0,n)read(a[i]);

	int ans=0;

	rep(i,1,n-2)

	{

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

		ans++;

	}

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

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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

using namespace std;



int main() {

  int n;

  cin >> n;

  int arr[n];

  for (int i = 0; i < n; ++i) cin >> arr[i];

  int cont = 0;

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

    if (arr[i] > min(arr[i-1], arr[i+1]) && arr[i] < max(arr[i-1], arr[i+1]) ) cont++;

  }

  cout << cont;

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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

using namespace std;

int a[100];

int main()

{

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

	int n, p;

	while (cin >> n)

	{

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

			cin >> a[i];

		int count = 0;

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

		{

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

				count++;

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

				count++;

		}

		cout << count << '\n';



	}



	return 0;

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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

#include<cstring>

#include<algorithm>

using namespace std;

int main()

{

	int n,sum=0;

	cin >> n;

	long long a[21];

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

		cin >> a[i];

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

	{

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

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

	}

	cout << sum << endl;

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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



using namespace std;



int main()

{

    int n;

    cin >> n;

    int p[20];

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

        cin >> p[i];

    }

    int num = 0;

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

        if(p[i-1] > p[i]) {

            if(p[i+1] < p[i]) {

                num++;

            }

        }

        else if (p[i-1] < p[i]) {

            if(p[i+1] > p[i]) {

                num++;

            }

        }

    }

    cout << num;

}


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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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



using namespace std;



int main()

{

    int n;

    cin>>n;

    int a[n];

    int cnt=0;

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

    {

        cin>>a[i];

    }



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

    {

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

        {

            cnt++;

        }

    }



    cout<<cnt;

}


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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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



using namespace std;



int main()

{ int n,c=0;

  cin>>n;

  int arr[n];

   for(int i=0 ;i<n ;i++) cin>>arr[i];

    for(int i=1;i<n-1;i++) if(((arr[i]>arr[i-1])&&(arr[i]<arr[i+1]))||((arr[i]<arr[i-1])&&(arr[i]>arr[i+1]))) c++;

    cout<<c;

    return 0;

}


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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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



using namespace std;



int n, a[22], c;



int main()

{

    cin >> n;

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

        cin >> a[i];

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

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

            c++;

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

            c++;

    }

    cout << c;

    return 0;

}




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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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

using namespace std;



int main()

{

	int n;

	cin >> n;

	int x;

	vector<int> v;

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

	{

		cin >> x;

		v.push_back(x);

	}

	int count = 0;

	int now, prev, next;

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

	{

		now = v[i];

		next = v[i + 1];

		prev = v[i - 1];



		if ((now > next && now < prev) || (now > prev && now < next))

			count++;

	}

	cout << count << endl;

}




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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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



using namespace std;



int main(){

    int n; cin >> n;

    int ar[n];

    int count = 0;

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

        cin >> ar[i];

    }

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

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

            continue;

        }else count++;

    }

    cout << count;

    return 0;

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

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

using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define endl "\n"

#define fore(i,x,n) for(int i=x;i<n;i++)

#define all(a) a.begin(),a.end()

#define pb push_back

#define ordenar(a) sort(all(a))

typedef long long ll;

typedef vector<int> vi;



int n;



int main(){



    cin>>n;



    vi a(n);



    fore(i,0,n) cin>>a[i];



    int cont=0;



    fore(i,1,n-1){

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

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

    }



    cout<<cont;



    return 0;

}

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

int main()

{

  int r,count=0;

  scanf("%d",&r);

  int ar[r];

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

  {

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

  }

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

  {

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

  {

    count++;

  }

  

  }

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

  return 0;

  }