stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main()

{

	long long k;

	string s;

	cin >> s >> k;

	long long sum = 0;

	int slen,elen,len = s.length(),cha = 0,tmplen = 1;

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

		if(s[i] == s[i - 1]){

			tmplen++;

		}

		else{

			if(cha == 0){

				slen = tmplen;

				tmplen = 1;

				cha++;

			}

			else{

				sum = sum + (tmplen / 2);

				tmplen = 1;

			}

		}

	}

	int tmp;

	long long ans = 0;

	if(s[len - 1] == s[0]){

		if(cha == 0){

			ans = (k / 2) * (tmplen) + k % 2 * (tmplen / 2);

		}

		else if(slen %  2 == 1 || tmplen % 2 == 1){

			ans = (k - 1) * ((slen + tmplen) / 2) + k * sum + slen / 2 + tmplen / 2;

		}

		else{

			ans = k * (sum + slen / 2 + tmplen / 2);

		}

	}

	else{

		ans = k * (sum + slen / 2 + tmplen / 2);

	}

	cout << ans << endl;

	return 0;

}

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

#include <string.h>

int main()

{

	char str[102];

	long long k;

	scanf("%s %lld",str,&k);

	char c=str[0];

	int len=strlen(str);

	long long t=0;

	int pre=0;

	int jian=0;

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

	if(str[i]!=str[i+1]) jian++;

	if(jian){

	

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

	{	

		

		if(str[i]==str[i-1]) pre++;

		else {

			pre++;

			pre/2==0?pre:pre-1;

			t=t+pre/2;

			pre=0;

		}

	}

	if(str[len-1]!=str[0]) t=t*k;

	else{

		int x=0,y=0;

		for(int i=0;str[i]==str[0];i++)

		x++;

		for(int j=len-1;str[len-1]==str[j];j--)

		y++;

		if(x%2!=0&&y%2!=0) t=t*k+k-1;

		else t=t*k;

	}

}

else {

	t=len*k;

	if(t%2==0) t=t/2;

	else t=(t-1)/2;

}

	printf("%lld",t);

	return 0;

	

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

#include <string>

using namespace std;



long long solve(string S) {

	long long cnt = 0, ret = 0;

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

		cnt++;

		if (i == (int)S.size() - 1 || S[i] != S[i + 1]) {

			ret += cnt / 2;

			cnt = 0;

		}

	}

	return ret;

}



int main() {

	string T; cin >> T;

	long long K; cin >> K;



	bool flag = true;

	for (int i = 0; i < (int)T.size() - 1; i++) {

		if (T[i] != T[i + 1]) flag = false;

	}



	if (flag == true) {

		long long len = 1LL * (long long)(T.size()) * K;

		cout << len / 2LL << endl;

	}

	else {

		string V1 = T;

		string V2 = T + T;

		long long R1 = solve(V1);

		long long R2 = solve(V2);

		cout << R1 + (R2 - R1) * (K - 1LL) << endl;

	}

	return 0;

}

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

#include <string.h>

int main()

{

	char str[102];

	long long k;

	scanf("%s %lld",str,&k);

	char c=str[0];

	int len=strlen(str);

	long long t=0;

	int pre=0;

	int jian=0;

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

	if(str[i]!=str[i+1]) jian++;

	if(jian){

	

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

	{	

		

		if(str[i]==str[i-1]) pre++;

		else {

			pre++;

			pre/2==0?pre:pre-1;

			t=t+pre/2;

			pre=0;

		}

	}

	if(str[len-1]!=str[0]) t=t*k;

	else{

		int x=0,y=0;

		for(int i=0;str[i]==str[0];i++)

		x++;

		for(int j=len-1;str[len-1]==str[j];j--)

		y++;

		if(x%2!=0&&y%2!=0) t=t*k+k-1;

		else t=t*k;

	}

}

else {

	t=len*k;

	if(t%2==0) t=t/2;

	else t=(t-1)/2;

}

	printf("%lld",t);

	return 0;

	

}
// Slower C++ solution:
#pragma warning(disable:4996)

#include<iostream>

#include<cstdio>

#include<cmath>

#include<string>

using namespace std;



int main()

{

	string s;

	int k;

	cin >> s;

	scanf("%d", &k);

	int len = s.length();

	long long ans = 0,cnt=1,cnt1=1,flag=0;

	s += '!';

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

	{

		if (s[i] == s[i + 1])

		{

			cnt++;

			if (!flag)

			{

				cnt1++;

			}

		}

		else

		{

			ans += cnt / 2;

			flag = 1;

			if (i != len - 1)

			{

				cnt = 1;

			}

		}

	}

	if (cnt == len)

	{

		ans = 1ll*len*k/2;

	}

	else

	{

		ans *= k;

		if (cnt % 2 && cnt1 % 2 && s[0] == s[len - 1])

		{

			ans += k - 1;

		}

	}

	printf("%lld\n", ans);

	//system("pause");

	return 0;

}


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

#include <string.h>

int main()

{

	char str[102];

	long long k;

	scanf("%s %lld",str,&k);

	char c=str[0];

	int len=strlen(str);

	long long t=0;

	int pre=0;

	int jian=0;

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

	if(str[i]!=str[i+1]) jian++;

	if(jian){

	

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

	{	

		

		if(str[i]==str[i-1]) pre++;

		else {

			pre++;

			pre/2==0?pre:pre-1;

			t=t+pre/2;

			pre=0;

		}

	}

	if(str[len-1]!=str[0]) t=t*k;

	else{

		int x=0,y=0;

		for(int i=0;str[i]==str[0];i++)

		x++;

		for(int j=len-1;str[len-1]==str[j];j--)

		y++;

		if(x%2!=0&&y%2!=0) t=t*k+k-1;

		else t=t*k;

	}

}

else {

	t=len*k;

	if(t%2==0) t=t/2;

	else t=(t-1)/2;

}

	printf("%lld",t);

	return 0;

	

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define INF 9999999;

using namespace std;

inline int read() {

	char c = getchar(); int x = 0, f = 1;

	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}

	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();

	return x * f;

}

stack<char>Q;

string ss;

char s;

map<char,int>mp; 

int tot=0,num=0,t;

int main()

{

	cin>>ss;

	int i=0;

	int j=ss.size()-1;

	while(i<=j)

	 {

	 	if(ss[i]==ss[j])

	 	 {

	 	 	i++;

	 	 	j--;

	 	 	continue;

		 }

		if(ss[i]=='x')

		 {

		 	i++;

		 	tot++;

		 	continue;

		 }

		if(ss[j]=='x')

		 {

		 	j--;

		 	tot++;

		 	continue;

		 }

		else{

		cout<<"-1\n";

		return 0;

	   }

	 }

	cout<<tot<<'\n';

	return 0;

}

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

#include <string.h>

#define N 100001



char s[N];



int main() 

{

	int i, j, ti, tj, ans = 0, x, y;

	

	scanf("%s", s + 1);

	i = 0, j = strlen(s + 1) + 1;

	while(i < j){

		for(ti = i + 1; ti < j && s[ti] == 'x'; ti++);

		if(ti == j) break;

		for(tj = j - 1; s[tj] == 'x'; tj--);

		if(s[ti] != s[tj]){

			puts("-1");

			return 0;

		}

		x = ti - i, y = j - tj;

		if(y > x) ans += y - x;

		else ans += x - y;

		i = ti, j = tj;

	}

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

			

	return 0;

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

#include <stdio.h>

#include <stdlib.h>

#include <algorithm>

#include <cmath>

#include <climits>

#include <vector>

#include <queue>

#include <cstring>

#include <iterator>

#include <list>

#include <set>

#include <map>

#include <bitset>

using namespace std;



typedef long long LL;

int main()

{

    LL N, K;

    cin >> N >> K;



    map<LL, LL> freq;

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

        LL a, b;

        cin >> a >> b;

        if(!freq.count(a))

            freq[a] = 0;

        freq[a] += b;

    }



    map<LL, LL>::iterator it;

    LL k = 1;

    for (it = freq.begin(); k <= K && it != freq.end(); it++) {

        k += it->second;

    }

    it--;

    cout << it->first << endl;

}

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

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

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

