/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

int n;
ll k;
vector<ll> a, pre_sum;

void solve() {
    scanf("%d %lld", &n, &k);
    a.resize(n + 1);
    pre_sum.resize(n + 1);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    //sort(all(a));
    sort(a.begin(), a.end() + 1);
    pre_sum[0] = 0;
    for(int i = 1; i <= n; i++) pre_sum[i] = pre_sum[i - 1] + a[i];
    int cnt = 0, val;
    for(int i = 1; i <= n; i++) {
        int low = 1, hi = i, mid, ret;
        while(hi >= low) {
            mid = (low + hi) / 2;
            ll m = pre_sum[i] - pre_sum[i - mid];
            if(a[i] * mid - m <= k) {
                ret = mid;
                low = mid + 1;
            }
            else hi = mid - 1;
        }
        if(ret > cnt) {
            cnt = ret;
            val = (int)a[i];
        }
    }
    printf("%d %d\n", cnt, val);
}

int main() {
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << #x << " = " << x << endl;
#define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;}
#define shop(n, x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define endl '\n'
#define en " "
#define pb push_back
#define mod 1000000007
#define inf (2e+18)
#define pi 3.1415926536
ll bin(ll f[], ll pref[], ll pos, ll k, ll n)
{
	ll l = pos, h = n - 1;
	ll val = 0, m;
	while(l < h)
	{
		m = (l + h) / 2;
		val = f[m] - (m - pos + 1) * pref[pos];

		if(k == val)	return m;

		if(k > val)	l = m + 1;

		if(k < val)	h = m;
	}
	m = l;
	val = f[m] - (m - pos + 1) * pref[pos];
	if(val > k)	return l - 1;
	return l;
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// 		j NOT i 		check		//		CHECK -> if()   else if()
		ll n, x = 0, m = 0, y = 0, k = inf;
		cin >> n >> k;
		ll a[n];
		for(ll i = 0; i < n; i++)
			cin >> a[i];
		sort(a, a + n, greater < ll > ());
		ll pref[n] = {};
		ll f[n] = {};
		for(ll i = 1; i < n; i++)
		{
			pref[i] = a[i - 1] - a[i] + pref[i - 1];
			f[i] = f[i - 1] + pref[i];
		}
		// show(pref)
		// show(f)
		for(ll i = 0; i < n; i++)
		{
			x = bin(f, pref, i, k, n);
			// here(x)
			x = x - i + 1;
			m = max(m, x);
			if(x == m)
				y = a[i];
		}
		cout << m << " " << y << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << #x << " = " << x << endl;
#define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;}
#define shop(n, x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define endl '\n'
#define en " "
#define pb push_back
#define mod 1000000007
#define inf (2e+18)
#define pi 3.1415926536
ll bin(ll f[], ll pref[], ll pos, ll k, ll n)
{
	ll l = pos, h = n - 1;
	ll val = 0, m;
	while(l < h)
	{
		m = (l + h) / 2;
		val = f[m] - (m - pos + 1) * pref[pos];

		if(k >= val)	l = m + 1;

		if(k < val)	h = m;
	}
	m = l;
	val = f[m] - (m - pos + 1) * pref[pos];
	// here(val)
	// here(l)
	if(val > k)	return l - 1;
	return l;
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// 		j NOT i 		check		//		CHECK -> if()   else if()
		ll n, x = 0, m = 0, y = 0, k = inf;
		cin >> n >> k;
		ll a[n];
		for(ll i = 0; i < n; i++)
			cin >> a[i];
		sort(a, a + n, greater < ll > ());
		ll pref[n] = {};
		ll f[n] = {};
		for(ll i = 1; i < n; i++)
		{
			pref[i] = a[i - 1] - a[i] + pref[i - 1];
			f[i] = f[i - 1] + pref[i];
		}
		// show(a)
		// show(pref)
		// show(f)
		for(ll i = 0; i < n; i++)
		{
			x = bin(f, pref, i, k, n);
			x = x - i + 1;
			// here(x)
			m = max(m, x);
			if(x == m)
				y = a[i];
		}
		cout << m << " " << y << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << #x << " = " << x << endl;
#define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;}
#define shop(n, x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define endl '\n'
#define en " "
#define pb push_back
#define mod 1000000007
#define inf (2e+18)
#define pi 3.1415926536
const ll N = 500000;
ll pref[N] = {};
ll f[N] = {};
ll pos = 0;
bool comp(ll &m, ll k)
{
	ll val = f[m] - f[pos] - (m - pos) * pref[pos];
	return (val <= k);
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// 		j NOT i 		check		//		CHECK -> if()   else if()
		ll n, x = 0, m = 0, y = 0, k = inf;
		cin >> n >> k;
		ll a[n + 2] = {}, in[n + 1] = {};
		for(ll i = 0; i < n; i++)
			cin >> a[i];
		sort(a, a + n, greater < ll > ());
		for(ll i = 1; i < n; i++)
		{
			in[i] = i;
			pref[i] = a[0] - a[i];
			f[i] = f[i - 1] + pref[i];
		}
		for(ll i = 0; i < n; i++)
		{
			pos = i;
			x = lower_bound(in + i, in + n, k, comp) - in - i;
			m = max(m, x);
			if(x == m)
				y = a[i];
		}
		cout << m << " " << y << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << #x << " = " << x << endl;
#define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;}
#define shop(n, x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define endl '\n'
#define en " "
#define pb push_back
#define mod 1000000007
#define inf (2e+18)
#define pi 3.1415926536
const ll N = 500000;
ll pref[N] = {};
ll f[N] = {};
ll pos = 0;
bool comp(ll m, ll k)
{
	ll val = f[m] - f[pos] - (m - pos) * pref[pos];
	return (val <= k);
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// 		j NOT i 		check		//		CHECK -> if()   else if()
		ll n, x = 0, m = 0, y = 0, k = inf;
		cin >> n >> k;
		ll a[n], in[n + 1] = {};
		for(ll i = 0; i < n; i++)
			cin >> a[i];
		sort(a, a + n, greater < ll > ());
		for(ll i = 1; i < n; i++)
		{
			in[i] = i;
			pref[i] = a[i - 1] - a[i] + pref[i - 1];
			f[i] = f[i - 1] + pref[i];
		}
		for(ll i = 0; i < n; i++)
		{
			pos = i;
			x = lower_bound(in, in + n, k, comp) - in - i;
			m = max(m, x);
			if(x == m)
				y = a[i];
		}
		cout << m << " " << y << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << #x << " = " << x << endl;
#define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;}
#define shop(n, x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define endl '\n'
#define en " "
#define pb push_back
#define mod 1000000007
#define inf (2e+18)
#define pi 3.1415926536
ll bin(ll f[], ll pref[], ll pos, ll k, ll n)
{
	ll l = pos, h = n - 1;
	ll val = 0, m;
	while(l < h)
	{
		m = (l + h) / 2;
		val = f[m] - f[pos] - (m - pos) * pref[pos];
		if(k >= val)	l = m + 1;

		if(k < val)	h = m;
	}
	m = l;
	val = f[m] - f[pos] - (m - pos) * pref[pos];

	if(val > k)	return l - 1;
	return l;
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// 		j NOT i 		check		//		CHECK -> if()   else if()
		ll n, x = 0, m = 0, y = 0, k = inf;
		cin >> n >> k;
		ll a[n];
		for(ll i = 0; i < n; i++)
			cin >> a[i];
		sort(a, a + n, greater < ll > ());
		ll pref[n] = {};
		ll f[n] = {};
		for(ll i = 1; i < n; i++)
		{
			pref[i] = a[i - 1] - a[i] + pref[i - 1];
			f[i] = f[i - 1] + pref[i];
		}
		// show(a)
		// show(pref)
		// show(f)
		for(ll i = 0; i < n; i++)
		{
			x = bin(f, pref, i, k, n);
			x = x - i + 1;
			// here(x)
			m = max(m, x);
			if(x == m)
				y = a[i];
		}
		cout << m << " " << y << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << #x << " = " << x << endl;
#define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;}
#define shop(n, x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define endl '\n'
#define en " "
#define pb push_back
#define mod 1000000007
#define inf (2e+18)
#define pi 3.1415926536
ll bin(ll f[], ll pref[], ll pos, ll k, ll n)
{
	ll l = pos, h = n - 1;
	ll val = 0, m;
	while(l < h)
	{
		m = (l + h) / 2;
		val = f[m] - f[pos] - (m - pos) * pref[pos];

		if(k >= val)	l = m + 1;

		if(k < val)	h = m;
	}
	m = l;
	val = f[m] - (m - pos + 1) * pref[pos];
	// here(val)
	// here(l)
	if(val > k)	return l - 1;
	return l;
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// 		j NOT i 		check		//		CHECK -> if()   else if()
		ll n, x = 0, m = 0, y = 0, k = inf;
		cin >> n >> k;
		ll a[n];
		for(ll i = 0; i < n; i++)
			cin >> a[i];
		sort(a, a + n, greater < ll > ());
		ll pref[n] = {};
		ll f[n] = {};
		for(ll i = 1; i < n; i++)
		{
			pref[i] = a[i - 1] - a[i] + pref[i - 1];
			f[i] = f[i - 1] + pref[i];
		}
		// show(a)
		// show(pref)
		// show(f)
		for(ll i = 0; i < n; i++)
		{
			x = bin(f, pref, i, k, n);
			x = x - i + 1;
		//	here(x)
			m = max(m, x);
			if(x == m)
				y = a[i];
		}
		cout << m << " " << y << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ipair;
typedef vector<int> vi;
typedef long long ll ;
#define fo(i, n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i=a; i<(b); i++)
#define pb emplace_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define debug(x) cout << #x << "  " << x << endl;
#define mem(x,y) memset(x,y,sizeof(x))
#define endl '\n'
#define all(x) x.begin(), x.end()
int n, k;

bool valid(int i, int sum, int m, int num) {
    if(i<0) return false;
    if(num*m-sum<=k)    return true;
    return false;
}

int main() {
    cin >> n >> k;
    int ar[n];
    ll pre[n];
    fo(i, n)    cin >> ar[i];
    sort(ar, ar+n); pre[0] = 0;
    fo(i, n)
        pre[i+1] = pre[i] + ar[i];
    int freq = 0, ind = -1;
    fo(i, n) {
        int lo = 0, hi = i;
        while(hi > lo) {
            int mid = lo+(hi-lo)/2;
            if(valid(mid, pre[i+1]-pre[mid], i-mid+1, ar[i])) {
                if(mid==0 || !valid(mid-1, pre[i+1]-pre[mid-1], i-mid+2, ar[i])) {
                    lo = mid;
                    break;
                }
                hi = mid-1;
            }
            else
                lo = mid+1;
        }
        // cout << ar[i] << " " << lo << endl;
        if(i-lo+1 > freq) {
            freq = i-lo+1;
            ind = ar[i];
        }
    }
    cout << freq << " " << ind;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ipair;
typedef vector<int> vi;
typedef long long ll ;
#define fo(i, n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i=a; i<(b); i++)
#define pb emplace_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define debug(x) cout << #x << "  " << x << endl;
#define mem(x,y) memset(x,y,sizeof(x))
#define endl '\n'
#define all(x) x.begin(), x.end()
int n, k;

bool valid(int i, ll sum, ll m, ll num) {
    if(i<0) return false;
    if(num*m-sum<=k)    return true;
    return false;
}

int main() {
    cin >> n >> k;
    int ar[n];
    ll pre[n];
    fo(i, n)    cin >> ar[i];
    sort(ar, ar+n); pre[0] = 0;
    fo(i, n)
        pre[i+1] = pre[i] + ar[i];
    int freq = 0, ind = -1;
    fo(i, n) {
        int lo = 0, hi = i;
        while(hi > lo) {
            int mid = lo+(hi-lo)/2;
            if(valid(mid, pre[i+1]-pre[mid], i-mid+1, ar[i])) {
                if(mid==0 || !valid(mid-1, pre[i+1]-pre[mid-1], i-mid+2, ar[i])) {
                    lo = mid;
                    break;
                }
                hi = mid-1;
            }
            else
                lo = mid+1;
        }
        // cout << ar[i] << " " << lo << endl;
        if(i-lo+1 > freq) {
            freq = i-lo+1;
            ind = ar[i];
        }
    }
    cout << freq << " " << ind;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ipair;
typedef vector<int> vi;
typedef long long ll ;
#define fo(i, n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i=a; i<(b); i++)
#define pb emplace_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define debug(x) cout << #x << "  " << x << endl;
#define mem(x,y) memset(x,y,sizeof(x))
#define endl '\n'
#define all(x) x.begin(), x.end()
int n, k;

bool valid(int i, int sum, int m, int num) {
    if(i<0) return false;
    if(num*m-sum<=k)    return true;
    return false;
}

int main() {
    cin >> n >> k;
    int ar[n], pre[n];
    fo(i, n)    cin >> ar[i];
    sort(ar, ar+n); pre[0] = 0;
    fo(i, n)
        pre[i+1] = pre[i] + ar[i];
    int freq = 0, ind = -1;
    fo(i, n) {
        int lo = 0, hi = i;
        while(hi > lo) {
            int mid = lo+(hi-lo)/2;
            if(valid(mid, pre[i+1]-pre[mid], i-mid+1, ar[i])) {
                if(!valid(mid-1, pre[i+1]-pre[mid-1], i-mid+2, ar[i])) {
                    lo = mid;
                    break;
                }
                hi = mid-1;
            }
            else
                lo = mid+1;
        }
        // cout << ar[i] << " " << lo << endl;
        if(i-lo+1 > freq) {
            freq = i-lo+1;
            ind = ar[i];
        }
    }
    cout << freq << " " << ind;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ipair;
typedef vector<int> vi;
typedef long long ll ;
#define fo(i, n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i=a; i<(b); i++)
#define pb emplace_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define debug(x) cout << #x << "  " << x << endl;
#define mem(x,y) memset(x,y,sizeof(x))
#define endl '\n'
#define all(x) x.begin(), x.end()
int n, k;

bool valid(int i, ll sum, ll m, ll num) {
    if(i<0) return false;
    if(num*m-sum<=k)    return true;
    return false;
}

int main() {
    cin >> n >> k;
    int ar[n];
    ll pre[n+1];
    fo(i, n)    cin >> ar[i];
    sort(ar, ar+n); pre[0] = 0;
    fo(i, n)
        pre[i+1] = pre[i] + ar[i];
    int freq = 0, ind = -1;
    fo(i, n) {
        int lo = 0, hi = i;
        while(hi >= lo) {
            int mid = lo+(hi-lo)/2;
            if(valid(mid, pre[i+1]-pre[mid], i-mid+1, ar[i])) {
                if(mid==0 || !valid(mid-1, pre[i+1]-pre[mid-1], i-mid+2, ar[i])) {
                    lo = mid;
                    break;
                }
                hi = mid-1;
            }
            else
                lo = mid+1;
        }
        // cout << ar[i] << " " << lo << endl;
        if(i-lo+1 > freq) {
            freq = i-lo+1;
            ind = ar[i];
        }
    }
    cout << freq << " " << ind;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ipair;
typedef vector<int> vi;
typedef long long ll ;
#define fo(i, n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i=a; i<(b); i++)
#define pb emplace_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define debug(x) cout << #x << "  " << x << endl;
#define mem(x,y) memset(x,y,sizeof(x))
#define endl '\n'
#define all(x) x.begin(), x.end()
int n, k;

bool valid(int i, ll sum, ll m, ll num) {
    if(i<0) return false;
    if(num*m-sum<=k)    return true;
    return false;
}

int main() {
    cin >> n >> k;
    int ar[n];
    ll pre[n];
    fo(i, n)    cin >> ar[i];
    sort(ar, ar+n); pre[0] = 0;
    fo(i, n)
        pre[i+1] = pre[i] + ar[i];
    int freq = 0, ind = -1;
    fo(i, n) {
        int lo = 0, hi = i;
        while(hi >= lo) {
            int mid = lo+(hi-lo)/2;
            if(valid(mid, pre[i+1]-pre[mid], i-mid+1, ar[i])) {
                if(mid==0 || !valid(mid-1, pre[i+1]-pre[mid-1], i-mid+2, ar[i])) {
                    lo = mid;
                    break;
                }
                hi = mid-1;
            }
            else
                lo = mid+1;
        }
        // cout << ar[i] << " " << lo << endl;
        if(i-lo+1 > freq) {
            freq = i-lo+1;
            ind = ar[i];
        }
    }
    cout << freq << " " << ind;
}


#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a)
{
    int ans=0;
    for (int i=0;i<s.length();i++)
         ans=(ans*10+(int)s[i]-'0')%a;
    return ans;
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y)
{
    if (y==0)
        return 1;
    else if (y%2==0)
        return power(x,y/2)*power(x,y/2);
    else
        return x*power(x,y/2)*power(x,y/2);
}
ll hcf(ll a,ll b)
{
    if(b==0)
        return a;
    return hcf(b,a%b);
}
ll n,k,ans,num;
vector <ll> v,pref;
ll check(ll mid)
{
    ll i;
    for(i=mid;i<=n;i++)
    {
        ll reqd=(v[i]*mid)-(pref[i]-pref[i-mid]);
        if(reqd<=k)
        {
          num=v[i];
          return i;
        }
    }
    return 0;
}
ll binsearch(ll low,ll high)
{
    ll mid,ans1=-INF;
    while(low<high)
    {
        mid=(low+high+1)/2;
        if(check(mid))
         low=mid;
        else
         high=mid-1;
    }
    //check(low);
    return low;
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       cin>>n>>k;
       ll i;
       v.resize(n+1);
       v[0]=-INF;
       pref.resize(n+1,0);
       for(i=1;i<=n;i++)
        cin>>v[i];
       sort(v.begin(),v.end());
       pref[1]=v[1];
       num=v[1];
       for(i=2;i<=n;i++)
        pref[i]=pref[i-1]+v[i];
        //cout<<ans<<" "<<num;
       ans=binsearch(1,n);
       cout<<ans<<" "<<num;
   }
}


#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a)
{
    int ans=0;
    for (int i=0;i<s.length();i++)
         ans=(ans*10+(int)s[i]-'0')%a;
    return ans;
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y)
{
    if (y==0)
        return 1;
    else if (y%2==0)
        return power(x,y/2)*power(x,y/2);
    else
        return x*power(x,y/2)*power(x,y/2);
}
ll hcf(ll a,ll b)
{
    if(b==0)
        return a;
    return hcf(b,a%b);
}
ll n,k,ans,num;
vector <ll> v,pref;
ll check(ll mid,ll x)
{
    ll i;
    for(i=mid;i<x;i++)
    {
        ll reqd=(v[x]*i)-(pref[x-1]-pref[x-i-1]);
        if(reqd<=k)
         return i;
    }
    return 0;
}
ll binsearch(ll low,ll high)
{
    ll mid=(low+high)/2,ans=0,i=high+1;
    while(low<high)
    {
        mid=(low+high+1)/2;
        if(check(mid,i))
         low=mid;
        else
         high=mid-1;
    }
    // cout<<high<<" ";
    // cout<<mid<<" ";
    // cout<<low<<"\n";
     //ll x=check(low,i);
     return low;
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       cin>>n>>k;
       ll i,ans=0,num;
       v.resize(n+1);
       v[0]=0;
       pref.resize(n+1,0);
       map <ll,ll> mp,mp2;
       for(i=1;i<=n;i++)
        cin>>v[i],mp2[v[i]]++,mp[v[i]]=-1;
       sort(v.begin(),v.end());
       for(i=1;i<=n;i++)
        pref[i]=pref[i-1]+v[i];
       for(i=1;i<=n;i++)
       {
           if(mp[v[i]]!=-1)
           {
               //cout<<"continued at"<<i<<"\n";
            continue;
           }
           ll p=binsearch(0,i-1);
           //cout<<p<<"\n";
           mp[v[i]]=p;
           if(mp2[v[i]]+p>ans)
            ans=mp2[v[i]]+p,num=v[i];
       }
       cout<<ans<<" "<<num;
   }
}


#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a)
{
    int ans=0;
    for (int i=0;i<s.length();i++)
         ans=(ans*10+(int)s[i]-'0')%a;
    return ans;
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y)
{
    if (y==0)
        return 1;
    else if (y%2==0)
        return power(x,y/2)*power(x,y/2);
    else
        return x*power(x,y/2)*power(x,y/2);
}
ll hcf(ll a,ll b)
{
    if(b==0)
        return a;
    return hcf(b,a%b);
}
ll n,k,ans,num;
vector <ll> v,pref;
ll check(ll mid,ll x)
{
    ll i,ans=0;
    for(i=mid;i<x;i++)
    {
        ll reqd=(v[x]*i)-(pref[x-1]-pref[x-i-1]);
        if(reqd<=k)
         return i;
    }
    return 0;
}
ll binsearch(ll low,ll high)
{
    ll mid=(low+high)/2,ans=0,i=high+1;
    while(low<high)
    {
        mid=(low+high+1)/2;
        if(check(mid,i))
         low=mid;
        else
         high=mid-1;
    }
     return low;
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       cin>>n>>k;
       ll i,ans=0,num;
       v.resize(n+1);
       v[0]=-INF;
       pref.resize(n+1,0);
       map <ll,ll> mp,mp2;
       for(i=1;i<=n;i++)
        cin>>v[i],mp2[v[i]]++,mp[v[i]]=-INF;
       sort(v.begin(),v.end());
       pref[1]=v[1];
       for(i=2;i<=n;i++)
        pref[i]=pref[i-1]+v[i];
       for(i=1;i<=n;i++)
       {
           if(mp[v[i]]!=-INF)
            continue;
           ll p=binsearch(0,i-1);
           mp[v[i]]=p;
           if(mp2[v[i]]+p>ans)
            ans=mp2[v[i]]+p,num=v[i];
       }
       cout<<ans<<" "<<num;
   }
}


#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a)
{
    int ans=0;
    for (int i=0;i<s.length();i++)
         ans=(ans*10+(int)s[i]-'0')%a;
    return ans;
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y)
{
    if (y==0)
        return 1;
    else if (y%2==0)
        return power(x,y/2)*power(x,y/2);
    else
        return x*power(x,y/2)*power(x,y/2);
}
ll hcf(ll a,ll b)
{
    if(b==0)
        return a;
    return hcf(b,a%b);
}
ll n,k,ans,num;
vector <ll> v,pref;
ll check(ll mid)
{
    ll i;
    for(i=mid;i<=n;i++)
    {
        ll reqd=(v[i]*mid)-(pref[i]-pref[i-mid]);
        if(reqd<=k)
        {
          num=v[i];
          return i;
        }
    }
    return 0;
}
ll binsearch(ll low,ll high)
{
    ll mid,ans1=-INF;
    while(low<high)
    {
        mid=(low+high+1)/2;
        if(check(mid))
         low=mid;
        else
         high=mid-1;
    }
    //check(low);
    return low;
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       cin>>n>>k;
       ll i;
       v.resize(n+1);
       v[0]=-INF;
       pref.resize(n+1,0);
       for(i=1;i<=n;i++)
        cin>>v[i];
       sort(v.begin(),v.end());
       pref[1]=v[1];
       for(i=2;i<=n;i++)
        pref[i]=pref[i-1]+v[i];
        //cout<<ans<<" "<<num;
       ans=binsearch(1,n);
       cout<<ans<<" "<<num;
   }
}


#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a)
{
    int ans=0;
    for (int i=0;i<s.length();i++)
         ans=(ans*10+(int)s[i]-'0')%a;
    return ans;
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y)
{
    if (y==0)
        return 1;
    else if (y%2==0)
        return power(x,y/2)*power(x,y/2);
    else
        return x*power(x,y/2)*power(x,y/2);
}
ll hcf(ll a,ll b)
{
    if(b==0)
        return a;
    return hcf(b,a%b);
}
ll n,k,ans,num;
vector <ll> v,pref;
ll check(ll mid,ll x)
{
    ll i,ans=0;
    for(i=mid;i<x;i++)
    {
        ll reqd=(v[x]*i)-(pref[x-1]-pref[x-i-1]);
        if(reqd<=k)
        {
         //cout<<reqd<<" "<<i<<"\n";
         //ans=
         return i;
        }
    }
    return 0;
}
ll binsearch(ll low,ll high)
{
    ll mid=(low+high)/2,ans=0,i=high+1;
    while(low<high)
    {
        mid=(low+high+1)/2;
        //cout<<"mid="<<low<<" "<<mid<<" "<<high<<"\n";
        if(check(mid,i))
         low=mid;
        else
         high=mid-1;
    }
    // cout<<high<<" ";
    // cout<<mid<<" ";
    // cout<<low<<"\n";
     //ll x=check(18,i);
     //cout<<"x="<<x<<"\n";
     return low;
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       cin>>n>>k;
       ll i,ans=0,num;
       v.resize(n+1);
       v[0]=-INF;
       pref.resize(n+1,0);
       map <ll,ll> mp,mp2;
       for(i=1;i<=n;i++)
        cin>>v[i],mp2[v[i]]++,mp[v[i]]=-INF;
       sort(v.begin(),v.end());
       pref[1]=v[1];
       for(i=2;i<=n;i++)
        pref[i]=pref[i-1]+v[i];
       for(i=1;i<=n;i++)
       {
           if(mp[v[i]]!=-INF)
           {
               //cout<<"continued at"<<i<<"\n";
            continue;
           }
           ll p=binsearch(0,i-1);
           //cout<<p<<"\n";
           mp[v[i]]=p;
           //if(v[i]==1||v[i]==0)
            //cout<<i<<" "<<v[i]<<" "<<p<<" "<<mp2[v[i]]<<" "<<p+mp2[v[i]]<<"\n";
           if(mp2[v[i]]+p>ans)
            ans=mp2[v[i]]+p,num=v[i];
       }
       //cout<<mp[0]<<" "<<mp[1]<<" ";
       //for(auto &u:v)
        //cout<<u<<" ";
       cout<<ans<<" "<<num;
   }
}


#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a)
{
    int ans=0;
    for (int i=0;i<s.length();i++)
         ans=(ans*10+(int)s[i]-'0')%a;
    return ans;
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y)
{
    if (y==0)
        return 1;
    else if (y%2==0)
        return power(x,y/2)*power(x,y/2);
    else
        return x*power(x,y/2)*power(x,y/2);
}
ll hcf(ll a,ll b)
{
    if(b==0)
        return a;
    return hcf(b,a%b);
}
ll n,k,ans,num;
vector <ll> v,pref;
ll check(ll mid)
{
    ll i;
    for(i=mid;i<n;i++)
    {
        ll reqd=(v[i]*mid)-(pref[i]-pref[i-mid]);
        if(reqd<=k)
        {
          num=v[i];
          return i;
        }
    }
    return 0;
}
ll binsearch(ll low,ll high)
{
    ll mid,ans1=-INF;
    while(low<high)
    {
        mid=(low+high+1)/2;
        if(check(mid))
         low=mid;
        else
         high=mid-1;
    }
     return low;
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       cin>>n>>k;
       ll i;
       v.resize(n+1);
       v[0]=-INF;
       pref.resize(n+1,0);
       for(i=1;i<=n;i++)
        cin>>v[i];
       sort(v.begin(),v.end());
       pref[1]=v[1];
       for(i=2;i<=n;i++)
        pref[i]=pref[i-1]+v[i];
        //cout<<ans<<" "<<num;
       ans=binsearch(1,n);
       cout<<ans<<" "<<num;
   }
}


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
ll a[1000009], pre[1000009];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k,num;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i = 1;i<=n;i++)
        pre[i] += pre[i-1] + a[i];
    int j = n;
    for(int i = n; i>=1;i--)
    {
        while(( (i- j + 1)*a[i] <= pre[i] - pre[j-1] + k) && j >= 1)
            j--;
        j++;
        if(i - j + 1 >= ans)
            ans = i - j + 1, num = a[i];
    }
    cout<<ans<<" "<<num;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k,a,b;
    cin>>a>>b;
    n = sqrtl(a);
    m = (sqrtl(1+4*b) - 1) / 2;
    if(n>m)
    {
        cout<<"Valera";
    }
    else cout<<"Vladik";
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int a[1000000], pre[1000000];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k,num;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i = 1;i<=n;i++)
        pre[i] += pre[i-1] + a[i];
    int j = n;
    for(int i = n; i>=1;i--)
    {
        while(((i-j+1)*a[i] <= pre[i] - pre[j-1] + k) && j >= 1)
            j--;
        if(i-j >= ans)
            ans = i-j, num = a[i];
    }
    cout<<ans<<" "<<num;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int a[1000009], pre[1000009];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k,num;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i = 1;i<=n;i++)
        pre[i] += pre[i-1] + a[i];
    int j = n;
    for(int i = n; i>=1;i--)
    {
        while(((i-j+1)*a[i] <= pre[i] - pre[j-1] + k) && j >= 1)
            j--;
        if(i-j >= ans)
            ans = i-j, num = a[i];
    }
    cout<<ans<<" "<<num;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int a[1000009], pre[1000009];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k,num;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i = 1;i<=n;i++)
        pre[i] += pre[i-1] + a[i];
    int j = n;
    for(int i = n; i>=1;i--)
    {
        while(( (i- j + 1)*a[i] <= pre[i] - pre[j-1] + k) && j >= 1)
            j--;
        j++;
        if(i- j + 1 >= ans)
            ans = i - j + 1, num = a[i];
    }
    cout<<ans<<" "<<num;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int a[1000009], pre[1000009];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k,num;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i = 1;i<=n;i++)
        pre[i] += pre[i-1] + a[i];
    int j = n;
    for(int i = n; i>=1;i--)
    {
        while(( (i- j + 1)*a[i] <= pre[i] - pre[j-1] + k) && j >= 1)
            j--;
        j++;
        if(i - j + 1 >= ans)
            ans = i - j + 1, num = a[i];
    }
    cout<<ans<<" "<<num;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int a[1000009], pre[1000009];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k,num;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i = 1;i<=n;i++)
        pre[i] += pre[i-1] + a[i];
    int j = n;
    for(int i = n; i>=1;i--)
    {
        while(((i-max(j,1)+1)*a[i] <= pre[i] - pre[j-1] + k) && j >= 1)
            j--;
        if(i-j >= ans)
            ans = i-j, num = a[i];
    }
    cout<<ans<<" "<<num;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005];
LL n, k,m,ans1 = -1,ans2 = -1;

int test(int tmp)
{
    for(int i = tmp; i<=n; i++)
    {
        if(sum[i]-sum[i-tmp]+k>=tmp*a[i])
        {
            ans1 = tmp;
            ans2 = a[i];
            return 1;
        }
    }
    return 0;
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        sum[i] = sum[i-1] + a[i];
    }
    sort(a+1,a+1+n);

    int h = 1, t = n,mid;
    while(h<=t)
    {
        mid = (h+t)/2;
        if(test(mid))
            h = mid + 1;
        else
            t = mid - 1;
    }
    cout<<ans1<<' '<<ans2<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005], b[100005];
LL n, k,m,ans1 = -1,ans2 = -1;

void binsch(LL val)
{
    int pos = upper_bound(a+1,a+1+n,val) - (a+1);
    int h = 0, t = pos-1, mid,cnt;
    while(h<=t)
    {
        mid = (h+t)/2;
        cnt = pos - mid;
        if( a[pos]*cnt<=sum[pos]-sum[mid]+k)
        {
            if(cnt>ans1)
            {
                ans1 = cnt;
                ans2 = a[pos];
            }
            t = mid-1;
        }
        else h = mid+1;
    }
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n);

    sum[1] = a[1];
    b[++m] = a[1];
    for(int i = 2; i<=n; i++)
    {
        sum[i] = sum[i-1] + a[i];
        if(a[i]!=b[m])
            b[++m] = a[i];
    }

   for(int i = 1; i<=n; i++)
       binsch(a[i]);

   cout<<ans1<<' '<<ans2<<endl;
}


