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

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

typedef long long ll;

const int mmax=1e5+10;

map<ll,ll> s;

ll book[mmax],num[mmax];

int main()

{

	ll n,k;

	while(cin>>n>>k)

	{

		memset(book,0,sizeof(book));

		memset(num,0,sizeof(num));

		s.clear();

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

		{

			ll a,b;

			cin>>a>>b;

			s[a]+=b;

			num[i]=a;

		}

		ll sum=0;

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

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

		{

			if(num[i]!=num[i-1])

				book[i]=num[i];

		}

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

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

		{



			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

				if(sum>k||sum==k)

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 


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

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,s;

    cin>>n>>k;

    vector<ll>vc;

    map<ll,ll>mp;

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

    {

        cin>>a>>b;

        if(mp[a]==0)

        {

            vc.push_back(a);

            mp[a]=mp[a]+b;

        }

        else if(mp[a]!=0)

        {

            mp[a]=mp[a]+b;

        }

    }

    sort(vc.begin(),vc.end());

    i=0;

    s=0;

    while(s<k)

    {

        l=vc[i];

        j=mp[l];

        s+=j;

        i++;

    }

    cout<<l<<endl;

    return 0;



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

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

const int N=1e5+5;

const int mod=1e9+7;

const double eps=1e-8;

const double PI = acos(-1.0);

#define lowbit(x) (x&(-x))

ll a[N],b[N],p[N];

int main()

{

    std::ios::sync_with_stdio(false);

    ll n,k;

    while(cin>>n>>k)

    {

        memset(p,0,sizeof(p));

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

        {

            cin>>a[i]>>b[i];

            p[a[i]]+=b[i];

        }

        ll ans=0;

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

        {

            ans+=p[i];

            if(ans>=k)

            {

                cout<<i<<endl;

                break;

            }

        }

    }



    return 0;

}


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

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,s;

    cin>>n>>k;

    vector<ll>vc;

    map<ll,ll>mp;

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

    {

        cin>>a>>b;

        if(mp[a]==0)

        {

            vc.push_back(a);

            mp[a]=mp[a]+b;

        }

        else if(mp[a]!=0)

        {

            mp[a]=mp[a]+b;

        }

    }

    sort(vc.begin(),vc.end());

    i=0;

    s=0;

    while(s<k)

    {

        l=vc[i];

        j=mp[l];

        s+=j;

        i++;

    }

    cout<<l<<endl;

    return 0;



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

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

typedef long long ll;

const int mmax=1e5+10;

map<ll,ll> s;

ll book[mmax],num[mmax];

int main()

{

	ll n,k;

	while(cin>>n>>k)

	{

		memset(book,0,sizeof(book));

		memset(num,0,sizeof(num));

		s.clear();

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

		{

			ll a,b;

			cin>>a>>b;

			s[a]+=b;

			num[i]=a;

		}

		ll sum=0;

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

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

		{

			if(num[i]!=num[i-1])

				book[i]=num[i];

		}

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

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

		{



			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

				if(sum>k||sum==k)

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 


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

using namespace std;



#define pb push_back

#define mp make_pair

#define fst first

#define snd second



#define fr(i,n) 	for(int i=0;i<n;i++)

#define frr(i,n)	for(int i=1;i<=n;i++)



#define ms(x,i)	memset(x,i,sizeof(x))

#define dbg(x)	cout << #x << " = " << x << endl

#define all(x)	x.begin(),x.end()



#define gnl cout << endl

#define olar cout << "olar" << endl

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



typedef long long int ll;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;

typedef pair<ll,ll> pll;



const int INF = 0x3f3f3f3f;

const ll llINF = 0x3f3f3f3f3f3f3f;

const int MOD = 1e9+7;



int main(){



	fastio;

	ll n,k;



	cin >> n >> k;

	vector<pll> v;



	ll sum = 0ll;

	ll ans;

	fr(i,n){

		ll a;

		ll b;

		cin >> a >> b;



		v.pb(mp(a,b));

	}



	sort(all(v));



	fr(i,n){

		sum += v[i].snd;



		if(sum >= k){

			ans = v[i].fst;

			break;

		}

	}



	cout << ans << endl;



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

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

const int N=1e5+5;

const int mod=1e9+7;

const double eps=1e-8;

const double PI = acos(-1.0);

#define lowbit(x) (x&(-x))

ll a[N],b[N],p[N];

int main()

{

    std::ios::sync_with_stdio(false);

    ll n,k;

    while(cin>>n>>k)

    {

        memset(p,0,sizeof(p));

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

        {

            cin>>a[i]>>b[i];

            p[a[i]]+=b[i];

        }

        ll ans=0;

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

        {

            ans+=p[i];

            if(ans>=k)

            {

                cout<<i<<endl;

                break;

            }

        }

    }



    return 0;

}


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

using namespace std;



#define pb push_back

#define mp make_pair

#define fst first

#define snd second



#define fr(i,n) 	for(int i=0;i<n;i++)

#define frr(i,n)	for(int i=1;i<=n;i++)



#define ms(x,i)	memset(x,i,sizeof(x))

#define dbg(x)	cout << #x << " = " << x << endl

#define all(x)	x.begin(),x.end()



#define gnl cout << endl

#define olar cout << "olar" << endl

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



typedef long long int ll;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;

typedef pair<ll,ll> pll;



const int INF = 0x3f3f3f3f;

const ll llINF = 0x3f3f3f3f3f3f3f;

const int MOD = 1e9+7;



int main(){



	fastio;

	ll n,k;



	cin >> n >> k;

	vector<pll> v;



	ll sum = 0ll;

	ll ans;

	fr(i,n){

		ll a;

		ll b;

		cin >> a >> b;



		v.pb(mp(a,b));

	}



	sort(all(v));



	fr(i,n){

		sum += v[i].snd;



		if(sum >= k){

			ans = v[i].fst;

			break;

		}

	}



	cout << ans << endl;



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

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

typedef long long ll;

const int mmax=1e5+10;

map<ll,ll> s;

ll book[mmax],num[mmax];

int main()

{

	ll n,k;

	while(cin>>n>>k)

	{

		memset(book,0,sizeof(book));

		memset(num,0,sizeof(num));

		s.clear();

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

		{

			ll a,b;

			cin>>a>>b;

			s[a]+=b;

			num[i]=a;

		}

		ll sum=0;

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

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

		{

			if(num[i]!=num[i-1])

				book[i]=num[i];

		}

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

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

		{



			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

				if(sum>k||sum==k)

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 


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

using namespace std;



#define pb push_back

#define mp make_pair

#define fst first

#define snd second



#define fr(i,n) 	for(int i=0;i<n;i++)

#define frr(i,n)	for(int i=1;i<=n;i++)

#define pv(x, n)    fr(iii, n) printf("%d%c", x[iii], " \n"[iii==n-1])

#define pvv(x, n)    frr(iii, n) printf("%d%c", x[iii], " \n"[iii==n])

#define vp(v)        pv(v, v.size()) 





#define ms(x,i)	memset(x,i,sizeof(x))

#define dbg(x)	cout << #x << " = " << x << endl

#define all(x)	x.begin(),x.end()

#define otp(x) cout << x << endl;

#define rvr(x) int x; scanf("%d", &x)

#define gnl cout << endl

#define olar cout << "olar" << endl

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)



typedef long long int ll;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;

typedef vector<ll> vll;

typedef pair<ll,ll> pll;



const int N = 1e5 + 1;



ll freq[N];



int main(){

    rvr(n);

    ll k; scanf("%lld", &k);

    fr(i, n){

        rvr(a); rvr(b);

        freq[a] += (ll)b;

    }

    int i = 1;

    while(k){

        if(freq[i] >= k){

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

            return 0;

        }

        k -= freq[i++];

    }

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

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

const int N=1e5+5;

const int mod=1e9+7;

const double eps=1e-8;

const double PI = acos(-1.0);

#define lowbit(x) (x&(-x))

ll a[N],b[N],p[N];

int main()

{

    std::ios::sync_with_stdio(false);

    ll n,k;

    while(cin>>n>>k)

    {

        memset(p,0,sizeof(p));

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

        {

            cin>>a[i]>>b[i];

            p[a[i]]+=b[i];

        }

        ll ans=0;

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

        {

            ans+=p[i];

            if(ans>=k)

            {

                cout<<i<<endl;

                break;

            }

        }

    }



    return 0;

}


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

using namespace std;



#define pb push_back

#define mp make_pair

#define fst first

#define snd second



#define fr(i,n) 	for(int i=0;i<n;i++)

#define frr(i,n)	for(int i=1;i<=n;i++)

#define pv(x, n)    fr(iii, n) printf("%d%c", x[iii], " \n"[iii==n-1])

#define pvv(x, n)    frr(iii, n) printf("%d%c", x[iii], " \n"[iii==n])

#define vp(v)        pv(v, v.size()) 





#define ms(x,i)	memset(x,i,sizeof(x))

#define dbg(x)	cout << #x << " = " << x << endl

#define all(x)	x.begin(),x.end()

#define otp(x) cout << x << endl;

#define rvr(x) int x; scanf("%d", &x)

#define gnl cout << endl

#define olar cout << "olar" << endl

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)



typedef long long int ll;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;

typedef vector<ll> vll;

typedef pair<ll,ll> pll;



const int N = 1e5 + 1;



ll freq[N];



int main(){

    rvr(n);

    ll k; scanf("%lld", &k);

    fr(i, n){

        rvr(a); rvr(b);

        freq[a] += (ll)b;

    }

    int i = 1;

    while(k){

        if(freq[i] >= k){

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

            return 0;

        }

        k -= freq[i++];

    }

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

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

typedef long long ll;

const int mmax=1e5+10;

map<ll,ll> s;

ll book[mmax],num[mmax];

int main()

{

	ll n,k;

	while(cin>>n>>k)

	{

		memset(book,0,sizeof(book));

		memset(num,0,sizeof(num));

		s.clear();

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

		{

			ll a,b;

			cin>>a>>b;

			s[a]+=b;

			num[i]=a;

		}

		ll sum=0;

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

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

		{

			if(num[i]!=num[i-1])

				book[i]=num[i];

		}

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

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

		{



			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

				if(sum>k||sum==k)

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 


// Faster C++ solution for the same problem (measured speedup: 2.952028570602386x):
//If you are trying to hack me I wish you can get it, Good Luck :D.

#include <bits/stdc++.h>

using namespace std;



#define debug(args...) fprintf (stderr,args)

#define pb push_back

#define mp make_pair



typedef long long ll;

typedef pair<int,int> pii;

typedef pair<ll,ll> pll;



const int MAX = 1e5 + 10;

const int INF = 0x3f3f3f3f;

const ll  MOD = 1000000007;



ll n, k, sum[MAX];

pll op[MAX];







int main() {

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

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

      ll a, b;

      scanf("%lld%lld", &a, &b);

      op[i] = pii(a, b);

   }

   sort(op, op + n);

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

      sum[i] = op[i].second;

      if (i > 0) sum[i] += sum[i - 1];      

   }



   ll l = 0, r = n - 1;



   while (l < r) {

      ll mid = (l + r) / 2;

      //debug("--> mid = %lld and sum[mid] = %lld\n", mid, sum[mid]);

      if (sum[mid] < k) l = mid + 1;

      else r = mid;

   }



   printf("%lld\n", op[l].first);



   return 0;

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

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

const int N=1e5+5;

const int mod=1e9+7;

const double eps=1e-8;

const double PI = acos(-1.0);

#define lowbit(x) (x&(-x))

ll a[N],b[N],p[N];

int main()

{

    std::ios::sync_with_stdio(false);

    ll n,k;

    while(cin>>n>>k)

    {

        memset(p,0,sizeof(p));

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

        {

            cin>>a[i]>>b[i];

            p[a[i]]+=b[i];

        }

        ll ans=0;

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

        {

            ans+=p[i];

            if(ans>=k)

            {

                cout<<i<<endl;

                break;

            }

        }

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.9736109832897206x):
//If you are trying to hack me I wish you can get it, Good Luck :D.

#include <bits/stdc++.h>

using namespace std;



#define debug(args...) fprintf (stderr,args)

#define pb push_back

#define mp make_pair



typedef long long ll;

typedef pair<int,int> pii;

typedef pair<ll,ll> pll;



const int MAX = 1e5 + 10;

const int INF = 0x3f3f3f3f;

const ll  MOD = 1000000007;



ll n, k, sum[MAX];

pll op[MAX];







int main() {

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

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

      ll a, b;

      scanf("%lld%lld", &a, &b);

      op[i] = pii(a, b);

   }

   sort(op, op + n);

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

      sum[i] = op[i].second;

      if (i > 0) sum[i] += sum[i - 1];      

   }



   ll l = 0, r = n - 1;



   while (l < r) {

      ll mid = (l + r) / 2;

      //debug("--> mid = %lld and sum[mid] = %lld\n", mid, sum[mid]);

      if (sum[mid] < k) l = mid + 1;

      else r = mid;

   }



   printf("%lld\n", op[l].first);



   return 0;

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

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

typedef long long ll;

const int mmax=1e5+10;

map<ll,ll> s;

ll book[mmax],num[mmax];

int main()

{

	ll n,k;

	while(cin>>n>>k)

	{

		memset(book,0,sizeof(book));

		memset(num,0,sizeof(num));

		s.clear();

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

		{

			ll a,b;

			cin>>a>>b;

			s[a]+=b;

			num[i]=a;

		}

		ll sum=0;

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

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

		{

			if(num[i]!=num[i-1])

				book[i]=num[i];

		}

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

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

		{



			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

				if(sum>k||sum==k)

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 


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

using namespace std;



#define pb push_back

#define mp make_pair

#define fst first

#define snd second



#define fr(i,n)     for(int i=0;i<n;i++)

#define frr(i,n)    for(int i=1;i<=n;i++)



#define ms(x,i) memset(x,i,sizeof(x))

#define dbg(x)  cout << #x << " = " << x << endl

#define all(x)  x.begin(),x.end()



#define gnl cout << endl

#define chapa cout << "oi meu chapa" << endl

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)

//cout << setprecision(9)<<fixed;



typedef long long int ll;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<pii> vii;

typedef pair<ll,ll> pll;



const int INF = 0x3f3f3f3f;

const ll llINF = (long long)(1e18) + 100;   

const int MAXN = 100100;

const int MAXM = 1001000;

const ll mod=1e9+7;

const int LMAXN = 25;

ll n, k;

vector<pll> v;



int main(){

	fastio;

	cin>>n>>k;



	ll a, b;

	fr(i, n){

		cin>>a>>b;

		v.pb({a, b});

	}

	

	sort(all(v));



	ll pos = 0;



	fr(i,n){

		if (pos <= k and k <= pos + v[i].snd){

			cout<<v[i].fst<<endl;

			return 0;

		}

		pos += v[i].snd;

	}



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

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

const int N=1e5+5;

const int mod=1e9+7;

const double eps=1e-8;

const double PI = acos(-1.0);

#define lowbit(x) (x&(-x))

ll a[N],b[N],p[N];

int main()

{

    std::ios::sync_with_stdio(false);

    ll n,k;

    while(cin>>n>>k)

    {

        memset(p,0,sizeof(p));

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

        {

            cin>>a[i]>>b[i];

            p[a[i]]+=b[i];

        }

        ll ans=0;

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

        {

            ans+=p[i];

            if(ans>=k)

            {

                cout<<i<<endl;

                break;

            }

        }

    }



    return 0;

}


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

using namespace std;



#define pb push_back

#define mp make_pair

#define fst first

#define snd second



#define fr(i,n)     for(int i=0;i<n;i++)

#define frr(i,n)    for(int i=1;i<=n;i++)



#define ms(x,i) memset(x,i,sizeof(x))

#define dbg(x)  cout << #x << " = " << x << endl

#define all(x)  x.begin(),x.end()



#define gnl cout << endl

#define chapa cout << "oi meu chapa" << endl

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)

//cout << setprecision(9)<<fixed;



typedef long long int ll;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<pii> vii;

typedef pair<ll,ll> pll;



const int INF = 0x3f3f3f3f;

const ll llINF = (long long)(1e18) + 100;   

const int MAXN = 100100;

const int MAXM = 1001000;

const ll mod=1e9+7;

const int LMAXN = 25;

ll n, k;

vector<pll> v;



int main(){

	fastio;

	cin>>n>>k;



	ll a, b;

	fr(i, n){

		cin>>a>>b;

		v.pb({a, b});

	}

	

	sort(all(v));



	ll pos = 0;



	fr(i,n){

		if (pos <= k and k <= pos + v[i].snd){

			cout<<v[i].fst<<endl;

			return 0;

		}

		pos += v[i].snd;

	}



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

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

typedef long long ll;

const int mmax=1e5+10;

map<ll,ll> s;

ll book[mmax],num[mmax];

int main()

{

	ll n,k;

	while(cin>>n>>k)

	{

		memset(book,0,sizeof(book));

		memset(num,0,sizeof(num));

		s.clear();

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

		{

			ll a,b;

			cin>>a>>b;

			s[a]+=b;

			num[i]=a;

		}

		ll sum=0;

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

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

		{

			if(num[i]!=num[i-1])

				book[i]=num[i];

		}

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

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

		{



			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

				if(sum>k||sum==k)

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 


// Faster C++ solution for the same problem (measured speedup: 1.600556115058318x):
// cities to vapori-

// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz

#include <bits/stdc++.h>

#define pb push_back

#define fst first

#define snd second

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

#define fill(x,v) memset(x,v,sizeof(x))

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

#define trace(x) cout << #x << " = " << x << endl

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

typedef long long ll;

typedef pair<int,int> ii;

const int N = 1e5+20;



ll f[N];



int main(){



	fastio;

	ll n,k;

	cin >> n >> k;

	fill(f,0);

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

		int a,b;

		cin >> a >> b;

		f[a] += b;

	}



	int ans;

	for(ans = 1; k > f[ans]; ++ans){

		k -= f[ans];

	}

	cout << ans << endl;



	return 0;

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

using namespace std;

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

#define rep1(i,n) for(ll i=1;i<n+1;i++)

#define sort(A) sort(A.begin(),A.end())

#define reverse(A) reverse(A.begin(),A.end())

typedef long long ll;

typedef pair<ll,ll> P;



int main(){

  ll n,k;

  cin >> n >> k;

  vector<ll> buc(100001);

  rep(i,n){

    ll a,b;

    cin >> a >> b;

    buc[a] += b;

  }

  vector<ll> sum(100001);

  rep(i,100001){

    if(i == 0) sum[i] = buc[i];

    else sum[i] = sum[i-1] + buc[i];

  }

  auto Iter =  lower_bound(sum.begin(),sum.end(),k);

  cout << Iter - sum.begin() << endl;

}

// Faster C++ solution for the same problem (measured speedup: 2.8138724469855245x):
#include <iostream> // cout, endl, cin

#include <string> // string, to_string, stoi

#include <vector> // vector

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound

#include <utility> // pair, make_pair

#include <tuple> // tuple, make_tuple

#include <cstdint> // int64_t, int*_t

#include <cstdio> // printf

#include <map> // map

#include <queue> // queue, priority_queue

#include <set> // set

#include <stack> // stack

#include <deque> // deque

#include <unordered_map> // unordered_map

#include <unordered_set> // unordered_set

#include <bitset> // bitset

#include <cctype> // isupper, islower, isdigit, toupper, tolower

#include<math.h>

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

using namespace std;

using ll = long long;

const ll INF = 100100100100100;



int main() {

	ll N, K;

	cin >> N >> K;//左から k個

    vector<pair<ll,ll>> p(N);

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

        int a,b;

        cin >> a >> b;

        p[i] = {a,b};

    }

    sort(p.begin(),p.end());

	ll cnt = 0;

	ll ans = 0;

	while (K) {//Kからb[cnt]を引いていき、0を下回ったらストップ

		if (p[cnt].second >= K) {

			ans = cnt;

			K = 0;

		}

		else {

			K -= p[cnt].second;

			cnt++;

		}

	}

	cout << p[ans].first << endl;

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

using namespace std;

#define N 100000

int main() {

	int n;

	long long int k;

	cin>>n>>k;

	long long int hoge[N]={};

	int a,b;

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

		

		cin>>a>>b;

		hoge[a-1]+=b;

	}

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

 		k=k-hoge[i];

 		if(k<=0){

 			cout<<i+1<<endl;

 			break;

 		}

 	}

	return 0;

}

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

using namespace std;

const int MOD = 1e9 + 7;

typedef long long lint;

const int INF =1e7;

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

#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)

typedef pair<int,int> P;

typedef vector<int> vi;

typedef vector<vi> vvi;

lint cc[100005]={0};

int main()

{

    int n;

    cin>>n;

    lint k;

    cin >> k;

    rep(i, n)

    {

        int a,b;

        cin >> a>>b;

        cc[a] += b;

    }

    int i = 0;

    while (k > cc[i])

    {

        k -= cc[i];

        i++;

    }

    cout << i << endl;

    return 0;

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

#include <cstdio>

#include <algorithm>

using namespace std;

int main(){

    int n;

    long long int k;

    cin>>n>>k;

    long long int d[100001]={};//個数

    long long int s[100001]={};//累積和

    int a;

    int b;

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

        cin>>a>>b;

        d[a]+=b;

    }

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

        s[i]=s[i-1]+d[i];

        if(k<=s[i]){

            cout<<i<<endl;

            return 0;

        }

    }



    return 0;



}

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

using namespace std;

const int MOD = 1e9 + 7;

typedef long long lint;

const int INF =1e7;

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

#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)

typedef pair<int,int> P;

typedef vector<int> vi;

typedef vector<vi> vvi;

lint cc[100005]={0};

int main()

{

    int n;

    cin>>n;

    lint k;

    cin >> k;

    rep(i, n)

    {

        int a,b;

        cin >> a>>b;

        cc[a] += b;

    }

    int i = 0;

    while (k > cc[i])

    {

        k -= cc[i];

        i++;

    }

    cout << i << endl;

    return 0;

}