{

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

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

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

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

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

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

#include <algorithm>

using namespace std;



typedef long long ll;

const int N = 1e5+10;

struct node{

	ll a;

	ll b;

}p[N];



bool cmp(node a,node b)

{

	return a.a<b.a;

}

int main()

{

	ll n,k;

	cin>>n>>k;

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

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

	sort(p,p+n,cmp);

	ll i;

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

		if(k<=0)

			break;

		else

			k-=p[i].b;

	cout<<p[i-1].a<<endl;

	return 0;

}

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

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

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

{

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

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

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

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

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

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

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<string.h>

using namespace std;

const int manx=1e5+5;

struct node{

	int a;

	int b;

}str[100005];

bool cmp(node x,node y)

{

	return x.a<y.a;

}

int main()

{

	long long n,k;

	long long a,b;

	long long s[100005];

	long long sum=0;

	long long flag=0;

	long long ans;

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

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

	{

		scanf("%d %d",&str[i].a,&str[i].b);

	}

	sort(str,str+n,cmp);

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

	{

		sum+=str[i].b;

		if(sum<k)

		{

			continue;

		}

		else

		{

			if(flag)

			{

				continue;

			 } 

			ans=str[i].a;

			flag=1;

		}

	}

	printf("%lld\n",ans);

	 return 0;

 } 

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

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

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

{

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

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

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

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

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

}
// Slower C++ solution:


///╔══╗

///╚╗╔╝

///╔╝╚(¯`v´¯)

///╚══╝`.¸.´farzin





#include <bits/stdc++.h>



#define int int64_t

#define pb push_back

#define ibsws ios_base::sync_with_stdio

#define gcd __gcd

#define S second

#define F first



using namespace std;



int t,x,y,n,k;

multiset<pair<int,int> > a;



int32_t main(){

	ibsws(true==false);

    cin>>n>>k;

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

        cin>>x>>y;

        a.insert({x,y});

    }

    multiset<pair<int,int> >::iterator it=a.begin();

    while(t<k){

        t+=(*it).S;

        x=(*it).F;

        it++;

    }

    cout<<x;

}


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

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

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

{

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

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

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

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

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

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

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <algorithm>

using namespace std;

struct Node

{

	long long x;

	long long num;

}nn[100005];

bool cmp(Node a,Node b)

{

	return a.x<b.x;

}

int main()

{

	long long n,k;

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

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

	{

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

	}

	sort(nn,nn+n,cmp);

	long long sum=0;

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

	{

		sum+=nn[i].num;

		if(sum>=k)

		{

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

			return 0;

		} 

	}

	return 0;

}

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

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

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

{

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

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

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

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

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

}
// Slower C++ solution:
/* BISMILLAHIR RAHMANIR RAHIM */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int mxn = 1e5 + 5;

ll f[mxn];



int main() {

	ios_base :: sync_with_stdio(0);

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

	ll n, k;

	cin >> n >> k;

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

		cin >> a >> b;

		f[a] += b;

	}

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

		if( k >= f[i] ) {

			k -= f[i];

		}

		else {

			k = 0;

		}

		if( k == 0 ) {

			cout << i << "\n";

			break;

		}

	}

}


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

#include<stdlib.h>

struct node

{

	long long a;

	long long b;

}num[100005];

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

{

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

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

    return m.a - n.a;

}

int main()

{

	int n;

	long long k;

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

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

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

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

	{

		k-=num[i].b;

		if(k<=0)

		{

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

			return 0;

		}

	}

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main(){

	

	int n;

	long long k;

	cin >> n >> k;

	

	vector<long long> v(101010);

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

		int x;

		long long f;

		cin >> x >> f;

		v[x] += f;

	}

	

	long long s = 0;

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

		s += v[i];

		if(s >= k){

			cout << i << "\n";

			break;

		}

	}

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.829586270742161x):
//When I was writing this, only God and I knew what it is

//Now, only The_Blitz know...



#pragma GCC optimize ("Ofast,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

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

#define pb push_back

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

#define IFR(i,a,b) for(int i = int(a); i >= int(b); -- i)

#define ff first

#define ss second

typedef long long ll;

typedef pair<int, int> ii;



const int N = 1e5 + 2;

const int Mod = 1e9 + 7;



map<ll, ll> m;



int main(){

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

	FER(i, 0, n){

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

		m[a] += b;

	}

	ll acc = 0;

	for(auto x: m){

		if(acc + x.ss >= k){

			cout << x.ff << endl;

			break;

		}

		acc += x.ss;

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main(){

	

	int n;

	long long k;

	cin >> n >> k;

	

	vector<long long> v(101010);

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

		int x;

		long long f;

		cin >> x >> f;

		v[x] += f;

	}

	

	long long s = 0;

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

		s += v[i];

		if(s >= k){

			cout << i << "\n";

			break;

		}

	}

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.831777885898183x):
// I look at my watch

// it say nine twenty-five

// And I think oh God

// I'm still alive !

 

#include <bits/stdc++.h>

#define ff first

#define ss second

#define pb push_back

#define mp make_pair

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

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

#define trace(x) cerr << #x << " = " << x << endl

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

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

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

using namespace std;

 

typedef long long ll;

typedef pair<int,int> ii;

typedef long double ld;









int main(){	

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

	ll ini=1;

	ll ans=-1;

	vector<ii>vec(n);

	For(i,0,n){

		ll val,c;cin>>val>>c;

		vec[i]={val,c};

	}

	sort(all(vec));

	For(i,0,n){

		ll val=vec[i].ff,c=vec[i].ss;

		ll l=ini,r=ini+c;

		if(l<=k&&k<r){

			ans=val;

			break;

		}

		ini=r;

	}

	cout<<ans<<endl;

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main(){

	

	int n;

	long long k;

	cin >> n >> k;

	

	vector<long long> v(101010);

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

		int x;

		long long f;

		cin >> x >> f;

		v[x] += f;

	}

	

	long long s = 0;

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

		s += v[i];

		if(s >= k){

			cout << i << "\n";

			break;

		}

	}

	

	return 0;

}

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

using namespace std;



#define nl "\n"

#define db(a) cout << (#a) << " = " << (a) << endl

#define ll long long

#define MOD 1000000007



int mod(int a, int b) {return a >= 0 ? a % b : (b + a % b) % b;}

int dceil(int a, int b) {return (a + b - 1) / b;}

/***********************************/



#define N -1



int main() {

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	/*******************************/

	ll n, k;

	cin >> n >> k;

	vector<pair<ll, ll>> cps;

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

		ll a, b;

		cin >> a >> b;

		cps.push_back({a, b});

	}

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

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

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

			cout << cps[i].first << "\n";

			break;

		}

		k -= cps[i].second;

	}

	return 0;

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

#include <stdio.h>

#include <stdlib.h>

#include <algorithm>

#include <cmath>

#include <climits>

#include <vector>

#include <queue>

#include <cstring>

#include <iterator>

#include <list>

#include <set>

#include <map>

#include <bitset>

using namespace std;



typedef long long LL;

int main()

{

    LL N, K;

    cin >> N >> K;



    map<LL, LL> freq;

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

        LL a, b;

        cin >> a >> b;

        if(!freq.count(a))

            freq[a] = 0;

        freq[a] += b;

    }



    map<LL, LL>::iterator it;

    LL k = 1;

    for (it = freq.begin(); k <= K && it != freq.end(); it++) {

        k += it->second;

    }

    it--;

    cout << it->first << endl;

}

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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

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



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

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

#include <algorithm>

using namespace std;



typedef long long ll;

const int N = 1e5+10;

struct node{

	ll a;

	ll b;

}p[N];



bool cmp(node a,node b)

{

	return a.a<b.a;

}

int main()

{

	ll n,k;

	cin>>n>>k;

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

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

	sort(p,p+n,cmp);

	ll i;

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

		if(k<=0)

			break;

		else

			k-=p[i].b;

	cout<<p[i-1].a<<endl;

	return 0;

}

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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

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



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

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

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<string.h>

using namespace std;

const int manx=1e5+5;

struct node{

	int a;

	int b;

}str[100005];

bool cmp(node x,node y)

{

	return x.a<y.a;

}

int main()

{

	long long n,k;

	long long a,b;

	long long s[100005];

	long long sum=0;

	long long flag=0;

	long long ans;

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

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

	{

		scanf("%d %d",&str[i].a,&str[i].b);

	}

	sort(str,str+n,cmp);

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

	{

		sum+=str[i].b;

		if(sum<k)

		{

			continue;

		}

		else

		{

			if(flag)

			{

				continue;

			 } 

			ans=str[i].a;

			flag=1;

		}

	}

	printf("%lld\n",ans);

	 return 0;

 } 

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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

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



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

}
// Slower C++ solution:


///╔══╗

///╚╗╔╝

///╔╝╚(¯`v´¯)

///╚══╝`.¸.´farzin





#include <bits/stdc++.h>



#define int int64_t

#define pb push_back

#define ibsws ios_base::sync_with_stdio

#define gcd __gcd

#define S second

#define F first



using namespace std;



int t,x,y,n,k;

multiset<pair<int,int> > a;



int32_t main(){

	ibsws(true==false);

    cin>>n>>k;

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

        cin>>x>>y;

        a.insert({x,y});

    }

    multiset<pair<int,int> >::iterator it=a.begin();

    while(t<k){

        t+=(*it).S;

        x=(*it).F;

        it++;

    }

    cout<<x;

}


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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

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



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

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

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <algorithm>

using namespace std;

struct Node

{

	long long x;

	long long num;

}nn[100005];

bool cmp(Node a,Node b)

{

	return a.x<b.x;

}

int main()

{

	long long n,k;

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

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

	{

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

	}

	sort(nn,nn+n,cmp);

	long long sum=0;

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

	{

		sum+=nn[i].num;

		if(sum>=k)

		{

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

			return 0;

		} 

	}

	return 0;

}

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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

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



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

}
// Slower C++ solution:
/* BISMILLAHIR RAHMANIR RAHIM */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int mxn = 1e5 + 5;

ll f[mxn];



int main() {

	ios_base :: sync_with_stdio(0);

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

	ll n, k;

	cin >> n >> k;

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

		cin >> a >> b;

		f[a] += b;

	}

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

		if( k >= f[i] ) {

			k -= f[i];

		}

		else {

			k = 0;

		}

		if( k == 0 ) {

			cout << i << "\n";

			break;

		}

	}

}


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



const int MAXN = 1e5 + 10;



int N;

long long K;

long long freq[MAXN];



int main() {

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



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

    int a, b;

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

    freq[a] += b;

  }



  int i = 1;

  long long k = 0;



  while (k + freq[i] < K) {

    k += freq[i];

    i++;

  }



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

  return 0;

}