#include<iostream>//先枚举答案，后二分个数（更新最小的合法个数）
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005];
LL n, k,m,ans1 = -1,ans2 = -1;

void binsch(int pos)
{
    int h = 0, t = pos-1, mid,cnt;
    while(h<=t)
    {
        mid = (h+t)/2;
        cnt = pos - mid;
        if(a[pos]*cnt<=sum[pos]-sum[mid]+k)
        {
            if(cnt>ans1)//更新答案
            {
                ans1 = cnt;
                ans2 = a[pos];
            }
            t = mid-1;
        }
        else h = mid+1;
    }
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n);

    for(int i = 1; i<=n; i++)
        sum[i] = sum[i-1] + a[i];

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

   cout<<ans1<<' '<<ans2<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005];
LL n, k,ans;

LL test(LL ocu)
{
    LL m = 0, le = k, j,i;
    for(i = ocu-1; i<n; i++)
    {
         for(j = i; j>=0; j--)
         {
             if(le>=a[i]-a[j])
             {
                 m++;
                 le -= a[i]-a[j];
                 if(m==ocu) {ans = a[i];return 1;}
             }
         }

         m = 0;
         le = k;
    }
    return 0;
}

int main()
{

    cin>>n>>k;
    for(int i = 0; i<n; i++)
        scanf("%lld",&a[i]);
   sort(a,a+n);

   LL h = 1, t = n,mid;
   while(h<=t)
   {
       mid = (h+t)/2;
       if(test(mid))
        h = mid+1;
       else
        t = mid-1;
   }
   cout<<t<<' '<<ans<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005], b[100005];
