stablegradients/pie-gem5-pairs huggingface dataset:
// 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.148397537954586x):
#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;

}
// 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.197217783516448x):
#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;

}
// 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.242009599289547x):
#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;

}
// 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.8432593181174175x):
#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;

}
// 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.165016636626285x):
#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;

}
// 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.204144112036504x):
#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;

}
// 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.2284213170832885x):
#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;

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

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

using namespace std;



typedef long long LL;

const int INF = 1e9 + 10;

int a[1111111];

int n, T;

vector<int> vec1, vec2;



inline int solve(int l, int r, int delta) {

//cout << l << " " << r << endl;

	int s1 = 0, s2 = 0;

	int mina = INF, maxa = -INF;

	for (int i = l; i <= r; ++i) {

		if (a[i] - mina == delta) {

			++s1;

		}

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

	}

	for (int i = r; i >= l; --i) {

		if (maxa - a[i] == delta) {

			++s2;

		}

		maxa = max(maxa, a[i]);

	}

	return min(s1, s2);

}



int main() {

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	

	cin >> n >> T;

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

		cin >> a[i];

	}

	

	int mina = INF, maxa = -INF;

	int delta = 0;

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

		delta = max(delta, a[i] - mina);

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

	}

	mina = INF;

	int ans = 0, last = 0;

	vec1.clear();

	vec1.push_back(0);

	vec2.clear();

	vec2.push_back(0);

	a[0] = -2; a[n + 1] = -1;

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

		if (a[i] - mina == delta) {

			if (a[i] != a[vec1[vec1.size() - 1]]) {

				vec1.push_back(i);

				vec2.push_back(i);

			} else {

				vec2[vec2.size() - 1] = i;

			}

		}

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

	}

	vec1.push_back(n + 1);

	vec2.push_back(n + 1);

	for (int i = 1; i + 1 < vec1.size(); ++i) {

		ans += solve(vec2[i - 1] + 1, vec1[i + 1] - 1, delta);

	}

	

	cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.307270746121286x):
#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;

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



using namespace std;

typedef long long ll;



const int MAXN = 100005;



int n, T;

int a[MAXN];

int mn, mx, cnt;



void input()

{

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

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

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

}



void solve()

{

	mn = a[1];

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

	{

		if(a[i] > mn)

		{

			int tmp = a[i] - mn;

			if(tmp > mx)

			{

				mx = tmp;

				cnt = 1;

			}

			else if(tmp == mx)

			{

				cnt++;

			}

		}

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

	}

	cout << cnt << endl;

}



void output()

{

}



int main()

{

	input();

	solve();

	output();



	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.221224771191615x):
#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;

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

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

#define rep_(a,b,c) for(int a=c-1;a>=b;a--)

using namespace std;



int main()

{

	cin.sync_with_stdio(false);

	cout.sync_with_stdio(false);

	int a[100005],b[100005],c[100005],n,t,p=0,q=0;

	cin >>n>>t;

	rep(i,0,n) cin >> a[i],b[i]=((i)?min(a[i],b[i-1]):a[i]);

	c[n-1]=a[n-1];rep_(i,0,n-1) c[i]=max(a[i],c[i+1]);

	rep_(i,0,n)

	{

		t=a[i]-b[i];

		if (p<t) p=t,q=0;

		if (p==t) q++;

	}

	int P=0,Q=0;

	rep(i,0,n)

	{

		t=c[i]-a[i];

		if (P<t) P=t,Q=0;

		if (P==t) Q++;

	}

	cout << min(q,Q) << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.405498412290362x):
#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;

}
// 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.168268576570513x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;

const int nMax=1e5+10;

int n,t,a[nMax],ans,cnt;

int main()

{

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

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

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

	int Min=a[1];

	ans=0;

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

	{

		if(a[i]-Min>ans)

		{

			ans=a[i]-Min;

			cnt=1;

		}

		else

			if(a[i]-Min==ans)

				cnt++;

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

	}

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

	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.157278825965133x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;

const int nMax=1e5+10;

int n,t,a[nMax],ans,cnt;

int main()

{

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

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

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

	int Min=a[1];

	ans=0;

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

	{

		if(a[i]-Min>ans)

		{

			ans=a[i]-Min;

			cnt=1;

		}

		else

			if(a[i]-Min==ans)

				cnt++;

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

	}

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

	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.2061832893167805x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;

const int nMax=1e5+10;

int n,t,a[nMax],ans,cnt;

int main()

{

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

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

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

	int Min=a[1];

	ans=0;

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

	{

		if(a[i]-Min>ans)

		{

			ans=a[i]-Min;

			cnt=1;

		}

		else

			if(a[i]-Min==ans)

				cnt++;

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

	}

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

	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.251052373601773x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;

const int nMax=1e5+10;

int n,t,a[nMax],ans,cnt;

int main()

{

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

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

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

	int Min=a[1];

	ans=0;

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

	{

		if(a[i]-Min>ans)

		{

			ans=a[i]-Min;

			cnt=1;

		}

		else

			if(a[i]-Min==ans)

				cnt++;

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

	}

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

	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.851614224784368x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;

const int nMax=1e5+10;

int n,t,a[nMax],ans,cnt;

int main()

{

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

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

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

	int Min=a[1];

	ans=0;

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

	{

		if(a[i]-Min>ans)

		{

			ans=a[i]-Min;

			cnt=1;

		}

		else

			if(a[i]-Min==ans)

				cnt++;

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

	}

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

	return 0;

}
// 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.1739265935577325x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;

const int nMax=1e5+10;

int n,t,a[nMax],ans,cnt;

int main()

{

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

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

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

	int Min=a[1];

	ans=0;

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

	{

		if(a[i]-Min>ans)

		{

			ans=a[i]-Min;

			cnt=1;

		}

		else

			if(a[i]-Min==ans)

				cnt++;

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

	}

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

	return 0;

}
// 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.213121566160171x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;

const int nMax=1e5+10;

int n,t,a[nMax],ans,cnt;

int main()

{

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

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

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

	int Min=a[1];

	ans=0;

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

	{

		if(a[i]-Min>ans)

		{

			ans=a[i]-Min;

			cnt=1;

		}

		else

			if(a[i]-Min==ans)

				cnt++;

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

	}

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

	return 0;

}