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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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

#define ll long long



using namespace std;



int main()

{

    ll n,k,i,j,a,b,ans=0;

    cin>>n>>k;

    vector<pair<ll, ll > >v;

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

    {

        cin>>a>>b;

        v.push_back({a,b});



    }

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

    j=v.size();

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

    {

        ans+=v[i].second;

        if(ans>=k)

        {

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

            break;

        }

    }

    return 0;

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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

using namespace std;

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

#define ll long long

#define ld long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define pld pair<ld,ld>

const int MAXN = 1e5+7;

pll aux[MAXN], sm[MAXN];

int main(){

    fastio;

    int n; ll k; cin>>n>>k;

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

        int ai,bi; cin>>ai>>bi;

        aux[i] = {ai, bi};

    }

    sort(aux, aux+n);

    ll cur = 0;

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

        cur += aux[i].second;

        sm[i] = {aux[i].first, cur};

    }

    int bl=0, br=n-1;

    while(bl != br){

        int bm = (bl+br)/2;

        if(sm[bm].second < k)bl = bm+1;

        else br = bm;

    }

    cout<<sm[bl].first<<endl;

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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



using namespace std;



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

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

#define frm(i, n) for(ll i = n-1; i >= 0; i--)



#define pb push_back

#define f first

#define s second



typedef long long ll;

typedef pair<ll,ll> pii;

typedef pair<double, double> ponto;

typedef vector<vector<ll>> matrix;



#define mem(v, k) memset(v, k, sizeof(v));



#define db cout << "Debug" << endl;



#define mp make_pair

#define pq priority_queue



#define mx(a, b) a = max(a, b);

#define mod(a, b) a = a%b;



#define MAXN 100010

#define MOD 1000000007

#define MAXL 30

#define ROOT 1

#define INF 987654321



ll fr[MAXN];