LL n, k,m,ans1 = -1,ans2 = -1;

void binsch(LL e)
{
    int pos = upper_bound(a+1,a+1+n,e) - (a+1);
    int h = 0, t = pos-1, mid,cnt;
    while(h<=t)
    {
        mid = (h+t)/2;
        cnt = pos - mid;
        if(a[pos]*cnt>=sum[pos]-sum[mid] &&  a[pos]*cnt<=sum[pos]-sum[mid]+k)
        {
            if(cnt>ans1)
            {
                ans1 = cnt;
                ans2 = a[pos];
            }
            t = mid-1;
        }
        else h = mid+1;
    }
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n);

    sum[1] = a[1];
    b[++m] = a[1];
    for(int i = 2; i<=n; i++)
    {
        sum[i] = sum[i-1] + a[i];
        if(a[i]!=b[m])
            b[++m] = a[i];
    }

   for(int i = 1; i<=m; i++)
       binsch(b[i]);

   cout<<ans1<<' '<<ans2<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005];
LL n, k,m,ans1 = -1,ans2 = -1;

int test(int tmp)
{
    for(int i = tmp; i<=n; i++)
    {
        if(sum[i]-sum[i-tmp]+k>=tmp*a[i])
        {

            ans1 = tmp;
            ans2 = a[i];
            return 1;
        }
    }
    return 0;
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        sum[i] = sum[i-1] + a[i];

    }
    sort(a+1,a+1+n);
    for(int i = 1; i<=n; i++)
    {

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

    }
    int h = 1, t = n,mid;
    while(h<=t)
    {
        mid = (h+t)/2;
        if(test(mid))
            h = mid + 1;
        else
            t = mid - 1;
    }
    cout<<ans1<<' '<<ans2<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005], b[100005];
LL n, k,m,ans1 = -1,ans2 = -1;

void binsch(LL val)
{
    int pos = upper_bound(a+1,a+1+n,val) - (a+1);
    int h = 0, t = pos-1, mid,cnt;
    while(h<=t)
    {
        mid = (h+t)/2;
        cnt = pos - mid;
        if(a[pos]*cnt>=sum[pos]-sum[mid] &&  a[pos]*cnt<=sum[pos]-sum[mid]+k)
        {
            if(cnt>ans1)
            {
                ans1 = cnt;
                ans2 = a[pos];
            }
            t = mid-1;
        }
        else h = mid+1;
    }
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n);

    sum[1] = a[1];
    b[++m] = a[1];
    for(int i = 2; i<=n; i++)
    {
        sum[i] = sum[i-1] + a[i];
        if(a[i]!=b[m])
            b[++m] = a[i];
    }

   for(int i = 1; i<=n; i++)
       binsch(a[i]);

   cout<<ans1<<' '<<ans2<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005];
LL n, k,m,cnt,val;

