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

#include <string>

#include <algorithm>

#include <vector>

#include <climits>

#include <sstream>



using namespace std;



const int MAX = 100000;



int main(){

	int N;

	long long K, cnt[MAX+1] = {0};



	cin >> N >> K;



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

		int a, b;

		cin >> a >> b;

		cnt[a] += b;

	}



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

		if(K <= cnt[i]){

			cout << i << endl;

			break;

		}

		K -=cnt[i];

	}



	return 0;

}

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



using namespace std;



typedef long long llint;

typedef pair<llint, llint> P;



llint v[101010];



int main() {

  llint n, k;

  cin >> n >> k;

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

    llint a, b;

    cin >> a >> b;

    v[a] += b;

  }

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

    if (k <= v[i]) {

      cout << i << endl;

      break;

    }

    k -= v[i];

  }



  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;

			//cout<<s[a]<<endl;

			num[i]=a;

		}

		ll sum=0;

		sort(num+1,num+n+1);

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

		{

			if(num[i]!=num[i-1])

				book[i]=num[i];

		}

		sort(book+1,book+n+1);

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

//			cout<<book[i]<<endl;

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

//			cout<<s[book[i]]<<endl;

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

		{

			//cout<<book[i]<<endl;

			if(book[i]==0)

				continue;

			else

			{

				sum+=s[book[i]];

			//	cout<<sum<<endl;

				if(sum>k||sum==k)

				{

					cout<<book[i]<<endl;

					break;

				}

			}	

		}

	}

	return 0;

 } 

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

#include <string.h>

#include <algorithm>

#include <iostream>

#include <math.h>

#include <vector>

#include <map>

#define int long long

#define inf 0x3f3f3f3f

using namespace std;

const int maxn = 1e5 + 5;



struct node

{

    int x, y;

}a[maxn];



bool cmp(node b, node c)

{

    return b.x < c.x;

}



signed main()

{

    int n, k;

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

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

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

    sort(a, a+n, cmp);

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

    {

        if(k>a[i].y)

            k -= a[i].y;

        else

        {

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

            break;

        }

    }

    return 0;

}


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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

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

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

std::vector<int> v1;

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

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];



int32_t main() {

    cin>>n>>k;

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

        cin>>x>>y;

        h[x]+=y;

        if(mark[x]==0){

           v1.pb(x);

           mark[x]=1;

        }

    }

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

    ans=h[v1[0]];

    int i=1;

    while(ans<k){

        ans+=h[v1[i]];

        i++;

    }

    cout<<v1[i-1];

    return 0;

}


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

#include <algorithm>

#include <cmath>

#include <vector>

#include <string>

#include <iomanip>

#include <string>

#include <sstream>

#include  <list>

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

#define INF 0x3f3f3f3f

using namespace std;

/*

int cmp(shi a,shi b)

{

    return a.x<b.x;

}

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

{

    return a > b;

}*/



struct shi{

    long long num;

    long long time;

}ff[1000000];

int cmd(shi a ,shi b){

    return a.num<b.num;

}



int main()

{

    long long n,m;

    cin >>n>>m;

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

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

    sort(ff,ff+n,cmd);

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

    {

        if(m)

        {

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

            m-=ff[i].time;

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

            {

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

                break;

            }

        }

        if(m==0){

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

            break;

        }



    }

    return 0;



}


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

#include <iostream>

#include <vector>

#include <algorithm>  // std::copy()

#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値

using namespace std;

typedef long long ll;



#define ALL(obj) (obj).begin(), (obj).end()

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1

#define IDX(vec, element_iter) distance((vec).begin(), element_iter)

#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり



int main() {

    // input

    ll N, K, a, b;

    cin >> N >> K;

    vector<ll> num(100000+1, 0);

    REP(i, N) {

        cin >> a >> b;

        num[a] += b;

    }

    

    // 各数が何個あるかの累積和を計算

    vector<ll> partial;

    COPY(num, partial);  // copy vec to partial

    partial_sum(num.begin(), num.end(), partial.begin());

    

    // K 個以上となる最小のインデックスを求める

    auto iter = lower_bound(partial.begin(), partial.end(), K);

    cout << IDX(partial, iter) << "\n";

    

    return 0;

}


// Optimized solution to the same problem (faster):
// ABC061_C

#include <iostream>

#include <vector>

#include <algorithm>  // std::copy()

#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値

using namespace std;

typedef long long ll;



#define ALL(obj) (obj).begin(), (obj).end()

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1

#define IDX(vec, element_iter) distance((vec).begin(), element_iter)

#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり



int main() {

    // input

    ll N, K, a, b, sum = 0, maxN = 100000 + 1;

    cin >> N >> K;

    vector<ll> num(maxN, 0);

    REP(i, N) {

        cin >> a >> b;

        num[a] += b;

    }

    

    // 各数が何個あるかの累積和を計算

    for (ll i = 0; i < maxN; ++i) {

        sum += num[i];

        if (K <= sum) {

            cout << i << "\n";

            return 0;

        }

    }

    

    return 0;

}


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

#include<climits>

#include<cmath>

#include<iomanip>

#include<iostream>

#include<list>

#include<map>

#include<numeric>

#include<queue>

#include<set>

#include<stack>

#include<utility>

#include<vector>

 

#define lint long long

#define REP(i, x, n) for(int i = x ; i < n ; i++)

#define rep(i, n) REP(i, 0, n)

#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)

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

#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX

#define LLINF LLONG_MAX



using namespace std;



int main(){

    int n;

    lint k;

    cin >> n >> k;

    vector<lint> v(100010, 0);

    rep(i, n){

        int a;

        lint b;

        cin >> a >> b;

        v[a] += b;

    }

    lint cnt = 0;

    int j = 0;

    while(cnt < k && j < 100005){

        j++;

        cnt += v[j];

    }

    cout << j << endl;

    return 0;

}

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

using namespace std;



#define lint long long

#define P pair<int, int>

#define LLP pair<long long, long long>

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)

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

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

#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)

#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)

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

#define SORT_INV(x) sort((x).rbegin(), (x).rend())



const int IINF = (1 << 30) - 1;

const long long LLINF = 1LL << 61;

const long long MOD = 1000000007LL;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};

const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

const double EPS = 1e-8;



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    lint n, k;

    cin >> n >> k;



    vector< LLP > v;

    rep(i, n){

        lint a, b;

        cin >> a >> b;

        v.emplace_back(a, b);

    }

    SORT(v);

    lint cnt = 0, ans = 0;

    rep(i, n){

        cnt += v[i].second;

        if(cnt >= k){

            ans = v[i].first;

            break;

        }

    }

    cout << ans << endl;



    return 0;

}

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

#include<string>

#include<vector>

#include<utility>

#include<queue>

#include<algorithm>

#include<cmath>

#include<cstdio>

#define INF 2147483647

#define llINF 9223372036854775807

#define pb push_back

#define mp make_pair 

#define F first

#define S second

#define ll long long



using namespace std;

int main(){

  int n;

  ll k;

  cin>>n>>k;

  ll aa[100010]={};

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

    int a,b;

    cin>>a>>b;

    aa[a]+=b;

  }

  int cnt=1;

  while(k>0){

    k-=aa[cnt];

    cnt++;

  }

  cout<<cnt-1<<endl;

  return 0;

}


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

#define INF 1e9

#define llINF 1e18

#define MOD 1000000007

#define pb push_back

#define mp make_pair 

#define F first

#define S second

#define ll long long

#define vi vector<ll>

#define vvi vector<vi>

#define BITLE(n) (1LL<<((ll)n))

#define SHIFT_LEFT(n) (1LL<<((ll)n))

#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))

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

using namespace std;



int main(){

  cin.tie(0);

  ios::sync_with_stdio(false);

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

  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<>>que;

  while(n--){

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

    que.push(mp(a,b));

  }

  while(true){

    ll num = que.top().F;

    ll cnt = que.top().S;

    que.pop();

    if(cnt < k){

      k-=cnt;

    }else{

      cout<<num<<endl;return 0;

    }

  }

  return 0;

}




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



using namespace std;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n; 

  long long k;

  cin >> n >> k;

  vector<long long> s(1e5 + 10, 0);

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

    int a, b;

    cin >> a >> b;

    s[a] += b;

  }

  long long cnt = 0;

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

    cnt += s[i];

    if (k <= cnt) {

      cout << i << endl;

      return 0;

    }

  }

  return 0;

}

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



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

#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)

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

#define rreps(i, n) for (int i = int(n); i >= 1; i--)

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

#define rrepc(i, n) for (int i = int(n); i >= 0; i--)

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

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

#define each(x, y) for (auto &x : y)

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

#define bit32(x) (1 << (x))

#define bit64(x) (1ll << (x))

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



using namespace std;



using i64 = long long;

using f80 = long double;

using vi32 = vector<int>;

using vi64 = vector<i64>;

using vf80 = vector<f80>;

using vstr = vector<string>;



inline void yes() { cout << "Yes" << endl; exit(0); }

inline void no() { cout << "No" << endl; exit(0); }

inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }

inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }

template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};

template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};

template <typename T> inline void amax(T &x, T y) { x = max(x, y); }

template <typename T> inline void amin(T &x, T y) { x = min(x, y); }

template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }

template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }



void solve() {

  int n;

  i64 k;

  cin >> n >> k;

  map<int, i64> mp;

  rep(i, n) {

    int a, b;

    cin >> a >> b;

    mp[a] += b;

  }

  i64 cnt = 0;

  each(m, mp) {

    cnt += m.second;

    if (cnt >= k) {

      cout << m.first << endl;

      return;

    }

  }

}


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

using namespace std;

int main() {

    long long N, K, i, t, a, b;

    long long arr[100001] = {0};

    cin >> N >> K;

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

        cin >> a >> b;

        arr[a] += b;

    }

    for(i = 1, t = 0; i <= 100001; i++) {

        t += arr[i];

        if(t >= K) {cout << i; break;}

    }

}

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

using namespace std;

long long N, K, i, t, a, b;

long long arr[100001] = {0};

int main() {

    scanf("%ld %ld", &N, &K);

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

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

        arr[a] += b;

    }

    for(i = 1, t = 0; i <= 100001; i++) {

        t += arr[i];

        if(t >= K) {printf("%ld", i); break;}

    }

}

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

using namespace std;

long long N, K, i, t, a, b;

long long arr[100001] = {0};

int main() {

    cin >> N >> K;

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

        cin >> a >> b;

        arr[a] += b;

    }

    for(i = 1, t = 0; i <= 100001; i++) {

        t += arr[i];

        if(t >= K) {cout << i; break;}

    }

}

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

using namespace std;

long long N, K, i, t, a, b;

long long arr[100001] = {0};

int main() {

    scanf("%ld %ld", &N, &K);

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

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

        arr[a] += b;

    }

    for(i = 1, t = 0; i <= 100001; i++) {

        t += arr[i];

        if(t >= K) {printf("%ld", i); break;}

    }

}

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

using namespace std;

#define ll long long

ll N, K, i, t, a, b;

ll arr[100001] = {0};

int main() {

    cin >> N >> K;

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

        cin >> a >> b;

        arr[a] += b;

    }

    for(i = 1, t = 0; i <= 100001; i++) {

        t += arr[i];

        if(t >= K) {cout << i; break;}

    }

}

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

using namespace std;

long long N, K, i, t, a, b;

long long arr[100001] = {0};

int main() {

    scanf("%ld %ld", &N, &K);

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

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

        arr[a] += b;

    }

    for(i = 1, t = 0; i <= 100001; i++) {

        t += arr[i];

        if(t >= K) {printf("%ld", i); break;}

    }

}

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

#include<vector>

#include<string>

#include<algorithm>

using namespace std;

int main() {

	int n;

  long long int k;

	cin >> n>>k;

	long long int nu[100010] = {};

	int a[100010];

	int b[100010];

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

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

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

	}

	long long int x = 0;

	int ans = 0;

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

		x += nu[i];

		if (x >= k) {

			ans = i;

			break;

        }

	}

	cout << ans << endl;

	return 0;

}


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

using namespace std;

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

typedef long long int ll;

typedef pair<ll,ll> P;

const ll MOD=1234567;

const ll INF=1000000010;

const ll LINF=1000000000000000010LL;

const int MAX=500010;

const double EPS=1e-3;

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

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

int main(){

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

    priority_queue<P,vector<P>,greater<P>> q;

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

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

        q.push(P(a,b));

    }

    while(!q.empty()){

        P p=q.top();

        q.pop();

        k-=p.second;

        if(k<=0){

            cout<<p.first<<endl;

            return 0;

        }

    }

    return 0;

}


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

using namespace std;



long long c[100001];



int main() {

  long long n, k; cin >> n >> k;

  while (n--) {

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

    c[a] += b;

  }

  int r = 0;

  while (k > 0) {

    k -= c[r++];

  }

  cout << --r << endl;

}

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

using namespace std;long r,k,a,b,c[100001];main(){scanf("%ld%ld",&k,&k);while(scanf("%ld%ld",&a,&b)+1)c[a]+=b;while(k>0)k-=c[++r];printf("%ld",r);}


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

using namespace std;long long r,k,a,b,c[100001];main(){cin>>k>>k;while(cin>>a>>b){c[a]+=b;}while(k>0){k-=c[r++];}cout<<--r<<endl;}

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

using namespace std;long r,k,a,b,c[100001];main(){scanf("%ld%ld",&k,&k);while(scanf("%ld%ld",&a,&b)+1)c[a]+=b;while(k>0)k-=c[++r];printf("%ld",r);}


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

using namespace std;



const int MAX = 100000;



int main() {

	int N;

	int64_t K;

	cin >> N >> K;



	int64_t num[MAX+1] = {0};



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

		int a, b;

		cin >> a >> b;



		num[a] += b;

	}



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

		K -= num[i];



		if (K <= 0) {

			cout << i << endl;

			break;

		}

	}

}

		


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

const int MAX = 1e5;



long K;

long num[MAX + 1] = {0};



int main() {

	int a, b, N;

	scanf("%d %ld\n", &N, &K);



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

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

		num[a] += b;

	}



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

		if (K <= num[i]) {

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

			return 0;

		}

		K -= num[i];

	}

}


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

#include<map>

using namespace std;



int main() {

	int N;

	int64_t K;

	cin >> N >> K;



	map<int, int64_t> num;



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

		int a, b;

		cin >> a >> b;



		num[a] += b;

	}



	int64_t mid_sum = 0;

	for (auto i = num.begin(); i != num.end(); i++) {

		mid_sum += i->second;



		if (mid_sum >= K) {

			cout << i->first << endl;

			break;

		}

	}

}

		


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

const int MAX = 1e5;



long K;

long num[MAX + 1] = {0};



int main() {

	int a, b, N;

	scanf("%d %ld\n", &N, &K);



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

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

		num[a] += b;

	}



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

		if (K <= num[i]) {

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

			return 0;

		}

		K -= num[i];

	}

}


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

const int MAX = 100000;



int main() {

	int N;

	long long K;

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



	long long num[MAX+1] = {0};



	int a, b;

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

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



		num[a] += b;

	}



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

		K -= num[i];



		if (K <= 0) {

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

			break;

		}

	}

}


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

const int MAX = 1e5;



long K;

long num[MAX + 1] = {0};



int main() {

	int a, b, N;

	scanf("%d %ld\n", &N, &K);



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

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

		num[a] += b;

	}



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

		if (K <= num[i]) {

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

			return 0;

		}

		K -= num[i];

	}

}


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

#include<vector>

const int MAX = 1e5;



long long K;

std::vector<long long> num(MAX + 1);



int main() {

	int a, b, N;

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



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

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

		num[a] += b;

	}



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

		if (K <= num[i]) {

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

			return 0;

		}

		K -= num[i];

	}

}


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

const int MAX = 1e5;



long K;

long num[MAX + 1] = {0};



int main() {

	int a, b, N;

	scanf("%d %ld\n", &N, &K);



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

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

		num[a] += b;

	}



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

		if (K <= num[i]) {

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

			return 0;

		}

		K -= num[i];

	}

}


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

#include <algorithm>



using namespace std;

int main()

{

	int n,a[200010];

	long long sum[200010]={0};

	cin >> n;

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

		cin >> a[i];

	}

	sum[0] = a[0];

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

		sum[i] = sum[i-1] + a[i];

	}

	sort(sum,sum+n);

	long long ans=0,cnt=0;

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

		if(sum[i] == 0)

			cnt++;

	}

	ans += (cnt * (cnt + 1)) / 2;

	cnt = 0;

	int tmp = -2;

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

		if(sum[i] == sum[i+1]){

			if(sum[i] != 0){

				cnt++;

				tmp = i;

				if(i == n-2)

					ans += (cnt * (cnt + 1)) / 2;

			}

		}

		else if(tmp == i - 1){

			ans += (cnt * (cnt + 1)) / 2;

			cnt = 0;

		}

	}

	cout << ans << endl;

	

	return 0;

}


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

#include <algorithm>



using namespace std;

int main()

{

	int n;

	long long sum[200010], a;

	cin >> n;

	sum[0] = 0;

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

		cin >> a;

		sum[i] = sum[i-1] + a;

	}

	sort(sum,sum+n+1);

	long long ans = 0;

    long long now = sum[0];

  	long long cnt = 1;

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

		if(now == sum[i]){

			cnt++;

		}

		else{

			ans += (cnt * (cnt-1)) / 2;

			now = sum[i];

			cnt = 1;

		}

	}

	cout << ans + (cnt * (cnt-1)) / 2 << endl;

	

	return 0;

}


// Fastest known solution for this problem: