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

}


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

using namespace std;



#define MAXN 212345

#define int long long

#define pb push_back

#define inf LLONG_MAX

#define mp make_pair

#define pii pair<int,int>

#define f first

#define s second



int32_t main(){

    ios::sync_with_stdio(false);

    cin.tie(0);



   int n,k;

   cin>>n>>k;

   vector<pii> v(n);

   k--;



   for(int i=0;i<n;i++)cin>>v[i].f>>v[i].s;

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

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

		//cout<<v[i].f<<" "<<v[i].s<<" "<<k<<endl;

		if(v[i].s>k){

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

			return 0;

		}

		k-=v[i].s;

	}



    return 0;

 

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

}


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



using namespace std;



pair<int, int> p[100010];



int main() {

	int n;

	long long k;

	cin >> n >> k;

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

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

	}

	sort(p, p+n);

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

		k -= p[i].second;

		if(k <= 0) {

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

			return 0;

		}

	}



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

}


// Faster C++ solution for the same problem (measured speedup: 3.484775016140846x):
//I read the news today, oh boy

//About a lucky man who made the grade

 

#include <bits/stdc++.h>

#define ff first

#define ss second

#define pb push_back

#define mp make_pair

#define sz(x) ll((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(ll i = ll(a); i < ll(b); ++i)

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

using namespace std;



typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<ll> vi;

typedef vector<ii> vii;



const ll N=1e6;



vii V;



int main(){

	fastio;

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

	For(i,0,n){

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

		V.pb(mp(a,b));

	}

	sort(all(V));

	ll acum=0;

	int i=-1;

	while(i<n-1 && acum<k){

		i++;

		acum+=V[i].ss;

	}

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

	return 0;

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

}


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

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

}

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

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

}


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

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

}

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

    }

  }

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

    }

}

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

    }

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

    }

}

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

    }

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

    }

}

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

    }

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

    }

}

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

    }

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

    }

}

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

    }

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

}


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

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

}

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

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

		}

	}

}

		


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

		}

	}

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

		}

	}

}

		


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

	}

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

		}

	}

}

		


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

	}

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

		}

	}

}


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

	}

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

	}

}


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

	}

}