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;

			//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.952452709283393x):
#include <stdio.h>

#include <string.h>

#include <algorithm>

#include <iostream>

#include <math.h>

#include <vector>

#include <map>

#define int long long

#define inf 0x3f3f3f3f

using namespace std;

const int maxn = 1e5 + 5;



struct node

{

    int x, y;

}a[maxn];



bool cmp(node b, node c)

{

    return b.x < c.x;

}



signed main()

{

    int n, k;

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

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

        scanf("%lld %lld", &a[i].x, &a[i].y);

    sort(a, a+n, cmp);

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

    {

        if(k>a[i].y)

            k -= a[i].y;

        else

        {

            printf("%lld\n", a[i].x);

            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.8477953390223787x):
#include<bits/stdc++.h>

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define endl "\n"

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

V< pair<LL,LL> >v;

map<LL,LL>u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    string a;

    cin>>n>>m;

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

    {

        cin>>p>>q;

        v.PSB({p,q});

    }

    sort(v.B,v.E);

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

    {

       k+=v[i].SE;

       if(k>=m)

       {

           cout<<v[i].FI<<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.887630316422924x):
#include<iostream>

#include<cstdio>

#include<string>

#include<vector>

#include<queue>

#include<cmath>

#include<algorithm>

#include<iomanip>

#include<functional>

#include<set>

#include<map>

#include<utility>

#define ul unsigned long long int

#define ll long long int

#define MAX 1000000+1

using namespace std;

#define F first

#define S second

#define pi 2*acos(0.0)

#define PB push_back

#define LSTAGE 1







int main()

{



    map<ll,ll> v;

    map<ll,ll> :: iterator it;

    ll n, p;

    cin >> n >> p;

        ll r, t;

    while(n--)

    {

        cin >> r >> t;

        if(v.count(r)==0) v[r] = 0;



        v[r] += t;



    }



  it= v.begin();

  r = it->S;



    while(r<p)

    {

        it++;

//        cout << it->S<< endl;

        r += it->S;

    }

//    if(it!=v.end())

    cout << it->F;



    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.8975406007071505x):
#include <bits/stdc++.h>

using namespace std;

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



bool sortByA(pair<int,int> i, pair<int,int> j) {

    return i.first < j.first;

}



int main() {

    int n, a, b;

    unsigned long long int k, acm;

    vector<pair<int,int>> vector;

    acm = 0;



    cin >> n >> k;





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

        cin >> a >> b;

        vector.push_back(make_pair(a,b));    

    }

    sort(vector.begin(), vector.end(), sortByA);

    

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

        acm += vector[i].second;



        if (acm >= k) {

            cout << vector[i].first << 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.878429182101391x):
#include "bits/stdc++.h"

using namespace std;



#define pb push_back

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

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



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

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

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



#define p(x) cout << x << "\n"

#define pv(x) fr(i, x.size()) cout << x[i] << " \n"[i==x.size()-1]



#define f first

#define s second



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



typedef long long int ll;

typedef long double ld;

typedef pair<int,int> pii;

typedef pair<ll,ll> pll;

typedef vector<int> vi;

typedef vector<ll> vl;



const int INF = 0x3f3f3f3f;

const ll LINF = 0x3f3f3f3f3f3f3f;



int main() {

    fastio;



    ll n, k;

    cin >> n >> k;



    pll v[n];

    fr(i, n) cin >> v[i].f >> v[i].s;

    sort(v, v+n);



    int i = 0;

    while (1) {

        if (k <= v[i].s) {

            p(v[i].f);

            return 0;

        }

        k -= v[i].s;

        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;

			//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.854020971736555x):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define mp make_pair



#define f first

#define s second



typedef long long int ll;

typedef long double ld;



const int INF = 0x3f3f3f3f;

const ll LINF = 0x3f3f3f3f3f3f3f;

const int MOD = 1000000007;



const int MAXN = int(1e5)+99;



ll arr[MAXN];



int main()

{

	ios_base::sync_with_stdio(false); 

	cin.tie(NULL); 

	cout.tie(NULL);

	

	ll N, K;

	cin >> N >> K;

	

	set<int> v;

	

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

	{

		ll A, B;

		cin >> A >> B;

		arr[A] += ll(B);

		v.insert(A);

	}

	

	ll pos = 0;

	for(int l : v){

		pos += arr[l];

		if(pos >= K){

			cout << l << endl;

			break;

		}

	}

}
// 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.8223686496045213x):
#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;



ll v[100100];



int main(){

    fastio;

    ll n, k;

    cin >> n >> k;

    fr(i,n){

        ll a, b;

        cin >> a >> b;

        v[a] += b;

    }

    ll soma = 0;

    frr(i,100100 - 1){

        soma += v[i];

        if(soma >= k){

            cout << i << endl;

            break;

        }

    }

    

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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];



int32_t main() {

    cin>>n>>k;

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

        cin>>x>>y;

        h[x]+=y;

        if(mark[x]==0){

           v1.pb(x);

           mark[x]=1;

        }

    }

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

    ans=h[v1[0]];

    int i=1;

    while(ans<k){

        ans+=h[v1[i]];

        i++;

    }

    cout<<v1[i-1];

    return 0;

}


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

#include<algorithm>

using namespace std;

struct Array

{

	long long num;

	long long count;

};

bool com(struct Array p,struct Array q)

{

	return p.num<q.num;

}

int main()

{

	long long n,k;

	cin>>n>>k;

	struct Array a[100001];	

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

	{

		cin>>a[i].num>>a[i].count;

	}

	sort(a,a+n,com);

	long long sum=0;

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

	{

		sum+=a[i].count;

		if(sum>=k)

		{

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

			break;

		}

	}

	return 0;

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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];



int32_t main() {

    cin>>n>>k;

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

        cin>>x>>y;

        h[x]+=y;

        if(mark[x]==0){

           v1.pb(x);

           mark[x]=1;

        }

    }

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

    ans=h[v1[0]];

    int i=1;

    while(ans<k){

        ans+=h[v1[i]];

        i++;

    }

    cout<<v1[i-1];

    return 0;

}


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



using namespace std;



int main()

{

	long long n, k;

	long long sum = 0;

	multiset< pair<long long, long long> >m;

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

	while(n--)

	{

		long long a, b;

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

		m.insert(make_pair(a, b));	

	}

	for(auto it = m.begin();it!=m.end();it++)

	{

		sum += it->second;

		if(sum >= k)

		{

			cout << it->first << endl;

			break;			

		}

	}	

	return 0;

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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];



int32_t main() {

    cin>>n>>k;

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

        cin>>x>>y;

        h[x]+=y;

        if(mark[x]==0){

           v1.pb(x);

           mark[x]=1;

        }

    }

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

    ans=h[v1[0]];

    int i=1;

    while(ans<k){

        ans+=h[v1[i]];

        i++;

    }

    cout<<v1[i-1];

    return 0;

}


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

#include <algorithm>

#include <cmath>

#include <vector>

#include <string>

#include <iomanip>

#include <string>

#include <sstream>

#include  <list>

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

#define INF 0x3f3f3f3f

using namespace std;

/*

int cmp(shi a,shi b)

{

    return a.x<b.x;

}

long long cmd(long long a, long long  b)

{

    return a > b;

}*/



struct shi{

    long long num;

    long long time;

}ff[1000000];

int cmd(shi a ,shi b){

    return a.num<b.num;

}



int main()

{

    long long n,m;

    cin >>n>>m;

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

        cin >>ff[i].num>>ff[i].time;

    sort(ff,ff+n,cmd);

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

    {

        if(m)

        {

            if(m>=ff[i].time)

            m-=ff[i].time;

            else if(m<ff[i].time)

            {

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

                break;

            }

        }

        if(m==0){

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

            break;

        }



    }

    return 0;



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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];



int32_t main() {

    cin>>n>>k;

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

        cin>>x>>y;

        h[x]+=y;

        if(mark[x]==0){

           v1.pb(x);

           mark[x]=1;

        }

    }

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

    ans=h[v1[0]];

    int i=1;

    while(ans<k){

        ans+=h[v1[i]];

        i++;

    }

    cout<<v1[i-1];

    return 0;

}


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

#include<vector>

#include<cstring>

#include<algorithm>



using namespace std;



struct Array{

	long long a;

	long long b;

};



int main(){

	long long n, k;

	cin >> n >> k;

	Array *p = new Array[n];

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

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

	}

	sort(p, p+n, [](Array n1, Array n2){

		return n1.a<n2.a;

	});

	long long sum = 0;

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

		sum += p[i].b;

		if( sum>=k ) {

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

			break;

		}

	}



    return 0;

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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];



int32_t main() {

    cin>>n>>k;

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

        cin>>x>>y;

        h[x]+=y;

        if(mark[x]==0){

           v1.pb(x);

           mark[x]=1;

        }

    }

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

    ans=h[v1[0]];

    int i=1;

    while(ans<k){

        ans+=h[v1[i]];

        i++;

    }

    cout<<v1[i-1];

    return 0;

}


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

using namespace std;

#define fi           first

#define se           second

#define ll           long long

#define pb           push_back

#define mp           make_pair

#define pll          pair<ll,ll>

#define pii          pair<int,int>

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

#define isWorking()  cout<<"Wroking"<<endl

#define FOR(i,x,y)   for(int i=x; i<y; i++)

#define SORT(x)      sort(x.begin(),x.end())

#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl

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

typedef vector < int > VI;

const ll mod= 1e9+7,INF=1e18,mx= 5e6+5,mn=100;

int testCase=1,cas=0;



int main() {

    Fast_Input



    //cin>>testCase;

    while(testCase--) {

        ll n,k; cin>>n>>k;



        map <ll,ll> Ar;

        map <ll,ll> ::iterator it;



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

            ll a,b; cin>>a>>b;

            Ar[a]+=b;

        }

        ll tmp=0;



        for(it= Ar.begin(); it!=Ar.end(); it++){

            tmp+=it->se;

            if(k<=tmp){

                cout<<it->fi<<endl;

                break;

            }

        }

    }

    return 0;

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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];



int32_t main() {

    cin>>n>>k;

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

        cin>>x>>y;

        h[x]+=y;

        if(mark[x]==0){

           v1.pb(x);

           mark[x]=1;

        }

    }

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

    ans=h[v1[0]];

    int i=1;

    while(ans<k){

        ans+=h[v1[i]];

        i++;

    }

    cout<<v1[i-1];

    return 0;

}


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

using namespace std;

#define ll long long

ll arr[200009];

int main()

{

    ll n,t,m,x,y,i,j,k,maxi = INT_MIN,mini = INT_MAX,flag =0,sum=0;

    map<ll,ll>mp;

    map<ll,ll> :: iterator it;

    cin>>n>>k;

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

    {

        cin>>x>>y;

        mp[x]+=y;

    }

    for(it = mp.begin();it!=mp.end() ;it++)

    {

        sum+=it->second;

        if(sum>=k)

        {

            x=it->first;

            break;

        }

    }

    cout<<x<<endl;

    return 0;



}