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

using namespace std;

int main() {

	int n, m;

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

	int tmp = 1e9 + 7, ans = 0, am = 0;

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

		int a;

		scanf("%d", &a);

		tmp = min(a, tmp);

		if (tmp < a) {

			if (a - tmp > am) {

				ans = 1;

				am = a - tmp;

			}

			else if (a - tmp == am) {

				ans ++;

			}

		}

	}

	assert(ans);

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

}




// Faster C++ solution for the same problem (measured speedup: 5.171847867147304x):
#include <cstdio>

#include <algorithm>

#include <cstring>



typedef long long ll;



int n, t, a[100005];



int main() {

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

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

		scanf("%d", a + i);

	

	int mxex = 0, mn = a[1], mx;

	int ans1 = 0, ans2 = 0;

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

		mxex = std::max(mxex, a[i] - mn);

		mn = std::min(mn, a[i]);

	}

	if (mxex == 0) return puts("0"), 0;

	mn = a[1];

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

		if (a[i] - mn == mxex) ++ans1;

		mn = std::min(mn, a[i]);

	}

	mx = a[n];

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

		if (mx - a[i] == mxex) ++ans2;

		mx = std::max(mx, a[i]);

	}

	printf("%d\n", std::min(ans1, ans2));

	

	return 0;

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

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

#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)

#define re(i,a,n) for(int _tmp=n,i=a;i<_tmp;++i)

#define fec(i,a) for(__typeof a.begin() i=a.begin();i!=a.end();++i)

#define For(i,v,u) for(int i=H[u],v=to[i];i;i=nxt[i],v=to[i])

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

#define pb push_back

#define mp make_pair

#define mt make_tuple

#define X first

#define Y second

#define inf 1000000000

using namespace std;

template<class T> inline void read(T&x){char c;bool fu=0;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x*=-1;}

template<class T> inline void read(T&x,T&y){read(x);read(y);}

template<class T> inline void read(T&x,T&y,T&z) {read(x,y);read(z);}

template<class T> inline void MAX(T&x,T y){if(x<y)x=y;}

template<class T> inline void MIN(T&x,T y){if(x>y)x=y;}

typedef long long ll;

typedef pair<int,int> pii;

typedef tuple<int,int,int> tiii;

const int N=111111;

//head

int n,T,a[N],now,mx,cnt;

int main() {

	read(n,T);

	rep(i,1,n)read(a[i]);

	now=a[1];

	rep(i,2,n)if(now<a[i]){

		if(a[i]-now>mx){

			mx=a[i]-now;

			cnt=1;

		}else if(a[i]-now==mx)++cnt;

	}else now=a[i];

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

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.160850505577014x):
#include <cstdio>

#include <algorithm>

#include <cstring>



typedef long long ll;



int n, t, a[100005];



int main() {

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

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

		scanf("%d", a + i);

	

	int mxex = 0, mn = a[1], mx;

	int ans1 = 0, ans2 = 0;

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

		mxex = std::max(mxex, a[i] - mn);

		mn = std::min(mn, a[i]);

	}

	if (mxex == 0) return puts("0"), 0;

	mn = a[1];

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

		if (a[i] - mn == mxex) ++ans1;

		mn = std::min(mn, a[i]);

	}

	mx = a[n];

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

		if (mx - a[i] == mxex) ++ans2;

		mx = std::max(mx, a[i]);

	}

	printf("%d\n", std::min(ans1, ans2));

	

	return 0;

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

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <iostream>

#include <algorithm>

#include <set>

using namespace std;

inline int read()

{

	int res, ok = 1;

	char ch;

	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())

	if (ch == '-')

	ok = -1;

	res = ch - '0';

	for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())

	res = res * 10 + ch - '0';

	return res * ok;

}

int n, T, a[100005], cnt, num;

set <int> s;

set <int> :: iterator it;

int main()

{

	n = read();

	T = read();

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

	a[i] = read();

	s.insert (a[1]);

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

	{

		it = s.begin();

		int now = *it;

		if (a[i] - now > num)

		{

			num = a[i] - now;

			cnt = 0;

		}

		if (a[i] - now == num)

		cnt++;

		s.insert (a[i]);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.209788837773177x):
#include <cstdio>

#include <algorithm>

#include <cstring>



typedef long long ll;



int n, t, a[100005];



int main() {

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

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

		scanf("%d", a + i);

	

	int mxex = 0, mn = a[1], mx;

	int ans1 = 0, ans2 = 0;

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

		mxex = std::max(mxex, a[i] - mn);

		mn = std::min(mn, a[i]);

	}

	if (mxex == 0) return puts("0"), 0;

	mn = a[1];

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

		if (a[i] - mn == mxex) ++ans1;

		mn = std::min(mn, a[i]);

	}

	mx = a[n];

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

		if (mx - a[i] == mxex) ++ans2;

		mx = std::max(mx, a[i]);

	}

	printf("%d\n", std::min(ans1, ans2));

	

	return 0;

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

using namespace std;



const int  maxn=200008;

int n,m; 

int a[maxn];

int main(){

  cin>>n>>m;

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

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

  int dis=0;

  int ans=0;

  int mx=a[n];

  for (int i=n-1;i>=1;i--)

    {

     

    

      if ((mx-a[i])>dis)

        {

          dis=mx-a[i];

          ans=1;

          continue;

        } 

      

      if (mx-a[i]== dis) 

        {

          ans++;

          continue;

        }

      

      if (a[i]>mx) mx=a[i];

    }

  cout<<ans<<endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.254688996196093x):
#include <cstdio>

#include <algorithm>

#include <cstring>



typedef long long ll;



int n, t, a[100005];



int main() {

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

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

		scanf("%d", a + i);

	

	int mxex = 0, mn = a[1], mx;

	int ans1 = 0, ans2 = 0;

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

		mxex = std::max(mxex, a[i] - mn);

		mn = std::min(mn, a[i]);

	}

	if (mxex == 0) return puts("0"), 0;

	mn = a[1];

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

		if (a[i] - mn == mxex) ++ans1;

		mn = std::min(mn, a[i]);

	}

	mx = a[n];

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

		if (mx - a[i] == mxex) ++ans2;

		mx = std::max(mx, a[i]);

	}

	printf("%d\n", std::min(ans1, ans2));

	

	return 0;

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

#include <cstring>

#include <algorithm>

#include <cmath>

#include <vector>

#include <set>

using namespace std;

typedef long long LL;

typedef long double DD;

const int inf = 1e9;

const int mo= 1e9+7;

const int N = 200010;

int n,m,a[N];

set<int> s;



int main(){

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

	int mn=inf,d=0;

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

		scanf("%d", a+i);

		d=max(d,a[i]-mn);

		mn=min(a[i],mn);

	}

	int ans=0;

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

		set<int>::iterator it=s.find(a[i]-d);

		if(it != s.end())

			ans++;

		s.insert(a[i]);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.854974216011549x):
#include <cstdio>

#include <algorithm>

#include <cstring>



typedef long long ll;



int n, t, a[100005];



int main() {

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

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

		scanf("%d", a + i);

	

	int mxex = 0, mn = a[1], mx;

	int ans1 = 0, ans2 = 0;

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

		mxex = std::max(mxex, a[i] - mn);

		mn = std::min(mn, a[i]);

	}

	if (mxex == 0) return puts("0"), 0;

	mn = a[1];

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

		if (a[i] - mn == mxex) ++ans1;

		mn = std::min(mn, a[i]);

	}

	mx = a[n];

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

		if (mx - a[i] == mxex) ++ans2;

		mx = std::max(mx, a[i]);

	}

	printf("%d\n", std::min(ans1, ans2));

	

	return 0;

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

using namespace std;

int main() {

	int n, m;

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

	int tmp = 1e9 + 7, ans = 0, am = 0;

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

		int a;

		scanf("%d", &a);

		tmp = min(a, tmp);

		if (tmp < a) {

			if (a - tmp > am) {

				ans = 1;

				am = a - tmp;

			}

			else if (a - tmp == am) {

				ans ++;

			}

		}

	}

	assert(ans);

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

}




// Faster C++ solution for the same problem (measured speedup: 5.1549711186804785x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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

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

#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)

#define re(i,a,n) for(int _tmp=n,i=a;i<_tmp;++i)

#define fec(i,a) for(__typeof a.begin() i=a.begin();i!=a.end();++i)

#define For(i,v,u) for(int i=H[u],v=to[i];i;i=nxt[i],v=to[i])

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

#define pb push_back

#define mp make_pair

#define mt make_tuple

#define X first

#define Y second

#define inf 1000000000

using namespace std;

template<class T> inline void read(T&x){char c;bool fu=0;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x*=-1;}

template<class T> inline void read(T&x,T&y){read(x);read(y);}

template<class T> inline void read(T&x,T&y,T&z) {read(x,y);read(z);}

template<class T> inline void MAX(T&x,T y){if(x<y)x=y;}

template<class T> inline void MIN(T&x,T y){if(x>y)x=y;}

typedef long long ll;

typedef pair<int,int> pii;

typedef tuple<int,int,int> tiii;

const int N=111111;

//head

int n,T,a[N],now,mx,cnt;

int main() {

	read(n,T);

	rep(i,1,n)read(a[i]);

	now=a[1];

	rep(i,2,n)if(now<a[i]){

		if(a[i]-now>mx){

			mx=a[i]-now;

			cnt=1;

		}else if(a[i]-now==mx)++cnt;

	}else now=a[i];

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

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.144009643646256x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <iostream>

#include <algorithm>

#include <set>

using namespace std;

inline int read()

{

	int res, ok = 1;

	char ch;

	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())

	if (ch == '-')

	ok = -1;

	res = ch - '0';

	for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())

	res = res * 10 + ch - '0';

	return res * ok;

}

int n, T, a[100005], cnt, num;

set <int> s;

set <int> :: iterator it;

int main()

{

	n = read();

	T = read();

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

	a[i] = read();

	s.insert (a[1]);

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

	{

		it = s.begin();

		int now = *it;

		if (a[i] - now > num)

		{

			num = a[i] - now;

			cnt = 0;

		}

		if (a[i] - now == num)

		cnt++;

		s.insert (a[i]);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.192788280518025x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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

using namespace std;



const int  maxn=200008;

int n,m; 

int a[maxn];

int main(){

  cin>>n>>m;

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

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

  int dis=0;

  int ans=0;

  int mx=a[n];

  for (int i=n-1;i>=1;i--)

    {

     

    

      if ((mx-a[i])>dis)

        {

          dis=mx-a[i];

          ans=1;

          continue;

        } 

      

      if (mx-a[i]== dis) 

        {

          ans++;

          continue;

        }

      

      if (a[i]>mx) mx=a[i];

    }

  cout<<ans<<endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.237541920965299x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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

#include <cstring>

#include <algorithm>

#include <cmath>

#include <vector>

#include <set>

using namespace std;

typedef long long LL;

typedef long double DD;

const int inf = 1e9;

const int mo= 1e9+7;

const int N = 200010;

int n,m,a[N];

set<int> s;



int main(){

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

	int mn=inf,d=0;

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

		scanf("%d", a+i);

		d=max(d,a[i]-mn);

		mn=min(a[i],mn);

	}

	int ans=0;

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

		set<int>::iterator it=s.find(a[i]-d);

		if(it != s.end())

			ans++;

		s.insert(a[i]);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.839131488081166x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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

#include<cstdio>

#include<cstdlib>

using namespace std;



const int maxn = 100010;

int A[maxn],pre[maxn],N,T,best;



inline int gi()

{

	char ch; int ret = 0,f = 1;

	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');

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

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

	return ret*f;

}



int main()

{

	// freopen("B.in","r",stdin);

	// freopen("B.out","w",stdout);

	N = gi(); T = gi();

	for (int i = 1;i <= N;++i) A[i] = gi();

	pre[0] = 1<<30;

	for (int i = 1;i <= N;++i) pre[i] = min(pre[i-1],A[i]);

	for (int i = 1;i <= N;++i) best = max(best,A[i]-pre[i]);

	int ans = 0;

	for (int i = 1;i <= N;++i) if (A[i]-pre[i] == best) ++ans;

	cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.160614578134258x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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



using namespace std;



int n,a[100010],nowm[100010];



int main()

{

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

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

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

	for(int i=n;i;i--)

	{

		nowm[i]=max(nowm[i+1],a[i]);

	}

	int nowans=0;

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

		if(nowm[i]-a[i]>=nowans)nowans=nowm[i]-a[i];

	int ans=0;

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

		if(nowm[i]-a[i]==nowans)ans++;

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

}

// Faster C++ solution for the same problem (measured speedup: 5.19970870584252x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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

using namespace std;



typedef long long ll;



#define N 100010



int n,Ans,T;

int A[N];

map<int,bool> flag;



inline int read()

{

	int x=0,f=1;char ch=getchar();

	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}

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

	return x*f;

}





int main()

{

	n=read();T=read();

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

	{

		A[i]=read();

	}

	int Min=A[1],Max=0,Ans=0;

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

	{

		int now=A[i]-Min;

		if(now>Max)

			Max=now;

		Min=min(Min,A[i]);

	}

	for(int i=n;i>=1;i--)

	{

		int now=A[i]+Max;

		flag[A[i]]=true;

		if(!flag[now])

			continue;

		Ans++;

	}

	cout<<Ans<<endl;				

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.223965219827851x):
#include<cmath>

#include<cstdio>

using namespace std;

const int maxn=100000+10;

int a[maxn],xds[maxn*4],szx;

int n,t,anss,cnt;

inline int bigger(int f1,int f2){

	if (a[f1]>=a[f2])return f1;

	else return f2;

}

inline int find(int l,int r){

	int ans=0;

	l+=szx-1;

	r+=szx+1;

	while ((l>>1)!=(r>>1)){

		if (!(bool)(l&1)){

			ans=bigger(ans,xds[l+1]);

		}

		if ((bool)(r&1)){

			ans=bigger(ans,xds[r-1]);

		}

		l=l>>1;

		r=r>>1;

	}

	return ans;

}

int main(){

	int b1,b2,b3,b4;

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

	for (b1=1;b1<=n;b1++){

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

	}

	a[0]=-1;

	szx=1;

	anss=0;

	while (szx-2<n)szx=szx*2;

	for (b1=1;b1<=szx;b1++){

		xds[b1]=0;

	}

	for (b1=1;b1<=n;b1++){

		xds[b1+szx]=b1;

	}

	for (b1=szx-1;b1>=1;b1--){

		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);

	}

	for (b1=1;b1<=n-1;b1++){

		b2=find(b1+1,n);

		//printf("%d\n",a[b2]-a[b1]);

		if (anss<a[b2]-a[b1]){

			anss=a[b2]-a[b1];

			cnt=1;

		} else if(anss==a[b2]-a[b1]){

			cnt++;

		}

	}

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

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

using namespace std;

int main() {

	int n, m;

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

	int tmp = 1e9 + 7, ans = 0, am = 0;

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

		int a;

		scanf("%d", &a);

		tmp = min(a, tmp);

		if (tmp < a) {

			if (a - tmp > am) {

				ans = 1;

				am = a - tmp;

			}

			else if (a - tmp == am) {

				ans ++;

			}

		}

	}

	assert(ans);

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

}




// Faster C++ solution for the same problem (measured speedup: 5.159368363242258x):
#include <cstdio>

#include <cstdlib>

#include <algorithm>



const int maxn = 1e5 + 20;



int N, K;

int a[maxn];

long long ans;



int main()

{

	scanf("%d%*d", &N);

	

	for(int i = 1; i <= N; i++) scanf("%d", &a[i]);

	

	for(int i = 2, pmin = a[1]; i <= N; i++)

	{

		K = std::max(a[i] - pmin, K);

		pmin = std::min(pmin, a[i]);	

	}

	

	for(int i = 2, pmin = a[1]; i <= N; i++)

	{

		if(a[i] - pmin >= K)

		{

			ans += a[i] - (pmin + K - 1);

			a[i] = pmin + K - 1;

		}

		

		pmin = std::min(pmin, a[i]);

	}

	

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

	

	return 0;

}