int main(){

	ios::sync_with_stdio(false);

	ll n, k;

	cin >> n >> k;

	fr(i, n){

		ll a, b;

		cin >> a >> b;

		fr[a]+=b;

	}



	ll ind = 0;

	

	while(k > 0){

		ind++;

		k-=fr[ind];

	}



	cout << ind << endl;

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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



using namespace std;



int main() {



    long long n, k, x, y, cont=0;

    

    vector<pair<long long, long long>> v;

    

    cin >> n >> k;

    

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

        cin >> x >> y;

        v.push_back(make_pair(x, y));

        

    }

    

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

    

    long long i=0;

    cont = v[i].second;

    while(cont < k) {

        cont += v[++i].second;

    }

    

    cout << v[i].first << "\n";



    return 0;



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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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

using namespace std;



vector<pair<int, int> > v;



int main() {

	int n; long long k; scanf("%d %lld", &n, &k);

	while (n--) {

		int a, b; scanf("%d %d", &a, &b);

		v.push_back({a, b});

	}

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

	for (int i = 0; i < v.size(); i++) {

		k -= (long long)v[i].second;

		if (k <= 0ll) {

			printf("%d\n", v[i].first);

			break;

		}

	}

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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

using namespace std;



vector<int> as;

map<int,long long int> bs;



int main(){

	

	int n;

	long long int k;

	cin >> n >> k;

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

	{

		int a;

		long long b;

		cin >> a >> b;

		if(bs[a]==0){

			bs[a]=b;

			as.push_back(a);}

		else{

			bs[a]+=b;

		}

	}



	sort(as.begin(),as.begin()+as.size());

	long long int cont=0;

	int i=0,salvar=as[0];

	while(cont<k){

		cont+=bs[as[i]];

		salvar=as[i];

		i+=1;

	}

	cout << salvar;

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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

#define MAX 112345

using namespace std;



long long pos[MAX];



int main(){

    long long n, k, a, b, actual = 0;

    cin >> n >> k;

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

        cin >> a >> b;

        pos[a] += b;

    }



    for(long long i = 1; i <= 100000; i++){

        actual += pos[i];

        if(k <= actual){

            cout << i << endl;

            i = MAX;

        }

    }





    return 0;

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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



using namespace std;



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

#define endl '\n'

#define f first

#define s second

#define pb push_back



typedef long long ll;

typedef pair<int, int> ii;



const int INF = 0x3f3f3f3f;

const ll LINF = 0x3f3f3f3f3f3f3f3fll;



int main() { _

	int n; cin >> n;

	ll k; cin >> k;

	vector<ii> v;

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

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

		v.pb({a, b});

	}

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

	vector<ll> pref(n);

	pref[0] = v[0].s;

	for (int i = 1; i < n; i++) pref[i] = pref[i-1]+v[i].s;

	int l = 0, r = n-1;

	while (l < r) {

		int m = (l+r)/2;

		if (pref[m] >= k) r = m;

		else l = m+1;

	}

	cout << v[l].f << endl;

	exit(0);

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.0798452489833936x):
#define MOD 1000000007;

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

#define  ll long long



#include <bits/stdc++.h>



using namespace std;

const int N = 2e1 + 5;



int main() {



    ll  n,k;

    cin>>n>>k;

    vector<pair<int,int>> vec;

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

    {

        int a,b;

        cin>>a>>b;

        vec.push_back({a,b});

    }

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





    int ans;

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

    {

        if(vec[i].second>=k)

        {ans=vec[i].first;

            break;}

        else

            k-=vec[i].second;



    }

    cout<<ans;



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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

	while(scanf("%d%lld",&n,&m)!=EOF)

	{

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

			a[i]=0;

		while(n--)

		{

			scanf("%d%d",&i,&j);

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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

using namespace std;

typedef long long ll;

typedef pair<int,int> ii;

vector<ii>wq;

int main()

{

    int g,t,z,x,re;

    ll q,lm=0;

    scanf("%d %lld",&t,&q);

    for(g=0;g<t;g++){

        scanf("%d %d",&z,&x);

        wq.push_back(ii(z,x));

    }

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

    for(g=0;g<t;g++){

        lm+=wq[g].second;

        if(lm>=q){

            re=wq[g].first;

            break;

        }

    }

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

    return 0;

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

#include <string>

#include <algorithm>

#include <queue>

#include <stack>

#include <map>

#include <vector>

#include <cstdio>

#include <cmath>

#include <cctype>

#define INF 1000000000

using namespace std;

bool debug=false;



int main(){

  long long n,k;

  long long x[100005]={0};

  cin>>n>>k;

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

    int a,b;

    cin>>a>>b;

    x[a]+=b;

  }

  long long sum=0;

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

    sum+=x[i];

    if(k<=sum){

      cout<<i<<endl;

      break;

    }

  }

  return 0;

}


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

#include <algorithm>

#include <string>

#include <vector>

#include <stack>

#include <queue>

#include <set>

#include <bitset>

#include <map>

#include <tuple>

#include <unordered_map>

#include <list>

#include <numeric>

#include <utility>

#include <iterator>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <cstring>

#include <climits>

#include <ctime>

#include <cassert>



#define INF 1000000000

#define LINF 9000000000000000000

#define mod 1000000007



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

#define rrep(i,n) for(int i=n-1;i>=0;i--)

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

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

#define pb push_back

#define mp make_pair



using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef vector<long long>vll;

typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};

int dy[4]={0,1,0,-1};

int ddx[8]={-1,-1,0,1,1,1,0,-1};

int ddy[8]={0,1,1,1,0,-1,-1,-1};

bool debug=false;



/*---------------------------------------------------*/



int main(){

  ll n,k;

  cin>>n>>k;



  vector<pair<ll,ll> > vp;

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

    int a,b;

    cin>>a>>b;

    vp.push_back(mp(a,b));

  }

  sort(all(vp));



  ll cnt=0;

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

    if(cnt<=k&&k<=cnt+vp[i].second){

      cout<<vp[i].first<<endl;

      return 0;

    }

    cnt+=vp[i].second;

  }

  return 0;

}
// Slower C++ solution:
//061 C - Big Array 2017/05/13



#include <bits/stdc++.h>

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

using namespace std;

typedef long long int int64;

typedef unsigned long long uint64;



int main(){

    int64 n , k; cin >> n >> k;

    int64 num[100001]={0};

    rep(i ,n){

        int a , b;

        cin >> a >> b;

        num[a]+=b;

    }

    rep(i , 1000001){

        if(k <= num[i]){

            cout << i << endl;

            break;

        }

        k -=num[i];

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.8025576816077131x):
//061 C - Big Array 2017/05/13



#include <bits/stdc++.h>

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

using namespace std;

typedef long long int int64;

typedef unsigned long long uint64;



/*

int main(){

    int64 n , k; cin >> n >> k;

    int64 num[100001]={0};

    rep(i ,n){

        int a , b;

        cin >> a >> b;

        num[a]+=b;

    }

    rep(i , 1000001){

        if(k <= num[i]){

            cout << i << endl;

            break;

        }

        k -=num[i];

    }

}

*/

int main(){

    int64 n , k; cin >> n >> k;

    vector<pair<int,int>> p(n);

    rep(i , n) cin >> p[i].first >> p[i].second;

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

    int64 sum=0;int64 i=0;

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

        sum+=p[i].second;

        if(sum >= k) break;

    }

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

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

using namespace std;

int main(){

  long long n,k,x=0;

  cin >> n >> k;

  int a[n],b[n];

  pair<int,int> p[1000000];

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

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

    p[i]=make_pair(a[i],b[i]);

  }

  sort(p,p+n);

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

    x+=p[i].second;

    if(x>=k){

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

      return 0;

    }

  }

}


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

using namespace std;

int main(){

  long long n,k,x=0;

  cin >> n >> k;

  long long a[n],b[n];

  pair<long long,long long> p[n];

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

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

    p[i]=make_pair(a[i],b[i]);

  }

  sort(p,p+n);

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

    x+=p[i].second;

    if(x>=k){

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

      return 0;

    }

  }

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

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

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

#define int long long

using namespace std;

typedef vector<int>   vint;

typedef pair<int,int> pint;



signed main()

{

    int N,K; cin>>N>>K;

    vint cnt(110000,0);

    REP(i,N){

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

        cnt[a]+=b;

    }

    

    int cur=0;

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

        cur+=cnt[i];

        if(cur>=K){

            cout<<i<<endl;

            return 0;

        }

    }

}


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

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

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

#define int long long

using namespace std;

typedef vector<int>   vint;

typedef pair<int,int> pint;



int cnt[100010];



signed main()

{

    int N,K; cin>>N>>K;

    REP(i,N){

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

        cnt[a]+=b;

    }



    int sum=0;

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

        sum+=cnt[i];

        if(sum>=K){

            cout<<i<<endl;

            return 0;

        }

    }

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

#include <string>

#include <algorithm>

#include <vector>

#include <climits>

#include <sstream>



using namespace std;



const int MAX = 100000;



int main(){

	int N;

	long long K, cnt[MAX+1] = {0};



	cin >> N >> K;



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

		int a, b;

		cin >> a >> b;

		cnt[a] += b;

	}



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

		if(K <= cnt[i]){

			cout << i << endl;

			break;

		}

		K -=cnt[i];

	}



	return 0;

}

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



using namespace std;



typedef long long llint;

typedef pair<llint, llint> P;



llint v[101010];



int main() {

  llint n, k;

  cin >> n >> k;

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

    llint a, b;

    cin >> a >> b;

    v[a] += b;

  }

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

    if (k <= v[i]) {

      cout << i << endl;

      break;

    }

    k -= v[i];

  }



  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;

			//cout<<s[a]<<endl;

			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++)

//			cout<<book[i]<<endl;

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

//			cout<<s[book[i]]<<endl;

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

		{

			//cout<<book[i]<<endl;

			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

			//	cout<<sum<<endl;

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

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 

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

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <set>

#include <iomanip>

#include <vector>

#include <queue>

#include <map>

#include <numeric>

//#include <bits/stdc++.h>



using namespace std;

const int INF = 1 << 30;

struct P

{

    int x;

    int y;

};



bool cmp(P a ,P b)

{

    return a.x<b.x;

}



int main()

{

    ios::sync_with_stdio(false);

    long long n,m;

    cin>>n>>m;

    P p[n];

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

    {

        int a,b;

        cin>>a>>b;

        p[i].x=a;

        p[i].y=b;

    }

    sort(p,p+n,cmp);

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

    {

        if(p[i].y>=m)

        {    

            cout<<p[i].x<<endl;

            return 0;

        }

        else

            m-=p[i].y;

    }

    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;

			//cout<<s[a]<<endl;

			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++)

//			cout<<book[i]<<endl;

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

//			cout<<s[book[i]]<<endl;

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

		{

			//cout<<book[i]<<endl;

			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

			//	cout<<sum<<endl;

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

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 

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

#include<string.h>

#include<cstdio>

#include<algorithm>

using namespace std;



struct point{

   int a, cnt;

};



int cmp(point p1, point p2){

    return p1.a < p2.a;

}

int main(){



   long long  n, k;

   while(cin >> n >>k){

     point p[100001];

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

          cin >>p[i].a >> p[i].cnt;

      }

      sort(p, p + n, cmp);

      int d=0;

      //for(int i = 0; i < n; ++i) cout <<p[i].a <<"  "<<p[i].cnt<<endl;

      for(long long i = k; i > 0; ){

         i -= p[d++].cnt;

      }

      cout << p[d-1].a <<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;

			//cout<<s[a]<<endl;

			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++)

//			cout<<book[i]<<endl;

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

//			cout<<s[book[i]]<<endl;

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

		{

			//cout<<book[i]<<endl;

			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

			//	cout<<sum<<endl;

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

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 

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

#include <bitset>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <cctype>

#include <queue>

#include <string.h> 

using namespace std;



const int M = 1e5+10;

struct ac

{

	long long p,q;

}a[M];

bool cmpm(const ac k,const ac l)

{

	return k.p<l.p;

}

int main()

{

	long long m,n,i;

	cin>>m>>n;

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

	{

		cin>>a[i].p>>a[i].q;

	}

	sort(a,a+m,cmpm);

	long long sum=0;

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

	{

		sum+=a[i].q;

		if(sum>=n)

		{

			cout<<a[i].p<<endl;

			break;

		}

	}

	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;

			//cout<<s[a]<<endl;

			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++)

//			cout<<book[i]<<endl;

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

//			cout<<s[book[i]]<<endl;

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

		{

			//cout<<book[i]<<endl;

			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

			//	cout<<sum<<endl;

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

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 

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

#include <algorithm>

using namespace std;



typedef long long ll;



struct st

{

    ll num;

    ll cnt;

};



bool cmp(struct st &a,struct st &b)

{

    return a.num < b.num;

}





const int N = 1e5+10;



st s[N];



int main()

{

    ll n,k;

    ll a,b;

    cin >> n >> k;



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

    {

        cin >> a >> b;

        s[i].num = a;

        s[i].cnt = b;

    }



    sort(s,s+n,cmp);



    ll sum = 0;

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

    {

        sum += s[i].cnt;

        if(k <= sum)

        {

            cout << s[i].num << endl;

            return 0;

        }

    }



    return 0;

}