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

using namespace std;

#define N 100000

int main() {

	int n;

	long long int k;

	cin>>n>>k;

	long long int hoge[N]={};

	int a,b;

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

		

		cin>>a>>b;

		hoge[a-1]+=b;

	}

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

 		k=k-hoge[i];

 		if(k<=0){

 			cout<<i+1<<endl;

 			break;

 		}

 	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

using namespace std;

const int MOD = 1e9 + 7;

typedef long long lint;

const int INF =1e7;

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

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

typedef pair<int,int> P;

typedef vector<int> vi;

typedef vector<vi> vvi;

lint cc[100005]={0};

int main()

{

    int n;

    cin>>n;

    lint k;

    cin >> k;

    rep(i, n)

    {

        int a,b;

        cin >> a>>b;

        cc[a] += b;

    }

    int i = 0;

    while (k > cc[i])

    {

        k -= cc[i];

        i++;

    }

    cout << i << endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <algorithm>

using namespace std;

int main(){

    int n;

    long long int k;

    cin>>n>>k;

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

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

    int a;

    int b;

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

        cin>>a>>b;

        d[a]+=b;

    }

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

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

        if(k<=s[i]){

            cout<<i<<endl;

            return 0;

        }

    }



    return 0;



}

// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

using namespace std;

const int MOD = 1e9 + 7;

typedef long long lint;

const int INF =1e7;

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

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

typedef pair<int,int> P;

typedef vector<int> vi;

typedef vector<vi> vvi;

lint cc[100005]={0};

int main()

{

    int n;

    cin>>n;

    lint k;

    cin >> k;

    rep(i, n)

    {

        int a,b;

        cin >> a>>b;

        cc[a] += b;

    }

    int i = 0;

    while (k > cc[i])

    {

        k -= cc[i];

        i++;

    }

    cout << i << endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

  int n;cin >> n;

  ll k;cin >> k;

  vector<ll> c(100005);

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

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

    c[a]+=b;

  }

  ll sum=0;

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

    sum+=c[i];

    if(sum>=k){

      cout << i << endl;

      return 0;

    }

  }

}

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

using namespace std;

typedef long long ll;

typedef long double ld;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=1LL<<60;

const int inf=1<<30;

const int mod=1e9+7;

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

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

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

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

    vector<pair<ll,ll>> p;

    rep(i,n){

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

        p.push_back({a,b});

    }

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

    rep(i,p.size()){

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

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

            return 0;

        }

        k-=p[i].second;

    }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <utility>



using namespace std;



typedef long long ll;

typedef pair<ll, ll> P;



int main() {

	ll n, k;

	P a[100000];

	cin >> n >> k;

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

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

	}

	sort(a, a + n);

	ll j = 0, sum = a[0].second;

	while (sum < k) {

		j++;

		sum += a[j].second;

	}

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

	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <algorithm>

#include <string>

#include <cmath>

#include <vector>

#include <functional>

#include <stack>

#include <utility>

#include <map>

#include <queue>

#include <set>



using namespace std;



typedef long long ll;

typedef pair<ll, ll> P;



const ll MOD = 1000000007;

const ll INF = 99999999;



ll n, m, a[100001]{};



int main() {

	

	cin >> n >> m;

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

		ll s, t;

		cin >> s >> t;

		a[s] += t;

	}

	ll sum = 0, j = 0;

	while (sum < m) {

		j++;

		sum += a[j];

	}

	cout << j << endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main() {

    int n;

    long long k;

    cin >> n >> k;

    long long num[100001] = {0};

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

        int a, b;

        cin >> a >> b;

        num[a] += b;

    }

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

        if (k <= num[i]) {

            cout << i << endl;

            break;

        }

        k -= num[i];

    }

}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<algorithm>

using namespace std;

typedef pair<int, int> P;

#define N 100000

int main() {

    int n;

    long long k;

    cin >> n >> k;

    int a[n], b[n];

    P p[n];

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

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

        p[i] = {a[i], b[i]};

    }

    sort(p, p + n);

    long long sum = 0;

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

        sum += p[i].second;

        if (sum >= k) {

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

            return 0;

        }

    }

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main() {

    int n;

    long long k;

    cin >> n >> k;

    long long num[100001] = {0};

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

        int a, b;

        cin >> a >> b;

        num[a] += b;

    }

    long long tmp = 0;

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

        tmp += num[i];

        if (tmp >= k) {

            cout << i << endl;

            break;

        }

    }

}




// Optimized solution to the same problem (faster):
#include<iostream>

#include<algorithm>

using namespace std;

typedef pair<int, int> P;

#define N 100000

int main() {

    int n;

    long long k;

    cin >> n >> k;

    int a[n], b[n];

    P p[n];

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

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

        p[i] = {a[i], b[i]};

    }

    sort(p, p + n);

    long long sum = 0;

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

        sum += p[i].second;

        if (sum >= k) {

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

            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;

    int a[N], b[N];

    long long c[100010]={};

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

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

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

    }

    int ans = 0;

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

        K -= c[i];

        if(K <= 0 ){

            ans = i;

            break;

        }

    }

    cout << ans << endl;



    return 0;

}

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

using namespace std;



int main(){

    int N;

    long long K;

    cin >> N >> K;

    vector<pair<int,int>> v;    

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

        int a, b;

        cin >> a >> b;

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

    }

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

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

        K -= v[i].second;

        if(K <= 0 ){

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

            break;

        }

    }



    return 0;

}

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

}

// 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("%lld%lld",&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 <algorithm>

#include <iostream>

#include <string>

using namespace std;



struct Number {

	int a, c;

};



bool cmp(Number a, Number b) {

	return a.a < b.a;

}



int main() {

	long long n, k;

	cin >> n >> k;

	

	Number N[n];

	

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

		cin >> N[i].a >> N[i].c;

	}

	

	sort(N, N + n, cmp);

	

	long long count = 0;

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

		count += N[i].c;

		if(count >= k) {

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

			break;

		}

	}

	

	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("%lld%lld",&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;



vector<pair<int, int> > vec;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  long long int k;

  int n; cin >> n >> k;

  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 = -1;

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

    k -= vec[i].second;

    if (k <= 0) {

      ans = vec[i].first;

      break;

    }

  }

  cout << ans << endl;

  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("%lld%lld",&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):
//I̲n̲ ̲t̲h̲e̲ ̲N̲a̲m̲e̲ ̲o̲f̲ ̲G̲o̲d̲

#define pb push_back

#define F first

#define S second

#define sz size()

#define ll long long



#include <bits/stdc++.h>



using namespace std;



ll n, k;

pair <ll , ll> a[100001];

int main()

{

	ios_base::sync_with_stdio(0);

	cin >> n >> k;

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

    {

        ll x,y;

        cin >> x >> y;

        a[i].F = x;

        a[i].S = y;

    }

    sort(a,a+n);

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

    {

        if (a[i].S >= k)

            return cout << a[i].F, 0;

        else

            k-= a[i].S;

    }

}


// 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("%lld%lld",&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 <iostream>

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

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

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

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

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n;

ll k;

vector<pii> v;



int solve(){

    cin >> n >> k;

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

        cin >> a >> b;

        pii p = mp(a, b);

        v.pb(p);

    }

    sort(all(v));

    ll sum = 0;

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

        sum += v[i].s;

        if(sum >= k) return v[i].f;

    }

    return v[0].f;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    cout << solve() << "\n";

    

    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("%lld%lld",&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 <iostream>

#include <queue>

#define int long long

using namespace std;



int n, k;

priority_queue<pair<int , int > , vector<pair<int , int > > , greater<pair<int , int > > > a;



signed main() {

    ios::sync_with_stdio(0);

    cin.tie(NULL);

    cin >> n >> k;

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

        int x, y;

        cin >> x >> y;

        a.push(make_pair(x, y));

    }

    int tot = 0;

    while(!a.empty()) {

        tot += a.top().second;

        if(tot >= k) {

            cout << a.top().first;

            return 0;

        }

        a.pop();

    }

    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("%lld%lld",&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<iostream>

////#include<set>

////#include<algorithm>

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

//////		}

//////	}	

////

////set<int> a = {0,1,2,9};

////set<int> b = {3,4,5};

////auto first = b.begin();

////auto second = b.end();

////a.insert(first,second);

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

////cout<<*it;

////	return 0;

////}

//

//#include<iostream>

//#include<set>

//#include<algorithm>

//using namespace std;

//int main()

//{

//	unordered_set<int> a{1,2,4,9};

//unordered_set<int> b{3,4,5};

//auto first = b.begin();

//auto second = b.end();

//a.insert(first,second);

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

//cout << *it;

//return 0;

//}

# include <bits/stdc++.h>

using namespace std;

 

typedef long long LL;

multiset<pair<LL, LL> >s;

int main()

{

    LL n, k, a, b;

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

    while(n--)

    {

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

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

    }

    LL sum = 0;

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

    {

        sum += it->second;

        if(sum >= k)

            return 0*printf("%d\n",it->first);

    }

    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("%lld%lld",&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 <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;

}


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

}


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

    }

}

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

}

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

    }

  }

}


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

    }

  }

}


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

        }

    }

}


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

        }

    }

}


// Fastest known solution for this problem: