stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <algorithm>

using namespace std;

struct Node

{

	long long x;

	long long num;

}nn[100005];

bool cmp(Node a,Node b)

{

	return a.x<b.x;

}

int main()

{

	long long n,k;

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

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

	{

		scanf("%lld%lld",&nn[i].x,&nn[i].num);

	}

	sort(nn,nn+n,cmp);

	long long sum=0;

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

	{

		sum+=nn[i].num;

		if(sum>=k)

		{

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

			return 0;

		} 

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

int inc(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

	qsort(num,n,sizeof(struct node),inc);

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/* BISMILLAHIR RAHMANIR RAHIM */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int mxn = 1e5 + 5;

ll f[mxn];



int main() {

	ios_base :: sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	ll n, k;

	cin >> n >> k;

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

		cin >> a >> b;

		f[a] += b;

	}

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

		if( k >= f[i] ) {

			k -= f[i];

		}

		else {

			k = 0;

		}

		if( k == 0 ) {

			cout << i << "\n";

			break;

		}

	}

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

int inc(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

	qsort(num,n,sizeof(struct node),inc);

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


////////////////////////// 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;

            }

        }

    }

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

        }

    }

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
// 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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
    #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;

    }

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

 } 


// Optimized solution to the same problem (faster):
//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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
//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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem: