stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

    }

  }

}

// Faster C++ solution for the same problem (measured speedup: 1.797939659736432x):
#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;

    }

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 2.580677848913274x):
#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;

}
// Slower C++ solution:
#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];

    }

}


// Faster C++ solution for the same problem (measured speedup: 1.807434195285286x):
#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;

        }

    }

}
// Slower C++ solution:
#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;

        }

    }

}




// Faster C++ solution for the same problem (measured speedup: 1.8058506385232227x):
#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;

        }

    }

}
// Slower C++ solution:
#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];

    }

}


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

#include<algorithm>

#include<vector>

using namespace std;

typedef long long ll;

int main() {

    int n;

    ll 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());

    vector<int> a(n), b(n); //1つのvetor 要素n個

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

        a[i] = v[i].first;

        b[i] = v[i].second;

    }

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

        if (b[i] >= k) {

            cout << a[i] << endl;

            return 0;

        } else {

            k -= b[i];

        }

    }

}
// Slower C++ solution:
#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;

        }

    }

}




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

#include<algorithm>

#include<vector>

using namespace std;

typedef long long ll;

int main() {

    int n;

    ll 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());

    vector<int> a(n), b(n); //1つのvetor 要素n個

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

        a[i] = v[i].first;

        b[i] = v[i].second;

    }

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

        if (b[i] >= k) {

            cout << a[i] << endl;

            return 0;

        } else {

            k -= b[i];

        }

    }

}
// Slower C++ solution:
#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];

    }

}


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

#include<algorithm>

#include<vector>

using namespace std;

typedef long long ll;

int main() {

    int n;

    ll 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 < n; i++) {

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

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

            return 0;

        } else {

            k -= v[i].second;

        }

    }

}
// Slower C++ solution:
#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;

        }

    }

}




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

#include<algorithm>

#include<vector>

using namespace std;

typedef long long ll;

int main() {

    int n;

    ll 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 < n; i++) {

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

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

            return 0;

        } else {

            k -= v[i].second;

        }

    }

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.803165233511418x):
#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;

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

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

	{

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

			a[i]=0;

		while(n--)

		{

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

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.1264859698767213x):
////#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.184114507216545x):
#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;

		}

	}

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.24920632352195x):
#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;

		}

	}

}
// Slower C++ solution:
//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;

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.216873945477043x):
#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;

		}

	}

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.257112766442111x):
#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;

		}

	}

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.23493087728833x):
#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;

		}

	}

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

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

	{

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

			a[i]=0;

		while(n--)

		{

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

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 10.873971803552244x):
#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;

		}

	}

}
// Slower C++ solution:
////#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.113587372590397x):
#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;

		}

	}

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

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

	{

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

			a[i]=0;

		while(n--)

		{

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

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

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

using namespace std;

int main()

{



long long a,b,c,d,e,i,j,k=0,l=0;

pair<long long,long long>p;

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

cin>>a>>b;

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

{

 cin>>c>>d;

p.first=c;

p.second=d;

v.push_back(p);



}

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

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

{l+=v[i].second;

if(l>=b&&k==0){c=v[i].first;k=1;}



}

cout<<c<<endl;

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

using namespace std;

long long a[100005]={0};

int main()

{

	int i,j,n,num;

	long long m;

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

	{

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

			a[i]=0;

		while(n--)

		{

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

			a[i]+=j; 

		}

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

		{

			m-=a[i];

			if(m<=0)

				break;

		}

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

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.0372215578934356x):
/*

        Author: Prokash

                CSE48, JU



*/



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

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

const ll mx=100001;

ll ara[mx+1];

int main()

{

    FAST;

    ll t,k,a,b;

    cin>>t>>k;

    while(t--)

    {

        cin>>a>>b;

        ara[a]+=b;

    }

    for(ll i=0;i<=mx;i++)

    {

        if(ara[i]>=k)

        {

            cout<<i<<endl;

            return 0;

        }

        k=k-ara[i];

    }

    return 0;

}