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

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.230231690455114x):
#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>

#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.414823214403289x):
#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<iostream>

#include<algorithm>

using namespace std;



int n, m, a[100005];



int main() {

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

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

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

	int mn = 1e9 + 7;

	int mx = 0, cnt = 0;

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

		if (mn < a[i]) {

			int t = a[i] - mn;

			if (t > mx) {

				mx = t;

				cnt = 1;	

			} else if (t == mx) cnt++;

		}

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

	}

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

	return 0;

}


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

#include <cstring>

#include <algorithm>

#include <iostream>

using namespace std;

const int N = 1e5 + 5;

int ls[N], s[N], pos[N], num[N], n, a[N];

int sum[N * 4];

void add(int now, int l, int r, int pos) {

    sum[now]++;

    if(l == r) return;

    int mid = l + r >> 1;

    if(pos <= mid) add(now * 2, l, mid, pos);

    else add(now * 2 + 1, mid + 1, r, pos);

}

bool ask(int now, int l, int r, int L, int R) {

    if(l > R || L > r) return false;

    if(L <= l && r <= R) return (sum[now] != 0);

    int mid = l + r >> 1;

    return ask(now * 2, l, mid, L, R) | ask(now * 2 + 1, mid + 1, r, L, R);

}

bool ask(int pos) {

   return ask(1, 1, n, 1, pos);

}

void add(int pos) {

   add(1, 1, n, pos);

}

bool find(int x, int right) {

    int l = 1, r = n;

    for(int mid = l + r >> 1; l < r; mid = l + r >> 1) {

        if(ls[mid] < x) l = mid + 1;

        else r = mid;

    }

    while(ls[l] > x && l > 0) l--;

    if(l == 0) return false;

   // printf("ask = %d %d %d %d\n", l, ask(l), x, ls[l]);

    return ask(l);

}

bool check(int x) {

   // printf("test = %d\n", x);

    memset(sum, 0, sizeof(sum));

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

        if(find(a[i] - x, i)) return true;

        add(num[i]);

        //printf("num = %d\n", num[i]);

        //rem[num[a[i]]] ++; 

    }    

    return false;

}

int main()

{

    int minn = 0, maxn = 0, m;

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

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

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

        ls[i] = a[i];

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

    }

    sort(ls + 1, ls + n + 1);

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

        num[i] = lower_bound(ls + 1, ls + n + 1, a[i]) - ls;

        pos[num[i]] = i;

        //cerr << num[i] << " "; 

        //

    }

    //cerr << "\n"; 

    //

    int l = minn, r = maxn;

    for (int mid = (l + r) >> 1; l < r; mid = (l + r) >>  1) {

    //printf("%d %d\n", l, r);

        if(check(mid)) l = mid + 1;

        else r = mid;

    }

    if(!check(l)) l--;

    memset(sum, 0, sizeof(sum));

    //printf("%d\n", l);

    int ans = 0;

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

        if(find(a[i] - l, i)) ans++;

        add(num[i]);

    }

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

    return 0;

}

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

#include <iostream>

#include <cstring>

#include <cstdio>

#include <map>



using namespace std;



const int N = 1e5 + 10;



int n, t, a[N];

map<int, int> b, c;



int main() {



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

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

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

	int mn = a[1], gap = 1;

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

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

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

	}

	mn = a[1];

	int cnt = 1, ans = 0;

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

		if (a[i] - mn == gap) {

			int &B = b[a[i]], &C = c[a[i]];

			ans -= min(B, C);

			B = mn;

			++C;

			ans += min(B, C);

		}

		if (a[i] == mn)

			++cnt;

		if (a[i] < mn) {

			mn = a[i];

			cnt = 1;

		}

	}

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



	return 0;

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

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <iostream>

using namespace std;

const int N = 1e5 + 5;

int ls[N], s[N], pos[N], num[N], n, a[N];

int sum[N * 4];

void add(int now, int l, int r, int pos) {

    sum[now]++;

    if(l == r) return;

    int mid = l + r >> 1;

    if(pos <= mid) add(now * 2, l, mid, pos);

    else add(now * 2 + 1, mid + 1, r, pos);

}

bool ask(int now, int l, int r, int L, int R) {

    if(l > R || L > r) return false;

    if(L <= l && r <= R) return (sum[now] != 0);

    int mid = l + r >> 1;

    return ask(now * 2, l, mid, L, R) | ask(now * 2 + 1, mid + 1, r, L, R);

}

bool ask(int pos) {

   return ask(1, 1, n, 1, pos);

}

void add(int pos) {

   add(1, 1, n, pos);

}

bool find(int x, int right) {

    int l = 1, r = n;

    for(int mid = l + r >> 1; l < r; mid = l + r >> 1) {

        if(ls[mid] < x) l = mid + 1;

        else r = mid;

    }

    while(ls[l] > x && l > 0) l--;

    if(l == 0) return false;

   // printf("ask = %d %d %d %d\n", l, ask(l), x, ls[l]);

    return ask(l);

}

bool check(int x) {

   // printf("test = %d\n", x);

    memset(sum, 0, sizeof(sum));

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

        if(find(a[i] - x, i)) return true;

        add(num[i]);

        //printf("num = %d\n", num[i]);

        //rem[num[a[i]]] ++; 

    }    

    return false;

}

int main()

{

    int minn = 0, maxn = 0, m;

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

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

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

        ls[i] = a[i];

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

    }

    sort(ls + 1, ls + n + 1);

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

        num[i] = lower_bound(ls + 1, ls + n + 1, a[i]) - ls;

        pos[num[i]] = i;

        //cerr << num[i] << " "; 

        //

    }

    //cerr << "\n"; 

    //

    int l = minn, r = maxn;

    for (int mid = (l + r) >> 1; l < r; mid = (l + r) >>  1) {

    //printf("%d %d\n", l, r);

        if(check(mid)) l = mid + 1;

        else r = mid;

    }

    if(!check(l)) l--;

    memset(sum, 0, sizeof(sum));

    //printf("%d\n", l);

    int ans = 0;

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

        if(find(a[i] - l, i)) ans++;

        add(num[i]);

    }

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

    return 0;

}

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

using namespace std;



const int N = 100000 + 10;



int n, T;

int aa[N];



int main() {

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

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

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

	int amin = aa[1];

	int smax = 0;

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

		smax = max( smax, aa[i] - amin );

		amin = min( amin, aa[i] );

	}

	int ans = 0;

	amin = aa[1];

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

		ans += (aa[i] - amin == smax);

		amin = min( amin, aa[i] );

	}

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

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

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <iostream>

using namespace std;

const int N = 1e5 + 5;

int ls[N], s[N], pos[N], num[N], n, a[N];

int sum[N * 4];

void add(int now, int l, int r, int pos) {

    sum[now]++;

    if(l == r) return;

    int mid = l + r >> 1;

    if(pos <= mid) add(now * 2, l, mid, pos);

    else add(now * 2 + 1, mid + 1, r, pos);

}

bool ask(int now, int l, int r, int L, int R) {

    if(l > R || L > r) return false;

    if(L <= l && r <= R) return (sum[now] != 0);

    int mid = l + r >> 1;

    return ask(now * 2, l, mid, L, R) | ask(now * 2 + 1, mid + 1, r, L, R);

}

bool ask(int pos) {

   return ask(1, 1, n, 1, pos);

}

void add(int pos) {

   add(1, 1, n, pos);

}

bool find(int x, int right) {

    int l = 1, r = n;

    for(int mid = l + r >> 1; l < r; mid = l + r >> 1) {

        if(ls[mid] < x) l = mid + 1;

        else r = mid;

    }

    while(ls[l] > x && l > 0) l--;

    if(l == 0) return false;

   // printf("ask = %d %d %d %d\n", l, ask(l), x, ls[l]);

    return ask(l);

}

bool check(int x) {

   // printf("test = %d\n", x);

    memset(sum, 0, sizeof(sum));

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

        if(find(a[i] - x, i)) return true;

        add(num[i]);

        //printf("num = %d\n", num[i]);

        //rem[num[a[i]]] ++; 

    }    

    return false;

}

int main()

{

    int minn = 0, maxn = 0, m;

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

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

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

        ls[i] = a[i];

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

    }

    sort(ls + 1, ls + n + 1);

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

        num[i] = lower_bound(ls + 1, ls + n + 1, a[i]) - ls;

        pos[num[i]] = i;

        //cerr << num[i] << " "; 

        //

    }

    //cerr << "\n"; 

    //

    int l = minn, r = maxn;

    for (int mid = (l + r) >> 1; l < r; mid = (l + r) >>  1) {

    //printf("%d %d\n", l, r);

        if(check(mid)) l = mid + 1;

        else r = mid;

    }

    if(!check(l)) l--;

    memset(sum, 0, sizeof(sum));

    //printf("%d\n", l);

    int ans = 0;

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

        if(find(a[i] - l, i)) ans++;

        add(num[i]);

    }

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

    return 0;

}

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

#include <string>

#include <algorithm>

using namespace std;

int main()

{

    int n,t;

    int money = 0, counts = 0;

    cin >> n >> t;

    int a[100001], b[100001];

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

        cin  >> a[i];

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

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

    int maxium[100001];

    maxium[0] = b[0];

    money = maxium[0];

    counts = 1;

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

    {

        if(maxium[i - 1] > 0)

            maxium[i] = maxium[i - 1] + b[i];

        else

            maxium[i] = b[i];

        if(maxium[i]  > money)

        {

            money = maxium[i];

            counts = 1;

        }

        else if(maxium[i] == money)

            ++counts;

    }

    cout << counts << endl;

    return 0;

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

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <iostream>

using namespace std;

const int N = 1e5 + 5;

int ls[N], s[N], pos[N], num[N], n, a[N];

int sum[N * 4];

void add(int now, int l, int r, int pos) {

    sum[now]++;

    if(l == r) return;

    int mid = l + r >> 1;

    if(pos <= mid) add(now * 2, l, mid, pos);

    else add(now * 2 + 1, mid + 1, r, pos);

}

bool ask(int now, int l, int r, int L, int R) {

    if(l > R || L > r) return false;

    if(L <= l && r <= R) return (sum[now] != 0);

    int mid = l + r >> 1;

    return ask(now * 2, l, mid, L, R) | ask(now * 2 + 1, mid + 1, r, L, R);

}

bool ask(int pos) {

   return ask(1, 1, n, 1, pos);

}

void add(int pos) {

   add(1, 1, n, pos);

}

bool find(int x, int right) {

    int l = 1, r = n;

    for(int mid = l + r >> 1; l < r; mid = l + r >> 1) {

        if(ls[mid] < x) l = mid + 1;

        else r = mid;

    }

    while(ls[l] > x && l > 0) l--;

    if(l == 0) return false;

   // printf("ask = %d %d %d %d\n", l, ask(l), x, ls[l]);

    return ask(l);

}

bool check(int x) {

   // printf("test = %d\n", x);

    memset(sum, 0, sizeof(sum));

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

        if(find(a[i] - x, i)) return true;

        add(num[i]);

        //printf("num = %d\n", num[i]);

        //rem[num[a[i]]] ++; 

    }    

    return false;

}

int main()

{

    int minn = 0, maxn = 0, m;

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

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

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

        ls[i] = a[i];

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

    }

    sort(ls + 1, ls + n + 1);

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

        num[i] = lower_bound(ls + 1, ls + n + 1, a[i]) - ls;

        pos[num[i]] = i;

        //cerr << num[i] << " "; 

        //

    }

    //cerr << "\n"; 

    //

    int l = minn, r = maxn;

    for (int mid = (l + r) >> 1; l < r; mid = (l + r) >>  1) {

    //printf("%d %d\n", l, r);

        if(check(mid)) l = mid + 1;

        else r = mid;

    }

    if(!check(l)) l--;

    memset(sum, 0, sizeof(sum));

    //printf("%d\n", l);

    int ans = 0;

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

        if(find(a[i] - l, i)) ans++;

        add(num[i]);

    }

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

    return 0;

}

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

#include <iostream>

#include <algorithm>

#include <cstring>

#define N 200010

using namespace std;

int a[N], preMin[N];

int main() {

	int n, t, ans = 0, cnt;

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

	preMin[0] = 1000000001;

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

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

		preMin[i] = min(preMin[i - 1], a[i]);

		if (a[i] - preMin[i] > ans) {

			cnt = 1;

			ans = a[i] - preMin[i];

		}

		else if (a[i] - preMin[i] == ans) {

			cnt++;

		}

	}

	

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

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

#define ll long long

using namespace std;

const int N=1e5+5;

map<ll,ll>mp;

ll n,m,x,mi;

int main()

{

	cin>>n>>m;

	cin>>mi;

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

	{

		cin>>x;

		mp[x-mi]++;

		mi=min(mi,x);

	}

	ll pnt;

	for(map<ll,ll>::iterator it=mp.begin();it!=mp.end();it++)pnt=it->second;

	cout<<pnt<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.253086284109537x):
// luogu-judger-enable-o2

#include <cstdio>

int n,t,a;

int main(){

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

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

	scanf("%d",&a);

	int min1=a,ans=0,maxc=0;

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

		scanf("%d",&a);

		if(a-min1==maxc) ans++;

		if(a-min1>maxc) maxc=a-min1,ans=1;

		if(min1>a) min1=a;

	}

	printf("%d",ans);

	return 0;

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

#include<cstring>

#include<cstdio>

#include<algorithm>

using namespace std;

int main()

{

    int n,t;

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

    int x,pre;

    int minn,maxx=-999;

    int cnt=1;

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

    {

        scanf("%d",&x);

        if(i)

        {

            if(x>pre)

                if(x-minn>maxx)

                    maxx=x-minn,cnt=1;

                else if(x-minn==maxx)

                    cnt++;

            if(minn>x)

                minn=x;

        }

        else

            minn=x;

        pre=x;

    }

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

}


// Faster C++ solution for the same problem (measured speedup: 5.1736683967730075x):
// luogu-judger-enable-o2

#include <cstdio>

int n,t,a;

int main(){

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

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

	scanf("%d",&a);

	int min1=a,ans=0,maxc=0;

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

		scanf("%d",&a);

		if(a-min1==maxc) ans++;

		if(a-min1>maxc) maxc=a-min1,ans=1;

		if(min1>a) min1=a;

	}

	printf("%d",ans);

	return 0;

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



using namespace std ;



#define N 100010

#define inf 0x3f3f3f3f

#define ll long long



int n , t ;

int a[ N ] ;



int main() {

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

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

    int ans = 0 , mx = 0 ;

    int tot = 0 ;

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

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

        ans = max( mx - a[ i ] , ans ) ;

    }

    mx = 0 ;

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

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

        if( mx - a[ i ] == ans ) tot ++ ;

    }

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

     return 0;

}

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

#include<cstring>

#include<cstdio>

#define ll long long

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

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

const int Max=100010;

const int Min=-1;

using std::sort;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

inline int read()

{

	int x=0,f=1;

	char ch=getchar();

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

	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}

	return x*f;

}

inline void write(int x)

{

	if(x<0){putchar('-');x=-x;}

	if(x>9)write(x/10);

	putchar(x%10+'0');

}

int n=read(),t=read(),sum,ans,maxn1,maxn2;

int a[Max];

int main()

{

	fr(i,1,n)a[i]=read();

	rf(i,n,1)

	{

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

		sum=max(maxn1-a[i],sum);

	}

	rf(i,n,1)

	{

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

		if(maxn2-a[i]==sum)++ans;

	}

	write(ans);

	return 0;

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

#define LL long long

using namespace std;

const LL MAXN = 1010;

const LL INF = 0x3f3f3f3f;

LL n,m,k,l,an[1001000],bn[1001000],i,x,y,t;

int main()

{

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

    LL mi=INF,ma=0;

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

    {

     scanf("%lld",&an[i]);

     mi=min(an[i],mi);

     bn[i]=an[i]-mi;

     if(bn[i]==ma) x++;

     if(bn[i]>ma) {ma=bn[i];y=i;x=1;}



    }

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

    return 0;

}


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

#include <algorithm>

using namespace std;

const int MAXN=110000;

const int INF=0X3F3F3F3F;

int a[MAXN];

int main()

{

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

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

	int n, t;

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

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

	int mx=0, ans=0;

	for (int i=1, mi=INF; i<=n; i++)

	{

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

		if (a[i]-mi>mx) mx=a[i]-mi, ans=0;

		if (a[i]-mi==mx) ans++;

	}

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

	return 0;

}