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

using namespace std;



    map<int,int>mp;

int main()

{

set<int>s;

set<int>::iterator it;

   long long  int n,k,a,b,mx,sum=0,f=0,d;

    cin>>n>>k;

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

    {cin>>a>>b;

    s.insert(a);

    mp[a]+=b;



    }

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

{

    d=*it;

    sum+=mp[d];

    if(sum>=k){break;}

}

cout<<d<<endl;

}


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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

  scanf("%d %lld", &N, &K);



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

}
// Slower C++ solution:


////////////////////////// Author

////////////////////////// Nasim Hossain Rabbi

////////////////////////// JU-CSE28

////////////////////////// CF - imnasim3.1415

////////////////////////// UVA - imnasim3.1415

////////////////////////// Mail - imnasim3.1415@gmail.com

#include<bits/stdc++.h>

using namespace std;

#define sz size()

#define mk make_pair

#define clr clear()

#define B begin()

#define E end()

#define EM empty()

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

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

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

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

#define pb push_back

#define endl '\n'

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

#define pi 3.1415926535897932384626433832795

#define vi vector<int>

#define vl vector<long long>

#define vs vector<string>

#define vp(vi,x) cin>>x; vi.pb(x);

typedef long long LL;

typedef unsigned long long ULL;

template<typename T>

 T gcd(T a,T b)

{

    return b==0?a:gcd(b,a%b);

}

template<typename T>

 T lcm(T a,T b)

{

    LL g=gcd(a,b);

    return (a/g)*b;

}

int main()

{

    fast;

    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;

    vector< pair <LL,LL > > a;

    while(cin>>n>>m)

    {

        c=0;

        bool f=1;

        rep(k,n)

        {

            cin>>i>>j;

            a.pb({i,j});

        }

        sort(all(a));

        rep(k,n)

        {

            c+=a[k].second;

            if(c>=m)

            {

                cout<<a[k].first<<endl;

                break;

            }

        }

    }

}


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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

  scanf("%d %lld", &N, &K);



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

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

using namespace std;

using ll = int64_t;



int main() 

{

    int n;

    ll k;

    cin >> n >> k;

    vector<pair<int, ll>> x(n);

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

        cin >> x[i].first >> x[i].second;

    sort(begin(x), end(x));



    int i = 0;

    while (i < n && k > 0ll) {

        if (k > x[i].second) {

            k -= x[i].second;

            i++;

        }

        else {

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

            break;

        }

    }

}


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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

  scanf("%d %lld", &N, &K);



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

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

using namespace std;



int main(){

	

	int n;

	long long k;

	cin >> n >> k;

	

	vector<long long> v(101010);

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

		int x;

		long long f;

		cin >> x >> f;

		v[x] += f;

	}

	

	long long s = 0;

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

		s += v[i];

		if(s >= k){

			cout << i << "\n";

			break;

		}

	}

	

	return 0;

}

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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

  scanf("%d %lld", &N, &K);



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

}
// Slower C++ solution:
//When I was writing this, only God and I knew what it is

//Now, only The_Blitz know...



#pragma GCC optimize ("Ofast,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

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

#define pb push_back

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

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

#define ff first

#define ss second

typedef long long ll;

typedef pair<int, int> ii;



const int N = 1e5 + 2;

const int Mod = 1e9 + 7;



map<ll, ll> m;



int main(){

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

	FER(i, 0, n){

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

		m[a] += b;

	}

	ll acc = 0;

	for(auto x: m){

		if(acc + x.ss >= k){

			cout << x.ff << endl;

			break;

		}

		acc += x.ss;

	}

	return 0;

}


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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

  scanf("%d %lld", &N, &K);



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

}
// Slower C++ solution:
// I look at my watch

// it say nine twenty-five

// And I think oh God

// I'm still alive !

 

#include <bits/stdc++.h>

#define ff first

#define ss second

#define pb push_back

#define mp make_pair

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

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

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

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

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

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

using namespace std;

 

typedef long long ll;

typedef pair<int,int> ii;

typedef long double ld;









int main(){	

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

	ll ini=1;

	ll ans=-1;

	vector<ii>vec(n);

	For(i,0,n){

		ll val,c;cin>>val>>c;

		vec[i]={val,c};

	}

	sort(all(vec));

	For(i,0,n){

		ll val=vec[i].ff,c=vec[i].ss;

		ll l=ini,r=ini+c;

		if(l<=k&&k<r){

			ans=val;

			break;

		}

		ini=r;

	}

	cout<<ans<<endl;

	

	return 0;

}


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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

  scanf("%d %lld", &N, &K);



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

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

using namespace std;



#define nl "\n"

#define db(a) cout << (#a) << " = " << (a) << endl

#define ll long long

#define MOD 1000000007



int mod(int a, int b) {return a >= 0 ? a % b : (b + a % b) % b;}

int dceil(int a, int b) {return (a + b - 1) / b;}

/***********************************/



#define N -1



int main() {

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	/*******************************/

	ll n, k;

	cin >> n >> k;

	vector<pair<ll, ll>> cps;

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

		ll a, b;

		cin >> a >> b;

		cps.push_back({a, b});

	}

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

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

		if (cps[i].second >= k) {

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

			break;

		}

		k -= cps[i].second;

	}

	return 0;

}

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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

  scanf("%d %lld", &N, &K);



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

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

#include <algorithm>

using namespace std;

typedef pair<int,int> P;

int main(void){

  int n,i;

  long k;

  P u[100010];

  cin >> n >> k;

  for (i=0;i<n;i++) cin >> u[i].first >> u[i].second;

  sort(u,u+n);

  i=0;

  while (k>0){

    k-=u[i].second;

    i++;

  }

  cout << u[i-1].first << endl;

  return 0;

}

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

#include <algorithm>

#include <vector>

using namespace std;

typedef long long ll;

typedef pair<int,int> P;





int main(void){

  int n,i,a,b;

  ll k;

  vector<P> op;

  

  cin >> n >> k;

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

    cin >> a >> b;

    op.push_back(P(a,b));

  }

  

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

  

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

    if (k<=op[i].second) break;

    k-=op[i].second;

  }

  

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

  

  return 0;

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

    #include <cstdio>

    #include <algorithm>

    using namespace std;

    struct num

    {

        int x;

        int sum;

    };

    num nums[100000+10];

    bool cmp(const num& a,const num& b)

    {

        if(a.x!=b.x)

        return a.x<b.x;

        else

        return a.sum>b.sum;

    }

    int main()

    {

        unsigned long long int n,k;

        cin>>n>>k;

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

        {

            scanf("%d%d",&nums[i].x,&nums[i].sum);

        }

        sort(nums,nums+n,cmp);

        unsigned long long int  add=0;

        unsigned long long int  res=0;

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

        {

            res+=nums[i].sum;

            if(res>=k)

            {

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

                break;

            }

            else

            add=res;

        }

        return 0;

    }

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

#include <algorithm>



using namespace std;



#define N 110000



typedef long long ll;



struct Node {

    int a, b;

    bool operator < (const Node &u) const {

        return a < u.a;

    }

};



Node a[N];



int main() {

    int n; ll k;

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

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

        sort(a, a +n);

        ll sum = 0;

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

            if (k <= sum + a[i].b) { printf("%d\n", a[i].a); break; }

            else sum += a[i].b;

        }

    }

    return 0;

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



using namespace std;



#define fst(t) std::get<0>(t)

#define snd(t) std::get<1>(t)

#define thd(t) std::get<2>(t)



using ll = long long;

using P = std::tuple<int,int>;



const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};



ll cnt[100100];



int main(){

    std::cin.tie(nullptr);

    std::ios::sync_with_stdio(false);



    int N;

    ll K;

    std::cin >> N >> K;



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

        int a, b;

        std::cin >> a >> b;



        cnt[a] += b;

    }



    // for(int i=0;i<10;++i){

    //     std::cout << i << ", " << cnt[i] << std::endl;

    // }



    int i = 0;

    ll sum = 0;

    while(cnt[i] + sum < K){sum += cnt[i]; i++;}



    std::cout << i << std::endl;

}


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

#include <algorithm>



using namespace std;



#define N 110000



typedef long long ll;



struct Node {

    int a, b;

    bool operator < (const Node &u) const {

        return a < u.a;

    }

};



Node a[N];



int main() {

    int n; ll k;

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

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

        sort(a, a +n);

        ll sum = 0;

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

            if (k <= sum + a[i].b) { printf("%d\n", a[i].a); break; }

            else sum += a[i].b;

        }

    }

    return 0;

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



using namespace std;



#define MXN 100005



typedef pair<int,int> PII;



int a[MXN], b[MXN];

vector<PII> v;



int main() { 

    long long int n, k;

    cin >> n >> k;

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

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

        v.push_back(make_pair(a[i], b[i]));

    }

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

    long long int cur = 0;

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

        cur += v[i].second;

        if (cur >= k) {

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

            break;

        }

    }



    return 0;

}


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

#include <algorithm>



using namespace std;



#define N 110000



typedef long long ll;



struct Node {

    int a, b;

    bool operator < (const Node &u) const {

        return a < u.a;

    }

};



Node a[N];



int main() {

    int n; ll k;

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

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

        sort(a, a +n);

        ll sum = 0;

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

            if (k <= sum + a[i].b) { printf("%d\n", a[i].a); break; }

            else sum += a[i].b;

        }

    }

    return 0;

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

#include <cmath>



#include <algorithm>

#include <iostream>

#include <vector>

#include <list>

#include <tuple>

#include <string>



using namespace std;



#define MAX(A, B)	((A) > (B) ? (A) : (B))

#define MIN(A, B)	((A) < (B) ? (A) : (B))



int main(int argc, char const *argv[]) {

	int64_t n, k;

	cin >> n >> k;



	vector<tuple<int64_t, int64_t>> v;



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

		int64_t a, b;

		cin >> a >> b;

		v.push_back(make_tuple(a, b));

	}



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



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

		int a = get<0>(v[i]), b = get<1>(v[i]);

		k -= b;

		if (k <= 0) {

			cout << a << endl;

			return 0;

		}

	}



	return 0;

}

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

#include <algorithm>



using namespace std;



#define N 110000



typedef long long ll;



struct Node {

    int a, b;

    bool operator < (const Node &u) const {

        return a < u.a;

    }

};



Node a[N];



int main() {

    int n; ll k;

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

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

        sort(a, a +n);

        ll sum = 0;

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

            if (k <= sum + a[i].b) { printf("%d\n", a[i].a); break; }

            else sum += a[i].b;

        }

    }

    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.914204454679164x):
#include<iostream>

#include<algorithm>

#include<utility>

using namespace std;

typedef long long ll;

const ll N=1e5+9;

pair<ll,ll> p[N];

int main()

{

	ll n,m,a,b;

	cin>>n>>m;

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

	{

		cin>>a>>b;

		p[i].first=a;

		p[i].second=b;

	}

	sort(p,p+n);

	ll sum=0;

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

	{

		sum+=p[i].second;

		if(sum>=m)

		{

			cout<<p[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;

			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.9031354468310084x):
#include <iostream>

#include <map>;



using namespace std;



map <int,long long> ans;



int main(){

    int n;

    long long k;

    cin>>n>>k;

    while (n--){

        int a,b;

        cin>>a>>b;

        ans[a]+=b;

    }

    map <int,long long> ::iterator it;

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

        k-=it->second;

        if (k<=0){

            cout<<it->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.8069812926266944x):
#include<iostream>

#include<map>

#include<set>

#include<list>

#include<queue>

#include<cmath>

#include<string>

#include<string.h>

#include<iomanip>

#include<stdlib.h>

#include<algorithm>

typedef long long ll;

using namespace std;



struct p{

	ll x;

	ll y;

};



bool cmp(p p1,p p2)

{

	return p1.x < p2.x ; 

}



int main()

{

	ll n,k,sum = 0;

	p ps[100010];

	cin >> n >> k;

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

	{

		cin >> ps[i].x >> ps[i].y ;

	}

	sort(ps,ps+n,cmp);

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

	{

		sum += ps[i].y;

		if(sum >= k)

		{

			cout << ps[i].x << 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;

			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.810398303347968x):
#include <iostream>

#include <cmath>

#include <string.h>

#include <cstdio>

#include <algorithm>

using namespace std;

struct stu{

    long long ge;

    long long shu;

};

bool com(struct stu a,struct stu b){

    return a.shu < b.shu;

}

int main(){

    long long a,b,c,i,n;

    struct stu z[100000];

    cin>>a>>b;

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

        cin>>z[i].shu>>z[i].ge;

    }

    sort(z,z+a,com);

    c = 0;

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

        c = c +z[i].ge;

        if(c >= b){

            cout<<z[i].shu;

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

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

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

#define sl(n) scanf("%lld", &n);

#define si(n) scanf("%d", &n);

#define RepAll(a) for(auto x: a)

#define cout(ans) cout << ans << endl;

typedef long long ll;

ll ans[100050];

using namespace std;

int main()

{

    ll n, k, a, b;

    //vector<int> ans;

    sl(n);

    sl(k);

    while(n--){

        cin >> a >> b;

        ans[a] += b;

    }

    int i = 1;

    while(k > 0){

        k -= ans[i];

        ++i;

    }

    cout << i-1 << 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: 1.4957499707879547x):
#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;

}