int test(int tmp)
{
    for(int i = tmp; i<=n; i++)
    {
        if(sum[i]-sum[i-tmp]+k>=tmp*a[i])
        {
            cnt = tmp;
            val = a[i];
            return 1;
        }
    }
    return 0;
}

void binsearch()
{
    int h = 1, t = n,mid;
    while(h<=t)
    {
        mid = (h+t)/2;
        if(test(mid))
            h = mid + 1;
        else
            t = mid - 1;
    }
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n);
    for(int i = 1; i<=n; i++)
    {
        sum[i] = sum[i-1] + a[i];
    }

    binsearch();
    cout<<cnt<<' '<<val<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005], b[100005],m;
LL n, k,ans1 = -1,ans2 = -1;

void binsch(LL e)
{
    int pos = upper_bound(a+1,a+1+n,e) - (a+1);//cout<<pos<<endl;
    int h = 0, t = pos-1, mid,cnt;
    while(h<=t)
    {
        mid = (h+t)/2;
        cnt = pos - mid;

        if(a[pos]*cnt>=sum[pos]-sum[mid] &&  a[pos]*cnt<=sum[pos]-sum[mid]+k)
        {
            if(cnt>ans1)
            {
                ans1 = cnt;
                ans2 = a[pos];
            }
            t = mid-1;
        }
        else h = mid+1;
    }
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
        scanf("%lld",&a[i]);
   sort(a+1,a+1+n);

    sum[1] = a[1];
    b[++m] = a[1];
    for(int i = 2; i<=n; i++)
    {
        sum[i] = sum[i-1] + a[i];
        if(a[i]!=b[m])
            b[++m] = a[i];
    }

   for(int i = 1; i<=m; i++)
   {
       binsch(b[i]);
   }

   cout<<ans1<<' '<<ans2<<endl;
}


#include<iostream>//先二分个数，后枚举答案判断是否合法，逐步逼近。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<set>
#define LL long long
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define LNF ((1LL<<62)-1)
#define maxn 200010

using namespace std;

LL a[100005], sum[100005];
LL n, k,m,cnt,val;

int test(int tmp)
{
    for(int i = tmp; i<=n; i++)
    {
        if(sum[i]-sum[i-tmp]+k>=tmp*a[i])
        {
            cnt = tmp;
            val = a[i];
            return 1;
        }
    }
    return 0;
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i<=n; i++)
        scanf("%lld",&a[i]);

    sort(a+1,a+1+n);
    for(int i = 1; i<=n; i++)
        sum[i] = sum[i-1] + a[i];

    int h = 1, t = n, mid;
    while(h<=t)
    {
        mid = (h+t)/2;
        if(test(mid))
            h = mid + 1;
        else
            t = mid - 1;
    }

    cout<<cnt<<' '<<val<<endl;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
typedef long long ll;
typedef long double ld;
const int N = 2e2 + 5, M = 100 + 5, OO = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, arr[N], ans1 = 0, ans2, k, cum[N];
int BS(int ee)
{
	int s = 0, e = ee, ans = ee;
	while(s <= e)
	{
		int mid = (s + e) / 2;
		ll cnt = ee - mid + 1;
		if(cnt * arr[ee] - (cum[ee] - cum[mid - 1]) <= k)
			e = mid - 1, ans = mid;
		else
			s = mid + 1;
	}
	return ee - ans + 1;
}
int main()
{
	MuhammedAly
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++)
		cin >> arr[i];
	sort(arr + 1, arr + n + 1);
	for(int i = 1 ; i <= n ; i++)
		cum[i] = cum[i - 1] + arr[i];
	for(int i = 1 ; i <= n; i++)
	{
		int tmp = BS(i);
		if(tmp > ans1)
			ans1 = tmp, ans2 = arr[i];
	}
	cout << ans1 << " " << ans2;
	return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
typedef long long ll;
typedef long double ld;
const int N = 2e2 + 5, M = 100 + 5, OO = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, arr[N], ans1 = 0, ans2, l = OO, r = -OO, k;
int main()
{
	MuhammedAly
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i], l = min(l, arr[i]), r = max(r, arr[i]);
	int mid1, mid2;
	while(l <= r)
	{
		mid1 = l + (r - l) / 3;
		mid2 = r - (r - l) / 3;
		int kk1 = k, tmp = 0, kk2 = k, tmp2 = 0;
		priority_queue<int, vector<int>, greater<int>>v1, v2;

		for(int i = 0 ; i < n ; i++)
		{
			if(arr[i] <= mid1)
				v1.push(abs(arr[i] - mid1));
			if(arr[i] <= mid2)
				v2.push(abs(arr[i] - mid2));
		}
		while(!v1.empty() && kk1 >= v1.top())
		{
			tmp++;
			kk1 -= v1.top();
			v1.pop();
		}
		while(!v2.empty() && kk2 >= v2.top())
		{
			tmp2++;
			kk2 -= v2.top();
			v2.pop();
		}
		if(tmp > ans1)
			ans2 = mid1, ans1 = tmp;
		if(tmp2 > ans1)
			ans2 = mid2, ans1 = tmp2;
		if(tmp == ans1 && mid1 > ans2)
			ans2 = mid1, ans1 = tmp;
		if(tmp2 == ans1 && mid2 > ans2)
			ans2 = mid2, ans1 = tmp2;
		if(tmp > tmp2)
			r = mid2 - 1;
		else
			l = mid1 + 1;

	}
	cout << ans1 << " " << ans2;
	return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5, M = 100 + 5, OO = 0x3f3f3f3f, MOD = 1e9 + 7;

ll n, arr[N], ans1 = 0, ans2, k, cum[N];
int BS(ll ee)
{
	ll s = 1, e = ee, ans = ee;
	while(s <= e)
	{
		ll mid = (s + e) / 2;
		ll cnt = ee - mid + 1;
		if(cnt * arr[ee] - (cum[ee] - cum[mid - 1]) <= k)
			e = mid - 1, ans = mid;
		else
			s = mid + 1;
	}
	return ee - ans + 1;
}
int main()
{
	MuhammedAly
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++)
		cin >> arr[i];
	sort(arr + 1, arr + n + 1);
	for(int i = 1 ; i <= n ; i++)
		cum[i] = cum[i - 1] + arr[i];
	for(int i = 1 ; i <= n; i++)
	{
		ll tmp = BS(i);
		if(tmp > ans1)
			ans1 = tmp, ans2 = arr[i];
	}
	cout << ans1 << " " << ans2;
	return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
typedef long long ll;
typedef long double ld;
const int N = 2e2 + 5, M = 100 + 5, OO = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, arr[N], ans1 = 0, ans2, l = OO, r = -OO, k;
int main()
{
	MuhammedAly
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i], l = min(l, arr[i]), r = max(r, arr[i]);
	int mid1, mid2;
	while(l <= r)
	{
		mid1 = l + (r - l) / 3;
		mid2 = r - (r - l) / 3;
		int kk1 = k, tmp = 0, kk2 = k, tmp2 = 0;
		priority_queue<int, vector<int>, greater<int>>v1, v2;

		for(int i = 0 ; i < n ; i++)
		{
			if(arr[i] <= mid1)
				v1.push(abs(arr[i] - mid1));
			if(arr[i] <= mid2)
				v2.push(abs(arr[i] - mid2));
		}
		while(!v1.empty() && kk1 >= v1.top())
		{
			tmp++;
			kk1 -= v1.top();
			v1.pop();
		}
		while(!v2.empty() && kk2 >= v2.top())
		{
			tmp2++;
			kk2 -= v2.top();
			v2.pop();
		}
		if(tmp > ans1)
			ans2 = mid1, ans1 = tmp;
		if(tmp2 > ans1)
			ans2 = mid2, ans1 = tmp2;
		if(tmp == ans1 && mid1 < ans2)
			ans2 = mid1, ans1 = tmp;
		if(tmp2 == ans1 && mid2 < ans2)
			ans2 = mid2, ans1 = tmp2;
		if(tmp >= tmp2)
			r = mid2 - 1;
		else
			l = mid1 + 1;

	}
	cout << ans1 << " " << ans2;
	return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
typedef long long ll;
typedef long double ld;
const int N = 2e2 + 5, M = 100 + 5, OO = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, arr[N], ans1 = 0, ans2, k, cum[N];
int BS(int ee)
{
	int s = 1, e = ee, ans = ee;
	while(s <= e)
	{
		int mid = (s + e) / 2;
		ll cnt = ee - mid + 1;
		if(cnt * arr[ee] - (cum[ee] - cum[mid - 1]) <= k)
			e = mid - 1, ans = mid;
		else
			s = mid + 1;
	}
	return ee - ans + 1;
}
int main()
{
	MuhammedAly
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++)
		cin >> arr[i];
	sort(arr + 1, arr + n + 1);
	for(int i = 1 ; i <= n ; i++)
		cum[i] = cum[i - 1] + arr[i];
	for(int i = 1 ; i <= n; i++)
	{
		int tmp = BS(i);
		if(tmp > ans1)
			ans1 = tmp, ans2 = arr[i];
	}
	cout << ans1 << " " << ans2;
	return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5, M = 100 + 5, OO = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, arr[N], ans1 = 0, ans2, k, cum[N];
int BS(int ee)
{
	int s = 1, e = ee, ans = ee;
	while(s <= e)
	{
		int mid = (s + e) / 2;
		ll cnt = ee - mid + 1;
		if(cnt * arr[ee] - (cum[ee] - cum[mid - 1]) <= k)
			e = mid - 1, ans = mid;
		else
			s = mid + 1;
	}
	return ee - ans + 1;
}
int main()
{
	MuhammedAly
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++)
		cin >> arr[i];
	sort(arr + 1, arr + n + 1);
	for(int i = 1 ; i <= n ; i++)
		cum[i] = cum[i - 1] + arr[i];
	for(int i = 1 ; i <= n; i++)
	{
		int tmp = BS(i);
		if(tmp > ans1)
			ans1 = tmp, ans2 = arr[i];
	}
	cout << ans1 << " " << ans2;
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n);
	vector <lli> pre(n, 0);

	for(lli &x: ar) cin >> x;
	sort(ALL(ar));

	pre[0] = ar[0];
	for(int i=1; i<n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	res.fi = 1;
	res.sc = ar[0];

	for(int j=1; j<n; j++){
		lli l=0, r = n;
		for(int a=0; a<1000; a++){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}

		if(res.fi < j-l+1){
			res.fi = j-l+1;
			res.sc = ar[j];
		}else if(res.fi == j-l+1){
			res.sc = min(res.sc, ar[j]);
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n+1, 0);
	vector <lli> pre(n+1, 0);

	for(int i=1; i<=n; i++) cin >> ar[i];
	sort(ar.begin()+1, ar.end());

	for(int i=1; i<=n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	map <lli, lli> ans;
	res.fi = 1;
	res.sc = ar[1];

	for(int j=2; j<=n; j++){
		lli l=1, r=j+1;
		while(r > l){
			lli comp;
			if(j-mid-1 >= 0)
				comp = ar[j] * mid - pre[j-1] + pre[j-mid-1];
			else
				comp = ar[j] * mid - pre[j-1];

			if(comp <= k)
				l = mid+1;
			else
				r = mid;
		}

		ans[ar[j]] = max(ans[ar[j]], l);
	}

	for(auto it=ans.begin(); it!=ans.end(); it++){
		if(it->sc > res.fi){
			res.fi = it->sc;
			res.sc = it->fi;
		}else if(it->sc == res.fi){
			res.sc = min(res.sc, it->fi);
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n+1, 0);
	vector <lli> pre(n+1, 0);

	for(int i=1; i<=n; i++) cin >> ar[i];
	sort(ar.begin()+1, ar.end());

	for(int i=1; i<=n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	res.fi = 1;
	res.sc = ar[1];

	for(int j=2; j<=n; j++){
		lli l=1, r=n+1;
		while(r > l){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}

		if(res.fi < j-l+1){
			res.fi = j-l+1;
			res.sc = ar[j];
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n+1, 0);
	vector <lli> pre(n+1, 0);

	for(int i=1; i<=n; i++) cin >> ar[i];
	sort(ar.begin()+1, ar.end());

	for(int i=1; i<=n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	res.fi = 1;
	res.sc = ar[1];

	for(int j=2; j<=n; j++){
		lli l=1, r=n+1;
		for(int a=0; a<1000; a++){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}

		if(res.fi < j-l+1){
			res.fi = j-l+1;
			res.sc = ar[j];
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n+1, 0);
	vector <lli> pre(n+1, 0);

	for(int i=1; i<=n; i++) cin >> ar[i];
	sort(ar.begin()+1, ar.end());

	for(int i=1; i<=n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	map <lli, lli> ans;
	res.fi = 1;
	res.sc = ar[1];

	for(int j=2; j<=n; j++){
		lli l=0, r=j;
		while(l<r){
			lli comp;
			if(j-mid-1 >= 0)
				comp = ar[j] * mid - pre[j-1] + pre[j-mid-1];
			else
				comp = ar[j] * mid - pre[j-1];

			if(comp <= k)
				l = mid+1;
			else
				r = mid;
		}

		//if(ar[j] * l - pre[j-1] + (j-l-1>=0?pre[j-l-1]:0) > k) l--;

		if(res.fi < l){
			res.fi = l;
			res.sc = ar[j];
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n+1, 0);
	vector <lli> pre(n+1, 0);

	for(int i=1; i<=n; i++) cin >> ar[i];
	sort(ar.begin()+1, ar.end());

	for(int i=1; i<=n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	res.fi = 1;
	res.sc = ar[1];

	for(int j=2; j<=n; j++){
		lli l=1, r=n+1;
		for(int a=0; a<1000; a++){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}

		if(res.fi < j-l+1 and j <= n){
			res.fi = j-l+1;
			res.sc = ar[j];
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n+1, 0);
	vector <lli> pre(n+1, 0);

	for(int i=1; i<=n; i++) cin >> ar[i];
	sort(ar.begin()+1, ar.end());

	for(int i=1; i<=n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	map <lli, lli> ans;
	res.fi = 1;
	res.sc = ar[1];

	for(int j=2; j<=n; j++){
		lli l=1, r=n+1;
		while(r > l){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}

		ans[ar[j]] = max(ans[ar[j]], j-l+1);
	}

	for(auto it=ans.begin(); it!=ans.end(); it++){
		if(it->sc > res.fi){
			res.fi = it->sc;
			res.sc = it->fi;
		}else if(it->sc == res.fi){
			res.sc = min(res.sc, it->fi);
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n+1, 0);
	vector <lli> pre(n+1, 0);

	for(int i=1; i<=n; i++) cin >> ar[i];
	sort(ar.begin()+1, ar.end());

	for(int i=1; i<=n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	map <lli, lli> ans;
	res.fi = 1;
	res.sc = ar[1];

	for(int j=2; j<=n; j++){
		lli l=0, r=j;
		for(int a=0; a<1000; a++){
			lli comp;
			if(j-mid-1 >= 0)
				comp = ar[j] * mid - pre[j-1] + pre[j-mid-1];
			else
				comp = ar[j] * mid - pre[j-1];

			if(comp <= k)
				l = mid;
			else
				r = mid-1;
		}

		if(res.fi < l+1){
			res.fi = l+1;
			res.sc = ar[j];
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n);
	vector <lli> pre(n, 0);

	for(lli &x: ar) cin >> x;
	sort(ALL(ar));

	pre[0] = ar[0];
	for(int i=1; i<n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	res.fi = 1;
	res.sc = ar[0];

	for(int j=1; j<n; j++){
		lli l=0, r = n;
		for(int a=0; a<1000; a++){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}

		if(res.fi < j-l+1){
			res.fi = j-l+1;
			res.sc = ar[j];
		}else if(res.fi == j-l+1){
			res.sc = min(res.sc, ar[j]);
		}
	}

	int f = 49001;
	if(n == 100000 and k == 500000){
		for(int i=0; i<n; i++){
			if(ar[i] == f){
				cout << "49001 : " << i << endl;
			}else if(ar[i] == 1000)
				cout << "1000 : " << i << endl;
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n);
	vector <lli> pre(n, 0);

	for(lli &x: ar) cin >> x;
	sort(ALL(ar));
	pre[0] = ar[0];
	for(int i=1; i<n; i++) pre[i] += pre[i-1] + ar[i];

	/*for(int x: pre) cout << x << " ";
		cout << endl;*/

	pair <long long, long long> res;
	for(int j=1; j<n; j++){
		lli l=0, r = n;
		for(int a=0; a<1000; a++){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}
		if(res.fi < j-l+1){
			res.fi = j-l+1;
			res.sc = ar[j];
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n, k;
	cin >> n >> k;
	vector <lli> ar(n);
	vector <lli> pre(n, 0);

	for(lli &x: ar) cin >> x;
	sort(ALL(ar));
	pre[0] = ar[0];
	for(int i=1; i<n; i++) pre[i] += pre[i-1] + ar[i];

	pair <long long, long long> res;
	res.fi = 1;
	res.sc = ar[0];
	for(int j=1; j<n; j++){
		lli l=0, r = n;
		for(int a=0; a<1000; a++){
			lli comp;
			if(mid - 1 >= 0)
				comp = ar[j] * (j - mid) - pre[j-1] + pre[mid-1];
			else
				comp = ar[j] * (j - mid) - pre[j-1];

			if(comp <= k)
				r = mid;
			else
				l = mid+1;
		}
		if(res.fi < j-l+1){
			res.fi = j-l+1;
			res.sc = ar[j];
		}
	}

	cout << res.fi << " " << res.sc;

	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define po pop_back
#define fi first
#define se second
#define ll long long int
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

using namespace std;
typedef pair<ll,ll> pp;
ll last = 0;

void solve(){

    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(ll i=0 ; i<n ; i++){
        cin >> a[i];
    }

    sort(a,a+n,greater<int>());

    ll max=0;
    ll ans;
    for(ll i=0 ; i<n-1 ; i++){
        if(a[i] == a[i-1] && i>0)
            continue;

        ll count= 1;
        ll t=1;
        ll j=i+1;
        ll sum = a[j];
        while((a[i]*t-sum)<=k && j<n){
            // cout << sum << " ";
            count++;
            j++;
            sum += a[j];
            t++;
        }
        if(count >= max){
            max = count;
            ans = a[i];
        }
    }

    cout << max << " " << ans;

    // cout << "Case #" << k<<": " << "IMPOSSIBLE";
}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve();
        cout << "\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define po pop_back
#define fi first
#define se second
#define ll long long int
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

using namespace std;
typedef pair<ll,ll> pp;
ll last = 0;

void solve(){

    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(ll i=0 ; i<n ; i++){
        cin >> a[i];
    }

    if(n == 1){
        cout << 1 << " " << a[0];
        return;
    }
    sort(a,a+n,greater<int>());

    ll max=0;
    ll ans=0;
    for(ll i=0 ; i<n-1 ; i++){
        if(a[i] == a[i-1] && i>0)
            continue;

        ll count= 1;
        ll t=1;
        ll j=i+1;
        ll sum = a[j];
        while((a[i]*t-sum)<=k && j<n){
            // cout << sum << " ";
            count++;
            j++;
            sum += a[j];
            t++;
        }
        if(count >= max){
            max = count;
            ans = a[i];
        }
    }

    cout << max << " " << ans;

    // cout << "Case #" << k<<": " << "IMPOSSIBLE";
}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve();
        cout << "\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define po pop_back
#define fi first
#define se second
#define ll long long int
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

using namespace std;
typedef pair<ll,ll> pp;
ll last = 0;

void solve(){

    ll n,k;
    cin >> n >> k;
    ll a[n];
    ll b[n+1]={0};
    for(ll i=0 ; i<n ; i++){
        cin >> a[i];
    }

    if(n == 1){
        cout << 1 << " " << a[0];
        return;
    }
    sort(a,a+n);

    b[0] = a[0];
    for(ll i=0 ; i<n ; i++){
        b[i+1] = b[i]+a[i];
    }

    ll max=0;
    ll ans=0;
    ll j = 0;
    for(ll i=0 ; i<n ; i++){

        while(a[i]*(i-j+1)-(b[i+1]-b[j])>k){
            j++;
        }

        if((i-j+1) > max){
            max = (i-j+1);
            ans = a[i];
        }
    }

    cout << max << " " << ans;

    // cout << "Case #" << k<<": " << "IMPOSSIBLE";
}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve();
        cout << "\n";
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <vector>
#include <map>
#include<set>
#include <string>
#include<cstdlib>
#include <queue>

using namespace std;

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

const int N = 200001;

struct point{int x,y;};
struct rect{int x1,x2,y1,y2; bool r; int num; rect(){r = false;}};

rect rects[N]; point points[N];

int n,m, rn, pn;

bool comp(const point& a, const point& b){ return a.y < b.y;}
bool comp2(const rect& a, const rect& b){ return a.y2 < b.y2;}
bool comp3(const rect& a, const rect& b){ return a.num < b.num;}

const int DN = 131072;
const int Dlog = 18;
int d[Dlog][DN];
void prepare(){
    fi(i,0,DN) fi(j,0,Dlog) d[j][i]=-1;
}

void add(int x, int v){
    d[0][x] =v; int h = 1;
    fi(i,1,Dlog)
    {
        x &= ~(1<<(i-1));
        d[i][x]=min(d[i-1][x], d[i-1][x+(1<<(i-1))]);
    }
}

int get(int l, int r){
    int ans = 1000000;
    r++;
    int h = 0;
    while(l + (1<<h) <=r){
        while((l + (1<<(h+1)) <= r) && ( (l & (1<<(h))) == 0)) h++;
        ans = min(ans, d[h][l]);
        l+= 1<<h;
    }
    while(l < r){
        while(l + (1<<h) > r) h--;
        ans = min(ans,d[h][l]);
        l += 1<<h;
    }
    return ans;
}

void solve(){
    sort(points, points + pn, comp);
    sort(rects, rects + rn, comp2);

    prepare();

    int pcur=0,rcur=0;
    fi(i,1,n+1){
        while(pcur < pn && points[pcur].y == i) {add(points[pcur].x, i); pcur++;}
        while(rcur < rn && rects[rcur].y2 == i){
            int z = get(rects[rcur].x1, rects[rcur].x2);
            if(z >= rects[rcur].y1) rects[rcur].r = true;

            rcur++;
        }
    }
}

void main()
{
#if defined(DEBUG) || defined(_DEBUG)
  ifstream cin("input.txt");
  ofstream cout("output.txt");
#endif
  cin>>m>>n>>pn>>rn;
  fi(i,0,pn) cin>>points[i].x >> points[i].y;
  fi(i,0,rn){ cin>>rects[i].x1>>rects[i].y1>>rects[i].x2>>rects[i].y2; rects[i].num = i;}

  solve();
  fi(i,0,pn) swap(points[i].x, points[i].y);
  fi(i,0,rn) {swap(rects[i].x1, rects[i].y1); swap(rects[i].y2, rects[i].x2);}
  swap(n,m);
  solve();
  sort(rects, rects+rn, comp3);

  fi(i,0,rn) cout<<(rects[i].r ? "YES" : "NO")<<endl;

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    class SegmentTree<T>
    {
        private readonly int size;
        private readonly T[] data;
        private readonly Func<T, T, T> fun;

        public SegmentTree(Func<T, T, T> fun, int size)
        {
            data = new T[size << 2];
            this.fun = fun;
            this.size = size;
        }

        public SegmentTree(Func<T, T, T> fun, T[] array)
            : this(fun, array.Length)
        {
            Build(array, 1, 0, size - 1);
        }

        private void Build(T[] array, int x, int xl, int xr)
        {
            if (xl == xr)
                data[x] = array[xl];
            else
            {
                int xm = xl + xr >> 1;
                Build(array, x * 2, xl, xm);
                Build(array, x * 2 + 1, xm + 1, xr);
                data[x] = fun(data[x * 2], data[x * 2 + 1]);
            }
        }

        private T Query(int x, int xl, int xr, int l, int r)
        {
            if (l == xl && r == xr)
                return data[x];

            int xm = xl + xr >> 1;
            if (l <= xm && r > xm)
                return fun(Query(x * 2, xl, xm, l, xm), Query(x * 2 + 1, xm + 1, xr, xm + 1, r));
            if (l <= xm)
                return Query(x * 2, xl, xm, l, r);
            return Query(x * 2 + 1, xm + 1, xr, l, r);
        }

        public T Query(int l, int r)
        {
            return Query(1, 0, size - 1, l, r);
        }

        private void Set(int x, int xl, int xr, int idx, T v)
        {
            if (xl == xr)
                data[x] = v;
            else
            {
                int xm = xl + xr >> 1;
                if (idx <= xm)
                    Set(x * 2, xl, xm, idx, v);
                else
                    Set(x * 2 + 1, xm + 1, xr, idx, v);
                data[x] = fun(data[x * 2], data[x * 2 + 1]);
            }
        }

        public void Set(int idx, T v)
        {
            Set(1, 0, size - 1, idx, v);
        }
    }

    void Swap<T>(ref T a, ref T b)
    {
        T t = a;
        a = b;
        b = t;
    }

    public void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        int k = ReadInt();
        int q = ReadInt();

        var a = ReadIntMatrix(k);
        var b = new int[q][];
        for (int i = 0; i < q; i++)
            b[i] = new [] { ReadInt() - 1, ReadInt() - 1, ReadInt() - 1, ReadInt() - 1, i };

        var ans = new bool[q];
        for (int it = 0; it < 2; it++)
        {
            Array.Sort(a, (a1, a2) => a1[1] - a2[1]);
            Array.Sort(b, (b1, b2) => b1[3] - b2[3]);
            var tree = new SegmentTree<int>(Math.Min, n);

            int pa = 0, pb = 0;
            for (int i = 0; i < m; i++)
            {
                for (; pa < k && a[pa][1] == i + 1; pa++)
                    tree.Set(a[pa][0] - 1, i + 1);
                for (; pb < q && b[pb][3] == i; pb++)
                    ans[b[pb][4]] |= tree.Query(b[pb][0], b[pb][2]) > b[pb][1];
            }

            if (it == 1)
                break;

            Swap(ref n, ref m);
            for (int i = 0; i < k; i++)
                Swap(ref a[i][0], ref a[i][1]);
            for (int i = 0; i < q; i++)
            {
                Swap(ref b[i][0], ref b[i][1]);
                Swap(ref b[i][2], ref b[i][3]);
            }
        }

        WriteLines(ans.Select(f => f ? "YES" : "NO"));
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("cycle.in");
        //writer = new StreamWriter("cycle.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


import java.io.*;
import java.util.*;

/**
* @author master_j
* @version 0.4.1
* @since Mar 22, 2015
*/
public class Solution {
    private void solve() throws IOException {
        int w = io.nI(), h = io.nI(), rooksNum = io.nI(), rectsNum = io.nI();

        Rook[] rooks = new Rook[rooksNum];
        for (int i = 0; i < rooks.length; i++)
            rooks[i] = new Rook(io);

        Rect[] rects = new Rect[rectsNum];
        for (int i = 0; i < rects.length; i++)
            rects[i] = new Rect(io, i);

        boolean[] ans = new boolean[rectsNum];
        int rookPtr, rectPtr;

        Arrays.sort(rooks, Rook.lrComp);
        Arrays.sort(rects, Rect.lrComp);
        SegmentTreeMinS stLR = new SegmentTreeMinS(1 + 1 + h);
        rookPtr = 0;
        rectPtr = 0;
        while (true) {
            Rook rook = null;
            if (rookPtr < rooks.length)
                rook = rooks[rookPtr];

            Rect rect = null;
            if (rectPtr < rects.length)
                rect = rects[rectPtr];

            if (rect == null)
                break;

            if (rook != null && rook.x <= rect.x1) {
                stLR.update(rook.y, rook.x);
                rookPtr++;
            } else {
                if (rect.x0 <= stLR.min(rect.y0, rect.y1))
                    ans[rect.id] = true;
                rectPtr++;
            }
        }

        Arrays.sort(rooks, Rook.btComp);
        Arrays.sort(rects, Rect.btComp);
        SegmentTreeMinS stBT = new SegmentTreeMinS(1 + 1 + w);
        rookPtr = 0;
        rectPtr = 0;
        while (true) {
            Rook rook = null;
            if (rookPtr < rooks.length)
                rook = rooks[rookPtr];

            Rect rect = null;
            if (rectPtr < rects.length)
                rect = rects[rectPtr];

            if (rect == null)
                break;

            if (rook != null && rook.y <= rect.y1) {
                stBT.update(rook.x, rook.y);
                rookPtr++;
            } else {
                if (rect.y0 <= stBT.min(rect.x0, rect.x1))
                    ans[rect.id] = true;
                rectPtr++;
            }
        }

        for (boolean b : ans)
            io.wln(b ? "YES" : "NO");
    }//2.2250738585072012e-308

    public static void main(String[] args) throws IOException {
        IO.launchSolution(args);
    }

    Solution(IO io) throws IOException {
        this.io = io;
        solve();
    }

    private final IO io;
}

class IO {
    static final String _localArg = "master_j";
    private static final String _problemName = "";
    private static final IO.Mode _inMode = Mode.STD_;
    private static final IO.Mode _outMode = Mode.STD_;
    private static final boolean _autoFlush = false;

    static enum Mode {STD_, _PUT_TXT, PROBNAME_}

    private final StreamTokenizer st;
    private final BufferedReader br;
    private final Reader reader;

    private final PrintWriter pw;
    private final Writer writer;

    static void launchSolution(String[] args) throws IOException {
        boolean local = (args.length == 1 && args[0].equals(IO._localArg));
        IO io = new IO(local);

        long nanoTime = 0;
        if (local) {
            nanoTime -= System.nanoTime();
            io.wln("<output>");
        }

        io.flush();
        new Solution(io);
        io.flush();

        if (local) {
            io.wln("</output>");
            nanoTime += System.nanoTime();
            final long D9 = 1000000000, D6 = 1000000, D3 = 1000;
            if (nanoTime >= D9)
                io.wf("%d.%d seconds\n", nanoTime / D9, nanoTime % D9);
            else if (nanoTime >= D6)
                io.wf("%d.%d millis\n", nanoTime / D6, nanoTime % D6);
            else if (nanoTime >= D3)
                io.wf("%d.%d micros\n", nanoTime / D3, nanoTime % D3);
            else
                io.wf("%d nanos\n", nanoTime);
        }

        io.close();
    }

    IO(boolean local) throws IOException {
        if (_inMode == Mode.PROBNAME_ || _outMode == Mode.PROBNAME_)
            if (_problemName.length() == 0)
                throw new IllegalStateException("You imbecile. Where's my <_problemName>?");

        if (_problemName.length() > 0)
            if (_inMode != Mode.PROBNAME_ && _outMode != Mode.PROBNAME_)
                throw new IllegalStateException("You imbecile. What's the <_problemName> for?");

        Locale.setDefault(Locale.US);

        if (local) {
            reader = new FileReader("input.txt");
            writer = new OutputStreamWriter(System.out);
        } else {
            switch (_inMode) {
                case STD_:
                    reader = new InputStreamReader(System.in);
                    break;
                case PROBNAME_:
                    reader = new FileReader(_problemName + ".in");
                    break;
                case _PUT_TXT:
                    reader = new FileReader("input.txt");
                    break;
                default:
                    throw new NullPointerException("You imbecile. Gimme _inMode.");
            }
            switch (_outMode) {
                case STD_:
                    writer = new OutputStreamWriter(System.out);
                    break;
                case PROBNAME_:
                    writer = new FileWriter(_problemName + ".out");
                    break;
                case _PUT_TXT:
                    writer = new FileWriter("output.txt");
                    break;
                default:
                    throw new NullPointerException("You imbecile. Gimme _outMode.");
            }
        }

        br = new BufferedReader(reader);
        st = new StreamTokenizer(br);

        pw = new PrintWriter(writer, _autoFlush);

        if (local && _autoFlush)
            wln("Note: auto-flush is on.");
    }

    void wln()          {pw.println(); }
    void wln(boolean x) {pw.println(x);}
    void wln(char x)    {pw.println(x);}
    void wln(char x[])  {pw.println(x);}
    void wln(double x)  {pw.println(x);}
    void wln(float x)   {pw.println(x);}
    void wln(int x)     {pw.println(x);}
    void wln(long x)    {pw.println(x);}
    void wln(Object x)  {pw.println(x);}
    void wln(String x)  {pw.println(x);}

    void wf(String f, Object...o){pw.printf(f, o);}

    void w(boolean x)   {pw.print(x);}
    void w(char x)      {pw.print(x);}
    void w(char x[])    {pw.print(x);}
    void w(double x)    {pw.print(x);}
    void w(float x)     {pw.print(x);}
    void w(int x)       {pw.print(x);}
    void w(long x)      {pw.print(x);}
    void w(Object x)    {pw.print(x);}
    void w(String x)    {pw.print(x);}

    int nI() throws IOException    {st.nextToken(); return (int)st.nval;}
    double nD() throws IOException {st.nextToken(); return st.nval;}
    float nF() throws IOException  {st.nextToken(); return (float)st.nval;}
    long nL() throws IOException   {st.nextToken(); return (long)st.nval;}
    String nS() throws IOException {st.nextToken(); return st.sval;}

    int[] nIa(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nI();
        return a;
    }
    double[] nDa(int n) throws IOException {
        double[] a = new double[n];
        for (int i = 0; i < n; i++)
            a[i] = nD();
        return a;
    }
    String[] nSa(int n) throws IOException {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nS();
        return a;
    }

    void wc(String x)         {wc(x.toCharArray());}
    void wc(char c1, char c2) {for (char c = c1; c<=c2; c++) wc(c);}
    void wc(char x[])         {for (char c : x) wc(c); }
    void wc(char x)           {st.ordinaryChar(x); st.wordChars(x, x);}

    public boolean eof() {return st.ttype == StreamTokenizer.TT_EOF;}
    public boolean eol() {return st.ttype == StreamTokenizer.TT_EOL;}

    void flush() {pw.flush();}
    void close() throws IOException {reader.close(); br.close(); flush(); pw.close();}
}

class SegmentTreeMinS {
    private final int n;
    private final int[] tree;

    SegmentTreeMinS(int n) {
        this.n = n;
        this.tree = new int[4 * n];
        Arrays.fill(tree, -1);
    }

    int min(int l, int r) {
        return min(1, 0, n - 1, l, r);
    }

    private int min(int v, int tl, int tr, int l, int r) {
        if (l > r)
            return Integer.MAX_VALUE;
        if (l == tl && r == tr)
            return tree[v];
        int tm = (tl + tr) / 2;
        return Math.min(min(2 * v, tl, tm, l, Math.min(tm, r)),
                min(1 + 2 * v, 1 + tm, tr, Math.max(l, 1 + tm), r));
    }

    void update(int i, int val) {
        update(1, i, val, 0, n - 1);
    }

    private void update(int v, int i, int val, int tl, int tr) {
        if (i < tl || tr < i)
            return;
        if (tl == tr) {
            tree[v] = val;
            return;
        }

        int tm = (tl + tr) / 2;
        update(2 * v, i, val, tl, tm);
        update(1 + 2 * v, i, val, 1 + tm, tr);
        tree[v] = Math.min(tree[2 * v], tree[1 + 2 * v]);
    }
}

class Rook {
    final int x, y;

    Rook(IO io) throws IOException {
        this.x = io.nI();
        this.y = io.nI();
    }

    static Comparator<Rook> lrComp = new Comparator<Rook>() {
        @Override
        public int compare(Rook r0, Rook r1) {
            return r0.x - r1.x;
        }
    };

    static Comparator<Rook> btComp = new Comparator<Rook>() {
        @Override
        public int compare(Rook r0, Rook r1) {
            return r0.y - r1.y;
        }
    };
}

class Rect {
    final int x0, y0, x1, y1;
    final int id;

    Rect(IO io, int id) throws IOException {
        this.x0 = io.nI();
        this.y0 = io.nI();
        this.x1 = io.nI();
        this.y1 = io.nI();
        this.id = id;
    }

    static Comparator<Rect> lrComp = new Comparator<Rect>() {
        @Override
        public int compare(Rect r0, Rect r1) {
            return r0.x1 - r1.x1;
        }
    };

    static Comparator<Rect> btComp = new Comparator<Rect>() {
        @Override
        public int compare(Rect r0, Rect r1) {
            return r0.y1 - r1.y1;
        }
    };
}