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

#include<iostream>

#include<algorithm>

#include<string>

#include<queue>

#include<vector>

#include<utility>

#include<math.h>

#include<set>

#include<map>

#include<string.h>

#include<stack>

#define n 200000

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

using namespace std;

typedef pair<int, int> P;

typedef long long lli;

typedef double llf;

struct edge{

	int from, to, weight;

	bool operator < (const edge& thing) const

	{

		return thing.weight < weight;

	}

};

vector<edge> V[n + 50];

bool visit[n + 50];

int arr[n + 50], a, b, c, d, e;

string str1, str2;

void addedge(int a, int b, int c)

{

	edge temp;

	temp.from = a;

	temp.to = b;

	temp.weight = c;

	V[a].push_back(temp);

}





//////////////////////////////////////////





void solve()

{

	cin >> a;

	loop(i, 0, a - 1)

		cin >> arr[i];

	int max = 0;

	loop(i, 1, a - 1)

		if(arr[i] > arr[max]) max = i;

	int ans2 = -1;

	int temp = arr[max] / 2;

	loop(i, 0, a - 1)

	{

		if(i == max) continue;

		else if(ans2 == -1) ans2 = i;

		else

		{

			int t1 = abs(temp - arr[ans2]), t2 = abs(temp - arr[i]);

			if(t2 < t1) ans2 = i;

		}

	}

	cout << arr[max] << ' ' << arr[ans2] << '\n';

}

int main()

{

	int times = 1;

//	cin << times;

	loop(i, 1, times)

	{

		solve();

		printf("\n");

	}

	return 0;

}






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

using namespace std;

int main()

{

	int a; cin >> a;

	int arr[a + 50], n = 0, m = 0, now = 999999999;

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

	{

		cin >> arr[i];

		n = max(n, arr[i]);

	}

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

	{

		if(arr[i] == n) continue;

		int tmp = abs(arr[i] - n / 2);

		if(m % 2) tmp = min(abs(arr[i] - n / 2), abs(arr[i] - (n + 1) / 2));

		if(tmp < now)

		{

			now = tmp;

			m = arr[i];

		}

	}

	cout << n << ' ' << m << '\n';

	return 0;

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

#include <cstdio>

#include <algorithm>

using namespace std;

int n, a[100005];

double m;

int main() {

	int i, k;

	scanf("%d", &n);

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

	sort(a, a+n);

	m = a[n-1] / 2.0;

	k = lower_bound(a, a+n, m) - a;

	if(m-a[k-1]<=a[k]-m) printf("%d %d", a[n-1], a[k-1]);

	else printf("%d %d", a[n-1], a[k]);

	return 0;

}

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

#include <algorithm>

using namespace std;

int n, a[100005];

int main() {

	int i;

	scanf("%d", &n);

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

	sort(a, a+n);

	for(i=0; 2*a[i]<a[n-1]; i++);

	printf("%d %d", a[n-1], a[n-1]-2*a[i-1] <= 2*a[i]-a[n-1] ? a[i-1] : a[i]);

	return 0;

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

#include <algorithm>

#include <string>

#include <vector>

#include <map>

using namespace std;

typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)

#define repe(i,s,n)for(ll i=s;i<=n;i++)



int main() {

	ll n; cin >> n;

	ll a[100000] = {};

	ll maxV = 0;

	rep(i, 0, n) {

		cin >> a[i];

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

	}



	ll index = 0;

	ll minV = 1e20;

	rep(i, 0, n) {

		if (a[i] != maxV) {

			if (minV > abs(maxV - 2 * a[i])) {

				minV = abs(maxV - 2 * a[i]);

				index = i;

			}

		}

	}

	cout << maxV << " " << a[index] << endl;



	return 0;

}

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

#include <string>

#include <algorithm>

#include <vector>

#include <map>

using namespace std;

typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)

#define repe(i,s,n)for(ll i=s;i<=n;i++)



ll a[100001];

int main()

{

	ll n; cin >> n;

	ll maxA = 0;

	rep(i, 0, n) {

		cin >> a[i];

		if (maxA <= a[i]) {

			maxA = a[i];

		}

	}



	ll minV = 1e20;

	ll minIndex = 0;

	rep(i, 0, n) {

		if (a[i] != maxA) {

			if (minV >= abs(2 * a[i] - maxA)) {

				minV = abs(2 * a[i] - maxA);

				minIndex = i;

			}

		}

	}

	cout << maxA << " " << a[minIndex] << endl;



	return 0;

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

#include <algorithm>

#include <vector>



using namespace std;



typedef long long lint;



int main()

{

	int n;

	static int a[100000];

	static int s[200000], t[200000], next[2][200000];

	static pair<int, int> p[400000];

	static vector<int> bucket[300000];

	

	lint sum = 0;

	

	scanf("%d", &n);

	

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

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

		sum += a[i];

	}

	

	lint left = 0, right = sum / 3;

	

	while (left != right){

		lint mid = (left + right + 1) >> 1;

		lint sum2 = 0;

		int head = 0, tail = 0;

		bool ng = false;

		

		for (; head < n; head++){

			while (sum2 < mid){

				sum2 += a[tail++];

				if (tail >= n) tail -= n;

			}

			int i = head;

			s[i] = head, t[i] = tail;

			if (s[i] == t[i]) ng = true;

			if (t[i] < s[i]) t[i] += n;

			s[n + i] = s[i] + n, t[n + i] = t[i] + n;

			sum2 -= a[head];

		}

		if (ng){

			right = mid - 1;

			continue;

		}

		for (int i = 0; i < n * 3; i++) bucket[i].clear();

		

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

			bucket[t[i]].push_back(i);

			bucket[s[i]].push_back(n * 2 + i);

		}

		int ctr = 0;

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

			for (int j = 0; j < bucket[i].size(); j++){

				p[ctr++] = make_pair(i, bucket[i][j]);

			}

		}

		

		int last = -1;

		for (int i = n * 4 - 1; i >= 0; i--){

			int id = p[i].second;

			if (id < n * 2) next[0][id] = last;

			else {

				id -= n * 2;

				if (last < 0 || t[last] > t[id]) last = id;

			}

		}

		

		for (int k = 0; k + 1 < 2; k++){

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

				if (next[k][i] < 0) next[k + 1][i] = -1;

				else next[k + 1][i] = next[k][next[k][i]];

			}

		}

		

		int res = 0;

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

			int tmp = 0, j = i;

			for (int k = 1; k >= 0; k--){

				int j2 = next[k][j];

				if (j2 >= 0 && t[j2] <= s[i] + n){

					j = j2;

					tmp |= 1 << k;

				}

			}

			if (res >= 3) break;

			res = max(res, tmp + 1);

		}

		if (res >= 3) left = mid;

		else right = mid - 1;

	}

	

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

	

	return (0);

}

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

#include <algorithm>

#include <vector>



using namespace std;



typedef long long lint;



int main()

{

	int n;

	int a[100000];

	int t[300000];

	

	lint sum = 0;

	

	scanf("%d", &n);

	

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

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

		sum += a[i];

	}

	

	lint left = 0, right = sum / 3;

	

	while (left != right){

		lint mid = (left + right + 1) >> 1;

		lint sum2 = 0;

		

		int head = 0, tail = 0;

		for (; head < n; head++){

			while (sum2 < mid){

				sum2 += a[tail % n];

				tail++;

			}

			t[head] = tail - 1;

			t[head + n] = tail - 1 + n;

			t[head + n + n] = tail - 1 + n + n;

			sum2 -= a[head];

		}

		

		bool ok = false;

		for (head = 0; head < n; head++){

			if (t[t[t[head] + 1] + 1] - head + 1 <= n){

				ok = true;

				break;

			}

		}

		

		if (ok) left = mid;

		else right = mid - 1;

	}

	

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

	

	return (0);

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

#include<algorithm>

#include<string>

#include<cmath>



using namespace std;



int main(){

    int n, t, maxn = 0;

    cin >> n >> t;

    int a[n], b[n];

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

        cin >> a[i];

    }

    b[n-1] = a[n-1];

    for(int i = n-2; i >= 0; i--){

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

    }

    int cnt = 0;

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

        if(maxn < b[i]-a[i]){

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

            cnt = 1;

        }else if(maxn == b[i] - a[i]){

            cnt ++;

        }

    }

    cout << cnt << endl;

    return 0;

}


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



vector < int > v;



int main(){

    int a_i, b_i, n, temp, t, mini, maxiD, cont = 0;



    cin>>n>>t;



    v.resize( n );



    for( a_i=0; a_i<n; a_i++ ) cin>>v[a_i];



    mini = v[0]; maxiD = 0;



    for( a_i=0; a_i<n; a_i++ ){

        mini = min( v[a_i], mini );

        maxiD = max( maxiD, v[a_i]-mini );

    }



    mini = v[0];

    for( a_i=0; a_i<n; a_i++ ){

        mini = min( v[a_i], mini );

        if( v[a_i]-mini == maxiD ) cont++;

    }



        cout<<cont<<endl;



}


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

#include<string>

#include<cmath>



using namespace std;



int main(){

    int n, t, maxn = 0;

    cin >> n >> t;

    int a[n], b[n];

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

        cin >> a[i];

    }

    b[n-1] = a[n-1];

    for(int i = n-2; i >= 0; i--){

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

    }

    int cnt = 0;

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

        if(maxn < b[i]-a[i]){

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

            cnt = 1;

        }else if(maxn == b[i] - a[i]){

            cnt ++;

        }

    }

    cout << cnt << endl;

    return 0;

}


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

#include<stdlib.h>

#include<string.h>

int v[100005];

int t[100005];

int main(void)

{

	int N, T;

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

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

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

	int max = v[N];

	int MAX = 0;

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

	{

		t[i] = max - v[i];

		if (t[i] > MAX)MAX = t[i];

		if (v[i] > max)max = v[i];

	}

	int ans = 0;

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

		if (t[i] == MAX)

			ans++;

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

	return 0;

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

using namespace std;



vector < int > v;



int main(){

    int a_i, b_i, n, temp, t, mini, maxiD, cont = 0;



    cin>>n>>t;



    v.resize( n );



    for( a_i=0; a_i<n; a_i++ ) cin>>v[a_i];



    mini = v[0]; maxiD = 0;



    for( a_i=0; a_i<n; a_i++ ){

        mini = min( v[a_i], mini );

        maxiD = max( maxiD, v[a_i]-mini );

    }



    mini = v[0];

    for( a_i=0; a_i<n; a_i++ ){

        mini = min( v[a_i], mini );

        if( v[a_i]-mini == maxiD ) cont++;

    }



        cout<<cont<<endl;



}


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

#include<stdlib.h>

#include<string.h>

int v[100005];

int t[100005];

int main(void)

{

	int N, T;

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

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

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

	int max = v[N];

	int MAX = 0;

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

	{

		t[i] = max - v[i];

		if (t[i] > MAX)MAX = t[i];

		if (v[i] > max)max = v[i];

	}

	int ans = 0;

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

		if (t[i] == MAX)

			ans++;

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

	return 0;

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

using namespace std;

int main()

{

	int a, b; cin >> a >> b;

	int arr[a + 50], mi[a + 50];

	fill(mi, mi + a, 2147483647);

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

	{

		cin >> arr[i];

		if(i) mi[i] = mi[i - 1];

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

	}

	int cnt = 1, now = 0;

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

	{

//		cout << arr[i] << ' ' << mi[i] << '\n';

		if(arr[i] - mi[i - 1] > now)

		{

			cnt = 1;

			now = arr[i] - mi[i - 1];

		}

		else if(arr[i] - mi[i - 1] == now) cnt ++;

	}

	cout << cnt << '\n';

}

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

#include<stdlib.h>

#include<string.h>

int v[100005];

int t[100005];

int main(void)

{

	int N, T;

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

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

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

	int max = v[N];

	int MAX = 0;

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

	{

		t[i] = max - v[i];

		if (t[i] > MAX)MAX = t[i];

		if (v[i] > max)max = v[i];

	}

	int ans = 0;

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

		if (t[i] == MAX)

			ans++;

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

	return 0;

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

#include<algorithm>

#include<string>

#include<cmath>



using namespace std;



int main(){

    int n, t, maxn = 0;

    cin >> n >> t;

    int a[n], b[n];

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

        cin >> a[i];

    }

    b[n-1] = a[n-1];

    for(int i = n-2; i >= 0; i--){

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

    }

    int cnt = 0;

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

        if(maxn < b[i]-a[i]){

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

            cnt = 1;

        }else if(maxn == b[i] - a[i]){

            cnt ++;

        }

    }

    cout << cnt << endl;

    return 0;

}


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

int min(int a,int b)

{

	if(a<b)

		return a;

	else

		return b;

}

int main()

{

	int n,t,i,pos,old,ans=0;

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

	int min_pic=0x3f3f3f3f,max_value=0;

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

	{

		scanf("%d",&pos);

		if(i==0)

		{

			min_pic=pos;

			old=pos;

		}

		else

		{

			if(pos>old)

			{

				if(pos-min_pic>max_value)

				{

					max_value=pos-min_pic;

					ans=1;

				}

				else if(pos-min_pic==max_value)

					ans++;

			}

			else

				old=pos;

			if(min_pic>pos)

				min_pic=pos;

		}

	}

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

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

using namespace std;



vector < int > v;



int main(){

    int a_i, b_i, n, temp, t, mini, maxiD, cont = 0;



    cin>>n>>t;



    v.resize( n );



    for( a_i=0; a_i<n; a_i++ ) cin>>v[a_i];



    mini = v[0]; maxiD = 0;



    for( a_i=0; a_i<n; a_i++ ){

        mini = min( v[a_i], mini );

        maxiD = max( maxiD, v[a_i]-mini );

    }



    mini = v[0];

    for( a_i=0; a_i<n; a_i++ ){

        mini = min( v[a_i], mini );

        if( v[a_i]-mini == maxiD ) cont++;

    }



        cout<<cont<<endl;



}


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

int min(int a,int b)

{

	if(a<b)

		return a;

	else

		return b;

}

int main()

{

	int n,t,i,pos,old,ans=0;

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

	int min_pic=0x3f3f3f3f,max_value=0;

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

	{

		scanf("%d",&pos);

		if(i==0)

		{

			min_pic=pos;

			old=pos;

		}

		else

		{

			if(pos>old)

			{

				if(pos-min_pic>max_value)

				{

					max_value=pos-min_pic;

					ans=1;

				}

				else if(pos-min_pic==max_value)

					ans++;

			}

			else

				old=pos;

			if(min_pic>pos)

				min_pic=pos;

		}

	}

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

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

using namespace std;

int main()

{

	int a, b; cin >> a >> b;

	int arr[a + 50], mi[a + 50];

	fill(mi, mi + a, 2147483647);

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

	{

		cin >> arr[i];

		if(i) mi[i] = mi[i - 1];

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

	}

	int cnt = 1, now = 0;

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

	{

//		cout << arr[i] << ' ' << mi[i] << '\n';

		if(arr[i] - mi[i - 1] > now)

		{

			cnt = 1;

			now = arr[i] - mi[i - 1];

		}

		else if(arr[i] - mi[i - 1] == now) cnt ++;

	}

	cout << cnt << '\n';

}

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

int min(int a,int b)

{

	if(a<b)

		return a;

	else

		return b;

}

int main()

{

	int n,t,i,pos,old,ans=0;

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

	int min_pic=0x3f3f3f3f,max_value=0;

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

	{

		scanf("%d",&pos);

		if(i==0)

		{

			min_pic=pos;

			old=pos;

		}

		else

		{

			if(pos>old)

			{

				if(pos-min_pic>max_value)

				{

					max_value=pos-min_pic;

					ans=1;

				}

				else if(pos-min_pic==max_value)

					ans++;

			}

			else

				old=pos;

			if(min_pic>pos)

				min_pic=pos;

		}

	}

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

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

using namespace std;

#define pb push_back

#define mp make_pair

#define ll long long

#define x first

#define y second

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



const int MAX = 500005;

const int mod = 998244353;

int a[100005];

int main()

{

	ios_base::sync_with_stdio(0);

	int n , t;

	cin >> n >> t;

	map<int, int> res;

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

		cin >> a[i];

	int ans = 0;

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

	{

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

		res[ans - a[i]]++;

	}

	cout << (--res.end())->y;

			

}


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

int min(int a,int b)

{

	if(a<b)

		return a;

	else

		return b;

}

int main()

{

	int n,t,i,pos,old,ans=0;

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

	int min_pic=0x3f3f3f3f,max_value=0;

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

	{

		scanf("%d",&pos);

		if(i==0)

		{

			min_pic=pos;

			old=pos;

		}

		else

		{

			if(pos>old)

			{

				if(pos-min_pic>max_value)

				{

					max_value=pos-min_pic;

					ans=1;

				}

				else if(pos-min_pic==max_value)

					ans++;

			}

			else

				old=pos;

			if(min_pic>pos)

				min_pic=pos;

		}

	}

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

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

using namespace std;

using LL = long long;

using ULL = unsigned long long;

using VI = vector<int>;

using VL = vector<LL>;

using PII = pair<int, int>;

using PLL = pair<LL, LL>;



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

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

#define MP make_pair

#define PB push_back

#define EB emplace_back

#define F first

#define S second

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

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

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



void dout() { cerr << endl; }



template <typename Head, typename... Tail>

void dout(Head H, Tail... T) {

    cerr << H << ' ';

    dout(T...);

}



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int n, t;

    cin >> n >> t;

    VI a(n);

    FOR(i, 0, n)

        cin >> a[i];

    VI prof(n);

    int mn = a[0];

    FOR(i, 1, n)

    {

        prof[i] = a[i] - mn;

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

    }

    int mx = *max_element(ALL(prof));

    cout << count(ALL(prof), mx);

    return 0;

}

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

int min(int a,int b)

{

	if(a<b)

		return a;

	else

		return b;

}

int main()

{

	int n,t,i,pos,old,ans=0;

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

	int min_pic=0x3f3f3f3f,max_value=0;

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

	{

		scanf("%d",&pos);

		if(i==0)

		{

			min_pic=pos;

			old=pos;

		}

		else

		{

			if(pos>old)

			{

				if(pos-min_pic>max_value)

				{

					max_value=pos-min_pic;

					ans=1;

				}

				else if(pos-min_pic==max_value)

					ans++;

			}

			else

				old=pos;

			if(min_pic>pos)

				min_pic=pos;

		}

	}

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

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/stack:16777216")

#include <string>

#include <vector>

#include <map>

#include <list>

#include <iterator>

#include <set>

#include <queue>

#include <iostream>

#include <sstream>

#include <stack>

#include <deque>

#include <cmath>  

#include <memory.h>

#include <cstdlib>

#include <cstdio>

#include <cctype>

#include <algorithm>

#include <utility>

#include <time.h>

#include <bitset>

using namespace std;



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

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

#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(A,value) memset(A,value,sizeof(A))



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

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

#define PB push_back

#define MP make_pair

const double PI=acos(-1.0);



typedef long long Int;

typedef long long LL;

typedef unsigned long long UINT;

typedef vector <int> VI;

typedef pair <int, int> PII;

typedef pair <double, double> PDD;



const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL) INF;



const int MAX = 2100000;

const int MAX1 = 2007;

const int MAX2 = 24000000;

const int LEN = 21;

const int BASE = 1000000000;



const int MOD = 1000000007;



int n, t;

VI A;



int main()

{

  cin >> n >> t;

  FOR (i,0,n)

  {

    int x;

    cin >> x;

    A.PB(x);

  }



  int mx = 0, md = 0, cnt = 0;

  RFOR (i,n,0)

  {

    if (mx > A[i])

    {

      int d = mx - A[i];

      if (d > md)

      {

        cnt = 1;

        md = d;

      }

      else

      if (md == d) ++ cnt;

    }



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

  }





  cout << cnt << endl;

  

  return 0;

}


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

int min(int a,int b)

{

	if(a<b)

		return a;

	else

		return b;

}

int main()

{

	int n,t,i,pos,old,ans=0;

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

	int min_pic=0x3f3f3f3f,max_value=0;

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

	{

		scanf("%d",&pos);

		if(i==0)

		{

			min_pic=pos;

			old=pos;

		}

		else

		{

			if(pos>old)

			{

				if(pos-min_pic>max_value)

				{

					max_value=pos-min_pic;

					ans=1;

				}

				else if(pos-min_pic==max_value)

					ans++;

			}

			else

				old=pos;

			if(min_pic>pos)

				min_pic=pos;

		}

	}

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

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

#include <algorithm>

#include <vector>

#include <map>



using namespace std;



int main() {

    size_t N, T;

    scanf("%zu %zu", &N, &T);



    map<int, size_t> d;

    int min_=1e9+7;

    for (size_t i=0; i<N; ++i) {

        int A;

        scanf("%d", &A);



        if (min_ > A)

            min_ = A;



        if (min_ != A)

            ++d[A-min_];

    }



    printf("%zu\n", d.rbegin()->second);

    return 0;

}


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

#include <algorithm>



int main() {

  int N;

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



  int min=1e9+1;

  int maxprofit=0, res=0;

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

    int A;

    scanf("%d", &A);



    if (A < min)

      min = A;



    if (A - min == maxprofit) {

      ++res;

    } else if (A - min > maxprofit) {

      maxprofit = A - min;

      res = 1;

    }

  }



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

  return 0;

}