#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=2e5+10;
const ll mod=1e9;
struct node
{
	ll h,d;
	friend bool operator <(node a,node b)
	{
		return a.h-a.d>b.h-b.d;
	}
	void input()
	{
		scanf("%lld%lld",&h,&d);
	}
}a[MAX];
int main()
{
	int i,n,x,y;
	ll ans,now,tmp;
	while(~scanf("%d%d%d",&n,&x,&y))
	{
		for(i=0;i<n;i++) a[i].input();
		sort(a,a+n);
		ans=0;
		for(i=0;i<n;i++) ans+=a[i].d;
		if(y==0) goto end;
		y--;
		tmp=0;
		for(i=0;i<n;i++)
		{
			if(i<y&&a[i].h>a[i].d) ans+=a[i].h-a[i].d;
			if(i==y&&a[i].h>a[i].d) tmp=a[i].h-a[i].d;
		}
		now=ans;
		for(i=0;i<n;i++)
		{
			if(i<y&&a[i].h>a[i].d) ans=max(ans,now+((1LL<<x)-1)*a[i].h+tmp);
			else ans=max(ans,now+(1LL<<x)*a[i].h-a[i].d);
		}
		end:;
		printf("%lld\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef __int64 ll;
const int N=200005;
ll y[N],x[N],n,a,b,ans,now,f[N];
int cmp(int a,int b)
{
	return x[a]-y[a]>x[b]-y[b];
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++)scanf("%I64d%I64d",&x[i],&y[i]),f[i]=i;
	sort(f+1,f+n+1,cmp);
	for (int i=1;i<=b;i++)now+=max(x[f[i]],y[f[i]]);
	for (int i=b+1;i<=n;i++)now+=y[f[i]];
	ans=now;
	for (int i=1;i<=b;i++)
	 {
	 	ll now1=now;
	  	if (x[f[i]]>y[f[i]])now1-=x[f[i]];
	  	else now1-=y[f[i]];
	  	now1+=x[f[i]]*(1<<a);
	  	ans=max(ans,now1);
	 }
	for (int i=b+1;i<=n;i++)
	 {
	 	ll now1=now;
	 	ans=max(ans,now1);
	 	now1-=y[f[i]];
	 	now1+=x[f[i]]*(1<<a);
	 	if (x[f[b]]>y[f[b]])now1-=x[f[b]];
	 	else now1+=y[f[b]];
	 	now1+=y[f[b]];
	 	ans=max(ans,now1);
	 }
	printf("%I64d",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef __int64 ll;
const int N=200005;
ll y[N],x[N],n,a,b,ans,now,f[N];
int cmp(int a,int b)
{
	return x[a]-y[a]>x[b]-y[b];
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++)scanf("%I64d%I64d",&x[i],&y[i]),f[i]=i;
	sort(f+1,f+n+1,cmp);
	if (!b)
	 {
	 	for (int i=1;i<=n;i++)ans+=y[i];
	 	printf("%I64d",ans);
	 	return 0;
	 }
	for (int i=1;i<=b;i++)now+=max(x[f[i]],y[f[i]]);
	for (int i=b+1;i<=n;i++)now+=y[f[i]];
	ans=now;
	for (int i=1;i<=b;i++)
	 {
	 	ll now1=now;
	  	if (x[f[i]]>y[f[i]])now1-=x[f[i]];
	  	else now1-=y[f[i]];
	  	now1+=x[f[i]]*(1<<a);
	  	ans=max(ans,now1);
	 }
	for (int i=b+1;i<=n;i++)
	 {
	 	ll now1=now;
	 	now1-=y[f[i]];
	 	now1+=x[f[i]]*(1<<a);
	 	if (x[f[b]]>y[f[b]])now1-=x[f[b]];
	 	else now1-=y[f[b]];
	 	now1+=y[f[b]];
	 	ans=max(ans,now1);
	 }
	printf("%I64d",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef __int64 ll;
const int N=200005;
ll y[N],x[N],n,a,b,ans,now,f[N];
int cmp(int a,int b)
{
	return x[a]-y[a]>x[b]-y[b];
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++)scanf("%I64d%I64d",&x[i],&y[i]),f[i]=i;
	sort(f+1,f+n+1,cmp);
	for (int i=1;i<=b;i++)now+=max(x[f[i]],y[f[i]]);
	for (int i=b+1;i<=n;i++)now+=y[f[i]];
	ans=now;
	for (int i=1;i<=b;i++)
	 {
	 	ll now1=now;
	  	now1-=x[f[i]];
	  	now1+=x[f[i]]*(1<<a);
	  	ans=max(ans,now1);
	 }
	for (int i=b+1;i<=n;i++)
	 {
	 	ll now1=now;
	 	ans=max(ans,now1);
	 	now1-=y[f[i]];
	 	now1+=x[f[i]]*(1<<a);
	 	now1-=x[f[b]];
	 	now1+=y[f[b]];
	 	ans=max(ans,now1);
	 }
	printf("%I64d",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef __int64 ll;
const int N=200005;
ll y[N],x[N],n,a,b,ans,now,f[N];
int cmp(int a,int b)
{
	return x[a]-y[a]>x[b]-y[b];
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++)scanf("%I64d%I64d",&x[i],&y[i]),f[i]=i;
	sort(f+1,f+n+1,cmp);
	for (int i=1;i<=b;i++)now+=max(x[f[i]],y[f[i]]);
	for (int i=b+1;i<=n;i++)now+=y[f[i]];
	ans=now;
	for (int i=1;i<=b;i++)
	 {
	 	ll now1=now;
	  	if (x[f[i]]>y[f[i]])now1-=x[f[i]];
	  	else now1-=y[f[i]];
	  	now1+=x[f[i]]*(1<<a);
	  	ans=max(ans,now1);
	 }
	for (int i=b+1;i<=n;i++)
	 {
	 	ll now1=now;
	 	now1-=y[f[i]];
	 	now1+=x[f[i]]*(1<<a);
	 	if (x[f[b]]>y[f[b]])now1-=x[f[b]];
	 	else now1-=y[f[b]];
	 	now1+=y[f[b]];
	 	ans=max(ans,now1);
	 }
	printf("%I64d",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef __int64 ll;
const int N=200005;
ll y[N],x[N],n,a,b,ans,now,f[N];
int cmp(int a,int b)
{
	return x[a]-y[a]>x[b]-y[b];
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++)scanf("%I64d%I64d",&x[i],&y[i]),f[i]=i;
	sort(f+1,f+n+1,cmp);
	if (!b)
	 {
	 	for (int i=1;i<=n;i++)ans+=y[i];
	 	printf("%I64d",ans);
	 }
	for (int i=1;i<=b;i++)now+=max(x[f[i]],y[f[i]]);
	for (int i=b+1;i<=n;i++)now+=y[f[i]];
	ans=now;
	for (int i=1;i<=b;i++)
	 {
	 	ll now1=now;
	  	if (x[f[i]]>y[f[i]])now1-=x[f[i]];
	  	else now1-=y[f[i]];
	  	now1+=x[f[i]]*(1<<a);
	  	ans=max(ans,now1);
	 }
	for (int i=b+1;i<=n;i++)
	 {
	 	ll now1=now;
	 	now1-=y[f[i]];
	 	now1+=x[f[i]]*(1<<a);
	 	if (x[f[b]]>y[f[b]])now1-=x[f[b]];
	 	else now1-=y[f[b]];
	 	now1+=y[f[b]];
	 	ans=max(ans,now1);
	 }
	printf("%I64d",ans);
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const double esp = 1e-12;
const int ff = 0x3f3f3f3f;
map<int,int>::iterator it;
struct node
{
	ll h,d;
	int mk;
} p[maxn];

ll n,a,b;

bool cmp(node x,node y)
{
	return x.h-x.d< y.h-y.d;
}

ll quick_pow(ll x,ll y)
{
	ll ans = 1;
	while(y)
	{
		if(y&1)
			ans*= x;
		x*= x;
		y>>= 1;
	}

	return ans;
}

int main()
{
	mem(p,0);
	cin>>n>>a>>b;

	for(int i = 1;i<= n;i++)
		scanf("%lld %lld",&p[i].h,&p[i].d);

	sort(p+1,p+n+1,cmp);

	int last = n+1;
	for(int i = n;i>= 1;i--)
	{
		if(p[i].h-p[i].d> 0&&b> 0)
			p[i].mk = 1,b--;
		else
			break;
		last--;
	}

	ll sum = 0;
	for(int i = 1;i<= n;i++)
		if(p[i].mk)
			sum+= p[i].h;
		else
			sum+= p[i].d;

	ll ans = sum;
	for(int i = 1;i<= n;i++)
	{
		ll tmp = p[i].h*quick_pow(2,a);

		ll d = 0;
		if(p[i].mk)
			d = sum-p[i].h+tmp;
		else if(tmp> p[i].d)
		{
			if(b> 0)
				d = sum-p[i].d+tmp;
			else if(last<= n)
				d = sum-p[last].h+p[last].d-p[i].d+tmp;
		}
		ans = max(ans,d);
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const double esp = 1e-12;
const int ff = 0x3f3f3f3f;
map<int,int>::iterator it;
struct node
{
	ll h,d;
	ll z;
	int mk;
} p[maxn];

ll n,a,b;
ll dp[maxn];

bool cmp(node x,node y)
{
	return x.z< y.z;
}

ll quick_pow(ll x,ll y)
{
	ll ans = 1;
	while(y)
	{
		if(y&1)
			ans*= x;
		x*= x;
		y>>= 1;
	}

	return ans;
}

int main()
{
	mem(p,0);
	cin>>n>>a>>b;

	for(int i = 1;i<= n;i++)
	{
		scanf("%lld %lld",&p[i].h,&p[i].d);
		p[i].z = p[i].h - p[i].d;
	}

	sort(p+1,p+n+1,cmp);

	int last = n+1;
	for(int i = n;i>= 1;i--)
	{
		if(p[i].z> 0&&b> 0)
			p[i].mk = 1,b--;
		else
			break;
		last--;
	}

	for(int i = 1;i<= n;i++)
		if(p[i].mk)
			dp[i] = dp[i-1]+p[i].h;
		else
			dp[i] = dp[i-1]+p[i].d;

	ll ans = dp[n];
	for(int i = 1;i<= n;i++)
	{
		ll tmp = p[i].h*quick_pow(2,a);

		ll sum = 0;
		if(p[i].mk)
			sum = dp[n]-p[i].h+tmp;
		else if(tmp> p[i].d)
		{
			if(b> 0)
				sum = dp[n]-p[i].d+tmp;
			else if(last<= n)
			{
				sum = dp[n]-p[last].h+p[last].d-p[i].d+tmp;
			}
		}
		ans = max(ans,sum);
	}

	cout<<ans<<endl;

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

struct Node
{
	int x,y,ans;
}s[200005];

bool cmp(Node a,Node b)
{
	if(a.ans==b.ans) return a.x<b.x;
	return a.ans>b.ans;
}

int main()
{
	int n,a,b,k;
	ll sum=0,sum1;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>s[i].x>>s[i].y;
		s[i].ans=s[i].x-s[i].y;
	}
	sort(s,s+n,cmp);
	sum1=pow(2.0,a);
	int kk=min(n,b);
	for(k=0;k<kk;k++)
	{
		if(s[k].ans<=0) break;
		sum+=s[k].x;
	}
	for(int i=k;i<n;i++)
		sum+=s[i].y;
	//k--;
	//cout<<sum<<endl;
	if(b!=0)
	{
		ll maxn,maxnn=sum;
		for(int i=0;i<n;i++)
		{
			maxn=sum;
			if(i<=k)
			{
				maxn=maxn-s[i].x+(sum1*s[i].x);
				maxnn=max(maxnn,maxn);
			}
			else
			{
				if(k<b)
				{
					maxn=maxn-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
				else
				{
					maxn=maxn-s[k].x+s[k].y-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
			}
		}
		cout<<maxnn<<endl;
	}
	else
	{
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

struct Node
{
	int x,y,ans;
}s[200005];

bool cmp(Node a,Node b)
{
	if(a.ans==b.ans) return a.x<b.x;
	return a.ans>b.ans;
}

int main()
{
	int n,a,b,k;
	ll sum=0,sum1=1;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>s[i].x>>s[i].y;
		s[i].ans=s[i].x-s[i].y;
	}
	sort(s,s+n,cmp);
	for(int i=0;i<a;i++)
		sum1*=2;
	int kk=min(n,b);
	for(k=0;k<kk;k++)
	{
		if(s[k].ans<=0) break;
		sum+=s[k].x;
	}
	for(int i=k;i<n;i++)
		sum+=s[i].y;
	k--;
	//cout<<sum<<endl;
	if(b!=0)
	{
		ll maxn,maxnn=sum;
		for(int i=0;i<n;i++)
		{
			maxn=sum;
			if(i<=k)
			{
				maxn=maxn-s[i].x+(sum1*s[i].x);
				maxnn=max(maxnn,maxn);
			}
			else
			{
				if(k<b)
				{
					maxn=maxn-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
				else
				{
					maxn=maxn-s[k].x+s[k].y-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
			}
		}
		cout<<maxnn<<endl;
	}
	else
	{
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

struct Node
{
	int x,y,ans;
}s[200005];

bool cmp(Node a,Node b)
{
	if(a.ans==b.ans) return a.x<b.x;
	return a.ans>b.ans;
}

int main()
{
	int n,a,b,k;
	ll sum=0,sum1;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>s[i].x>>s[i].y;
		s[i].ans=s[i].x-s[i].y;
	}
	sort(s,s+n,cmp);
	sum1=pow(2.0,a);
	int kk=min(n,b);
	for(k=0;k<kk;k++)
	{
		if(s[k].ans<=0) break;
		sum+=s[k].x;
	}
	for(int i=k;i<n;i++)
		sum+=s[i].y;
	k--;
	//cout<<sum1<<endl;
	if(b!=0)
	{
		ll maxn,maxnn=sum;
		for(int i=0;i<n;i++)
		{
			maxn=sum;
			if(i<=k)
			{
				maxn=maxn-s[i].x+(sum1*s[i].x);
				maxnn=max(maxnn,maxn);
			}
			else
			{
				if(k<b)
				{
					maxn=maxn-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
				else
				{
					maxn=maxn-s[k+1].x+s[k+1].y-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
			}
		}
		cout<<maxnn<<endl;
	}
	else
	{
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

struct Node
{
	int x,y,ans;
}s[200005];

bool cmp(Node a,Node b)
{
	if(a.ans==b.ans) return a.x<b.x;
	return a.ans>b.ans;
}

int main()
{
	int n,a,b,k;
	ll sum=0,sum1=1;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>s[i].x>>s[i].y;
		s[i].ans=s[i].x-s[i].y;
	}
	sort(s,s+n,cmp);
	//sum1=pow(2.0,a);
	for(int i=1;i<=a;i++) sum1 *= 2;
	int kk=min(n,b);
	for(k=0;k<kk;k++)
	{
		if(s[k].ans<=0) break;
		sum+=s[k].x;
	}
	for(int i=k;i<n;i++)
		sum+=s[i].y;
	k--;
	//cout<<sum<<endl;
	if(b!=0)
	{
		ll maxn,maxnn=sum;
		for(int i=0;i<n;i++)
		{
			maxn=sum;
			if(i<=k)
			{
				maxn=maxn-s[i].x+(sum1*s[i].x);
				maxnn=max(maxnn,maxn);
			}
			else
			{
				if(k<b)
				{
					maxn=maxn-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
				else
				{
					maxn=maxn-s[k].x+s[k].y-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
			}
		}
		cout<<maxnn<<endl;
	}
	else
	{
		cout<<sum<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn = 320000;

int n,a,b;

struct node{
    int hp,dm;
}d[maxn];

int cmp(node alpha,node beta){
    return alpha.hp-alpha.dm > beta.hp-beta.dm;
}

void read(){
    scanf("%d%d%d",&n,&a,&b);
    for(int i=1;i<=n;i++) scanf("%d%d",&d[i].hp,&d[i].dm);
    sort(d+1,d+n+1,cmp);
}

void work(){
    int hh = 1;
    long long ext = 0,ans = 0;
    for(int i=1;i<=a;i++) hh *= 2;
    int pt;
    for(pt=1;pt<=min(b,n);pt++){
    if(d[pt].hp-d[pt].dm <= 0) break;
    ans += d[pt].hp;
    }
    for(int i=pt;i<=n;i++) ans += d[i].dm;
    long long em = ans;ext = ans;pt--;
    if(b == 0){printf("%I64d",ext);return;}
    for(int i=1;i<=n;i++){
    em = ans;
    if(i<=pt){
        em = em-d[i].hp+(1ll*d[i].hp*hh);
        ext = max(ext,em);
    }else{
        if(pt < b){
        em = em+(1ll*d[i].hp*hh)-d[i].dm;
        ext = max(ext,em);
        }else{
        em = em-d[pt].hp+(1ll*d[i].hp*hh)-d[i].dm+d[pt].dm;
        ext = max(ext,em);
        }
    }
    }
    printf("%I64d",ext);
}

int main(){
    read();
    work();
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

struct Node
{
	ll x,y,ans;
}s[200005];

bool cmp(Node a,Node b)
{
	if(a.ans==b.ans) return a.x<b.x;
	return a.ans>b.ans;
}

int main()
{
	ll n,a,b,k;
	ll sum=0,sum1=1;
	cin>>n>>a>>b;
	for(ll i=0;i<n;i++)
	{
		cin>>s[i].x>>s[i].y;
		s[i].ans=s[i].x-s[i].y;
	}
	sort(s,s+n,cmp);
	sum1=pow(2.0,a);
	ll kk=min(n,b);
	for(k=0;k<kk;k++)
	{
		if(s[k].ans<=0) break;
		sum+=s[k].x;
	}
	for(ll i=k;i<n;i++)
		sum+=s[i].y;
	k--;
	//cout<<sum<<endl;
	if(b!=0)
	{
		ll maxn,maxnn=sum;
		for(ll i=0;i<n;i++)
		{
			maxn=sum;
			if(i<=k)
			{
				maxn=maxn-s[i].x+(sum1*s[i].x);
				maxnn=max(maxnn,maxn);
			}
			else
			{
				if(k<b)
				{
					maxn=maxn-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
				else
				{
					maxn=maxn-s[k].x+s[k].y-s[i].y+(sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
			}
		}
		cout<<maxnn<<endl;
	}
	else
	{
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

struct Node
{
	int x,y,ans;
}s[200005];

bool cmp(Node a,Node b)
{
	if(a.ans==b.ans) return a.x<b.x;
	return a.ans>b.ans;
}

int main()
{
	int n,a,b,k;
	ll sum=0,sum1;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>s[i].x>>s[i].y;
		s[i].ans=s[i].x-s[i].y;
	}
	sort(s,s+n,cmp);
	sum1=pow(2.0,a);
	int kk=min(n,b);
	for(k=0;k<kk;k++)
	{
		if(s[k].ans<=0) break;
		sum+=s[k].x;
	}
	for(int i=k;i<n;i++)
		sum+=s[i].y;
	k--;
	//cout<<sum<<endl;
	if(b!=0)
	{
		ll maxn,maxnn=sum;
		for(int i=0;i<n;i++)
		{
			maxn=sum;
			if(i<=k)
			{
				maxn=maxn-s[i].x+(1ll*sum1*s[i].x);
				maxnn=max(maxnn,maxn);
			}
			else
			{
				if(k<b)
				{
					maxn=maxn-s[i].y+(1ll*sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
				else
				{
					maxn=maxn-s[k].x+s[k].y-s[i].y+(1ll*sum1*s[i].x);
					maxnn=max(maxnn,maxn);
				}
			}
		}
		cout<<maxnn<<endl;
	}
	else
	{
		cout<<sum<<endl;
	}
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a,b,rk[N];
LL ans,tot,x[N],y[N];

struct node{
	LL x; int id;
	bool operator < (const node &a) const
	{return x>a.x;}
}c[N];

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	b=min(b,n);
	for (int i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x[i],&y[i]);
		c[i]=(node){x[i]-y[i],i};
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
		tot=tot+y[i],rk[c[i].id]=i;
	for (int i=1;i<=b;i++)
		if (c[i].x>=0ll) tot=tot+c[i].x;
	ans=tot;
	if (b==0)
	{
		printf("%I64d\n",ans);
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		if ((x[i]<<a)<=y[i]) continue;
		if ((x[i]<<a)-y[i]>max(c[b].x,0ll))
			ans=max(ans,tot+(x[i]<<a)-y[i]-(rk[i]>=b)*max(c[b].x,0ll)-(rk[i]<b)*max(0ll,c[rk[i]].x));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a,b,rk[N];
LL ans,tot,x[N],y[N];

struct node{
	LL x; int id;
	bool operator < (const node &a) const
	{return x>a.x;}
}c[N];

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	b=min(b,n);
	for (int i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x[i],&y[i]);
		c[i]=(node){x[i]-y[i],i};
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
		tot=tot+y[i],rk[c[i].id]=i;
	for (int i=1;i<=b;i++)
		if (c[i].x>=0ll) tot=tot+c[i].x;
	ans=tot;
	//printf("%d\n",ans);
	for (int i=1;i<=n;i++)
	{
		if ((x[i]<<a)<=y[i]) continue;
		if ((x[i]<<a)-y[i]>max(c[b].x,0ll))
			ans=max(ans,tot+(x[i]<<a)-y[i]-max(c[b].x,0ll)*(rk[i]>b));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a,b;
LL ans,tot,x[N],y[N];

struct node{
	LL x; int id;
	bool operator < (const node &a) const
	{return x<a.x;}
}c[N];

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	b=min(b,n);
	for (int i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x[i],&y[i]);
		c[i]=(node){x[i]-y[i],i};
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
		tot=tot+y[i];
	for (int i=1;i<=b;i++)
		if (c[i].x>=0ll) tot=tot+c[i].x;
	ans=tot;
	//printf("%d\n",ans);
	for (int i=1;i<=n;i++)
	{
		if ((x[i]<<a)<=y[i]) continue;
		if ((x[i]<<a)-y[i]>max(c[b].x,0ll))
			ans=max(ans,tot+(x[i]<<a)-y[i]-max(c[b].x,0ll));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a,b,rk[N];
LL ans,tot,x[N],y[N];

struct node{
	LL x; int id;
	bool operator < (const node &a) const
	{return x>a.x;}
}c[N];

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	b=min(b,n);
	for (int i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x[i],&y[i]);
		c[i]=(node){y[i]-x[i],i};
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
		tot=tot+y[i],rk[c[i].id]=i;
	for (int i=1;i<=b;i++)
		if (c[i].x>=0ll) tot=tot+c[i].x;
	ans=tot;
	//printf("%d\n",ans);
	for (int i=1;i<=n;i++)
	{
		if ((x[i]<<a)<=y[i]) continue;
		if ((x[i]<<a)-y[i]>max(c[b].x,0ll))
			ans=max(ans,tot+(x[i]<<a)-y[i]-max(c[b].x,0ll)*(rk[i]>b));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a,b,rk[N];
LL ans,tot,x[N],y[N];

struct node{
	LL x; int id;
	bool operator < (const node &a) const
	{return x>a.x;}
}c[N];

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	b=min(b,n);
	for (int i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x[i],&y[i]);
		c[i]=(node){x[i]-y[i],i};
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
		tot=tot+y[i],rk[c[i].id]=i;
	for (int i=1;i<=b;i++)
		if (c[i].x>=0ll) tot=tot+c[i].x;
	ans=tot;
	for (int i=1;i<=n;i++)
	{
		if ((x[i]<<a)<=y[i]) continue;
		if ((x[i]<<a)-y[i]>max(c[b].x,0ll))
			ans=max(ans,tot+(x[i]<<a)-y[i]-max(c[b].x,0ll)-(rk[i]<b)*max(0ll,c[rk[i]].x));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a,b,rk[N];
LL ans,tot,x[N],y[N];

struct node{
	LL x; int id;
	bool operator < (const node &a) const
	{return x>a.x;}
}c[N];

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	b=min(b,n);
	for (int i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x[i],&y[i]);
		c[i]=(node){x[i]-y[i],i};
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
		tot=tot+y[i],rk[c[i].id]=i;
	for (int i=1;i<=b;i++)
		if (c[i].x>=0ll) tot=tot+c[i].x;
	ans=tot;
	if (b==0)
	{
		printf("%I64d\n",ans);
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		if ((x[i]<<a)<=y[i]) continue;
		if ((x[i]<<a)-y[i]>max(c[b].x,0ll))
			ans=max(ans,tot+(x[i]<<a)-y[i]-max(c[b].x,0ll)-(rk[i]<b)*max(0ll,c[rk[i]].x));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a,b,rk[N];
LL ans,tot,x[N],y[N];

struct node{
	LL x; int id;
	bool operator < (const node &a) const
	{return x<a.x;}
}c[N];

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	b=min(b,n);
	for (int i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x[i],&y[i]);
		c[i]=(node){x[i]-y[i],i};
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
		tot=tot+y[i],rk[c[i].id]=i;
	for (int i=1;i<=b;i++)
		if (c[i].x>=0ll) tot=tot+c[i].x;
	ans=tot;
	//printf("%d\n",ans);
	for (int i=1;i<=n;i++)
	{
		if ((x[i]<<a)<=y[i]) continue;
		if ((x[i]<<a)-y[i]>max(c[b].x,0ll))
			ans=max(ans,tot+(x[i]<<a)-y[i]-max(c[b].x,0ll)*(rk[i]>b));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;

struct mn{
    int bld;
    int atk;
    int delta;
    bool operator < (const mn &p){
        return delta > p.delta;
    }
};

mn mns[200010];

int main(void){

    int a,b;
    scanf("%d%d%d",&n,&a,&b);
    int tms = 1;
    for(int i=0;i<a;i++)tms*=2;

    long long totaldmg = 0;

    int ta,tb;
    for(int i=0;i<n;i++){
        scanf("%d%d",&ta,&tb);
        mns[i].bld = ta;
        mns[i].atk = tb;
        mns[i].delta = max(0,ta-tb);
        totaldmg += tb;
    }
    sort(mns,mns+n);

    int tempend = min(b,n);
    for(int i=0;i<tempend;i++){
        totaldmg = totaldmg + mns[i].delta;
    }

    long long maxdelta = 0ll;
    if(b){
        for(int i=0;i<n;i++){
            long long tmpdelta;
            if(i<tempend){
                tmpdelta = 0ll - mns[i].delta + 1ll * tms * mns[i].bld - mns[i].atk;
            }else{
                tmpdelta = 1ll * tms * mns[i].bld - mns[i].atk - mns[tempend-1].delta;
            }
            maxdelta = max(maxdelta,tmpdelta);
        }
    }

    cout<<totaldmg + maxdelta<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;

struct mn{
    int bld;
    int atk;
    int delta;
    bool operator < (const mn &p){
        return delta > p.delta;
    }
};

mn mns[200010];

int main(void){

    int a,b;
    scanf("%d%d%d",&n,&a,&b);
    int tms = 1;
    for(int i=0;i<a;i++)tms*=2;

    long long totaldmg = 0;

    int ta,tb;
    for(int i=0;i<n;i++){
        scanf("%d%d",&ta,&tb);
        mns[i].bld = ta;
        mns[i].atk = tb;
        mns[i].delta = max(0,ta-tb);
        totaldmg += tb;
    }
    sort(mns,mns+n);

    int tempend = max(b,n);
    for(int i=0;i<tempend;i++){
        totaldmg = totaldmg + mns[i].delta;
    }

    long long maxdelta = 0ll;
    if(b){
        for(int i=0;i<n;i++){
            long long tmpdelta;
            if(i<tempend){
                tmpdelta = 0ll - mns[i].delta + 1ll * tms * mns[i].bld - mns[i].atk;
            }else{
                tmpdelta = 1ll * tms * mns[i].bld - mns[i].atk - mns[tempend-1].delta;
            }
            maxdelta = max(maxdelta,tmpdelta);
        }
    }

    cout<<totaldmg + maxdelta<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18 + 7;
const int N = 211111;
int n, a, b, tp;
struct node{ll h, d;} c[N];
ll f[2][25][25], stk[N], po[N], s1[N], s2[N];

void upd(ll &a, ll b){a = a > b ? a : b;}
bool cmp(node x, node y){return x.h - x.d < y.h - y.d;}
ll get(int i, int dir, int j, int k, int x){
	return f[dir^1][stk[x]][k-1] + c[i].h * po[j-stk[x]];
}
ll find(int i, int dir, int j, int k){
	int l = 1, r = tp;
	while(l + 2 < r){
		int len = (r - l + 1) / 3;
		int m1 = l + len, m2 = r - len;
		if (get(i, dir, j, k, m1) >= get(i, dir, j, k, m2))
			r = m2; else l = m1;
	}
	ll ret = max(get(i, dir, j, k, l), get(i, dir, j, k, r));
	if (l + 1 < r) ret = max(ret, get(i, dir, j, k, l + 1));
	return ret;
}

int main(){
	read(n), read(a), read(b);
	rep(i, 1, n) read(c[i].h), read(c[i].d);
	sort(c + 1, c + n + 1, cmp);
	po[0] = 1;
	rep(i, 1, a) po[i] = po[i-1] * 2;
	per(i, n, 1) s1[i] = s1[i+1] + c[i].h, s2[i] = s2[i+1] + c[i].d;
	int lim = 1;
	per(i, n, 1) if (c[i].h < c[i].d) {lim = i + 1; break;}
	if (b == 0){
		cout << s2[1] << endl;
		return 0;
	}
	ll ans = 0; int dir = 1;
	rep(i, 0, a) rep(j, 0, min(a, b)) f[0][i][j] = -INF;
	f[0][0][0] = 0;
	for (int i = 1; i <= n; ++i, dir ^= 1){
		rep(j, 0, a) rep(k, 0, min(a, b)) f[dir][j][k] = -INF;
		rep(k, 0, min(a, b)){
			tp = 0;
			rep(j, 0, a){
				upd(f[dir][j][k], f[dir^1][j][k] + c[i].d);
				if (k > 0){
					while(tp > 0 && f[dir^1][j][k-1] >= f[dir^1][stk[tp]][k-1]) tp--;
					stk[++tp] = j;
					upd(f[dir][j][k], find(i, dir, j, k));
				}
			}
		}
		rep(j, 0, a) rep(k, 0, min(a, b)){
			int p = max(lim, max(i + 1, n - (b - k) + 1));
			upd(ans, f[dir][j][k] + s1[p] + s2[i+1] - s2[p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18 + 7;
const int N = 211111;
int n, a, b, tp;
struct node{ll h, d;} c[N];
ll f[2][25][25], stk[N], po[N], s1[N], s2[N];

void upd(ll &a, ll b){a = a > b ? a : b;}
bool cmp(node x, node y){return x.h - x.d < y.h - y.d;}

int main(){
	read(n), read(a), read(b);
	rep(i, 1, n) read(c[i].h), read(c[i].d);
	sort(c + 1, c + n + 1, cmp);
	po[0] = 1;
	rep(i, 1, a) po[i] = po[i-1] * 2;
	per(i, n, 1) s1[i] = s1[i+1] + c[i].h, s2[i] = s2[i+1] + c[i].d;
	int lim = 1;
	per(i, n, 1) if (c[i].h < c[i].d) {lim = i + 1; break;}
	if (b == 0){
		cout << s2[1] << endl;
		return 0;
	}
	ll ans = 0;
	rep(i, 1, n){
		ll res = max(c[i].h * po[a], c[i].d);
		int p = max(lim, n - (b - 1) + 1);
		res += s1[p] + s2[1] - s2[p];
		if (i >= p) res -= c[i].h, res += max(0ll, c[p-1].h - c[p-1].d);
		else res -= c[i].d;
		ans = max(ans, res);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18 + 7;
const int N = 211111;
int n, a, b, tp;
struct node{ll h, d;} c[N];
ll f[2][25][25], stk[N], po[N], s1[N], s2[N];

void upd(ll &a, ll b){a = a > b ? a : b;}
bool cmp(node x, node y){return x.h - x.d < y.h - y.d;}

int main(){
	read(n), read(a), read(b);
	rep(i, 1, n) read(c[i].h), read(c[i].d);
	sort(c + 1, c + n + 1, cmp);
	po[0] = 1;
	rep(i, 1, a) po[i] = po[i-1] * 2;
	per(i, n, 1) s1[i] = s1[i+1] + c[i].h, s2[i] = s2[i+1] + c[i].d;
	int lim = 1;
	per(i, n, 1) if (c[i].h < c[i].d) {lim = i + 1; break;}
	if (b == 0){
		cout << s2[1] << endl;
		return 0;
	}
	ll ans = 0;
	rep(i, 1, n){
		ll res = c[i].h * po[a];
		int p = max(lim, n - (b - 1) + 1);
		res += s1[p] + s2[1] - s2[p];
		if (i >= p) res -= c[i].h, res += max(0ll, c[p-1].h - c[p-1].d);
		else res -= c[i].d;
		ans = max(ans, res);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const int N = 211111;
int n, a, b, tp;
struct node{ll h, d;} c[N];
ll f[2][25][25], stk[N], po[N], s1[N], s2[N];

void upd(ll &a, ll b){a = a > b ? a : b;}
bool cmp(node x, node y){return x.h - x.d < y.h - y.d;}
ll get(int i, int dir, int j, int k, int x){
	return f[dir^1][stk[x]][k-1] + c[i].h * po[j-stk[x]];
}
ll find(int i, int dir, int j, int k){
	int l = 1, r = tp;
	while(l + 2 < r){
		int len = (r - l + 1) / 3;
		int m1 = l + len, m2 = r - len;
		if (get(i, dir, j, k, m1) > get(i, dir, j, k, m2))
			r = m2; else l = m1;
	}
	ll ret = max(get(i, dir, j, k, l), get(i, dir, j, k, r));
	if (l + 1 < r) ret = max(ret, get(i, dir, j, k, l + 1));
	return ret;
}

int main(){
	read(n), read(a), read(b);
	rep(i, 1, n) read(c[i].h), read(c[i].d);
	sort(c + 1, c + n + 1, cmp);
	po[0] = 1;
	rep(i, 1, a) po[i] = po[i-1] * 2;
	per(i, n, 1) s1[i] = s1[i+1] + c[i].h, s2[i] = s2[i+1] + c[i].d;
	int lim = n + 1;
	per(i, n, 1) if (c[i].h < c[i].d) {lim = i + 1; break;}
	ll ans = 0; int dir = 1;
	for (int i = 1; i <= n; ++i, dir ^= 1){
		rep(k, 0, min(a, b)){
			tp = 0;
			rep(j, 0, a){
				upd(f[dir][j][k], f[dir^1][j][k] + c[i].d);
				if (k > 0){
					while(tp > 0 && f[dir^1][j][k-1] >= f[dir^1][stk[tp]][k-1]) tp--;
					stk[++tp] = j;
					upd(f[dir][j][k], find(i, dir, j, k));
				}
			}
		}
		rep(j, 0, a) rep(k, 0, min(a, b)){
			int p = max(lim, max(i + 1, n - (b - k) + 1));
			upd(ans, f[dir][j][k] + s1[p] + s2[i+1] - s2[p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18 + 7;
const int N = 211111;
int n, a, b, tp;
struct node{ll h, d;} c[N];
ll f[2][25][25], stk[N], po[N], s1[N], s2[N];

void upd(ll &a, ll b){a = a > b ? a : b;}
bool cmp(node x, node y){return x.h - x.d < y.h - y.d;}
ll get(int i, int dir, int j, int k, int x){
	return f[dir^1][stk[x]][k-1] + c[i].h * po[j-stk[x]];
}
ll find(int i, int dir, int j, int k){
	int l = 1, r = tp;
	while(l + 2 < r){
		int len = (r - l + 1) / 3;
		int m1 = l + len, m2 = r - len;
		if (get(i, dir, j, k, m1) > get(i, dir, j, k, m2))
			r = m2; else l = m1;
	}
	ll ret = max(get(i, dir, j, k, l), get(i, dir, j, k, r));
	if (l + 1 < r) ret = max(ret, get(i, dir, j, k, l + 1));
	return ret;
}

int main(){
	read(n), read(a), read(b);
	rep(i, 1, n) read(c[i].h), read(c[i].d);
	sort(c + 1, c + n + 1, cmp);
	po[0] = 1;
	rep(i, 1, a) po[i] = po[i-1] * 2;
	per(i, n, 1) s1[i] = s1[i+1] + c[i].h, s2[i] = s2[i+1] + c[i].d;
	int lim = n + 1;
	per(i, n, 1) if (c[i].h < c[i].d) {lim = i + 1; break;}
	ll ans = 0; int dir = 1;
	rep(i, 0, a) rep(j, 0, min(a, b)) f[0][i][j] = -INF;
	f[0][0][0] = 0;
	for (int i = 1; i <= n; ++i, dir ^= 1){
		rep(j, 0, a) rep(k, 0, min(a, b)) f[dir][j][k] = -INF;
		rep(k, 0, min(a, b)){
			tp = 0;
			rep(j, 0, a){
				upd(f[dir][j][k], f[dir^1][j][k] + c[i].d);
				if (k > 0){
					while(tp > 0 && f[dir^1][j][k-1] >= f[dir^1][stk[tp]][k-1]) tp--;
					stk[++tp] = j;
					upd(f[dir][j][k], find(i, dir, j, k));
				}
			}
		}
		rep(j, 0, a) rep(k, 0, min(a, b)){
			int p = max(lim, max(i + 1, n - (b - k) + 1));
			upd(ans, f[dir][j][k] + s1[p] + s2[i+1] - s2[p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18 + 7;
const int N = 211111;
int n, a, b, tp;
struct node{ll h, d;} c[N];
ll f[2][25][25], stk[N], po[N], s1[N], s2[N];

void upd(ll &a, ll b){a = a > b ? a : b;}
bool cmp(node x, node y){return x.h - x.d < y.h - y.d;}
ll get(int i, int dir, int j, int k, int x){
	return f[dir^1][stk[x]][k-1] + c[i].h * po[j-stk[x]];
}
ll find(int i, int dir, int j, int k){
	int l = 1, r = tp;
	while(l + 2 < r){
		int len = (r - l + 1) / 3;
		int m1 = l + len, m2 = r - len;
		if (get(i, dir, j, k, m1) > get(i, dir, j, k, m2))
			r = m2; else l = m1;
	}
	ll ret = max(get(i, dir, j, k, l), get(i, dir, j, k, r));
	if (l + 1 < r) ret = max(ret, get(i, dir, j, k, l + 1));
	return ret;
}

int main(){
	read(n), read(a), read(b);
	rep(i, 1, n) read(c[i].h), read(c[i].d);
	sort(c + 1, c + n + 1, cmp);
	po[0] = 1;
	rep(i, 1, a) po[i] = po[i-1] * 2;
	per(i, n, 1) s1[i] = s1[i+1] + c[i].h, s2[i] = s2[i+1] + c[i].d;
	int lim = 1;
	per(i, n, 1) if (c[i].h < c[i].d) {lim = i + 1; break;}
	ll ans = 0; int dir = 1;
	rep(i, 0, a) rep(j, 0, min(a, b)) f[0][i][j] = -INF;
	f[0][0][0] = 0;
	for (int i = 1; i <= n; ++i, dir ^= 1){
		rep(j, 0, a) rep(k, 0, min(a, b)) f[dir][j][k] = -INF;
		rep(k, 0, min(a, b)){
			tp = 0;
			rep(j, 0, a){
				upd(f[dir][j][k], f[dir^1][j][k] + c[i].d);
				if (k > 0){
					while(tp > 0 && f[dir^1][j][k-1] >= f[dir^1][stk[tp]][k-1]) tp--;
					stk[++tp] = j;
					upd(f[dir][j][k], find(i, dir, j, k));
				}
			}
		}
		rep(j, 0, a) rep(k, 0, min(a, b)){
			int p = max(lim, max(i + 1, n - (b - k) + 1));
			upd(ans, f[dir][j][k] + s1[p] + s2[i+1] - s2[p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18 + 7;
const int N = 211111;
int n, a, b, tp;
struct node{ll h, d;} c[N];
ll f[2][25][25], stk[N], po[N], s1[N], s2[N];

void upd(ll &a, ll b){a = a > b ? a : b;}
bool cmp(node x, node y){return x.h - x.d < y.h - y.d;}

int main(){
	read(n), read(a), read(b);
	rep(i, 1, n) read(c[i].h), read(c[i].d);
	sort(c + 1, c + n + 1, cmp);
	po[0] = 1;
	rep(i, 1, a) po[i] = po[i-1] * 2;
	per(i, n, 1) s1[i] = s1[i+1] + c[i].h, s2[i] = s2[i+1] + c[i].d;
	int lim = 1;
	per(i, n, 1) if (c[i].h < c[i].d) {lim = i + 1; break;}
	if (b == 0){
		cout << s2[1] << endl;
		return 0;
	}
	ll ans = 0;
	rep(i, 1, n){
		ll res = c[i].h * po[a];
		int p = max(lim, n - (b - 1) + 1);
		res += s1[p] + s2[1] - s2[p];
		if (i >= p) res -= c[i].h + max(0ll, c[p-1].h - c[p-1].d);
		else res -= c[i].d;
		ans = max(ans, res);
	}
	cout << ans << endl;
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+7;
struct node
{
	int x,y,q;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.q>f.q;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c[i].x,&c[i].y);
			c[i].q=c[i].x*2-c[i].y;
		}
		sort(c+1,c+n+1,cmp);
		int ans=0;
		for(int i=1;i<=MIN;i++)
		ans+=c[i].x*2;
		int e=b-MIN;
		for(int i=MIN+1;i<=n;i++){
			if(c[i].x>c[i].y&&e)
			ans+=c[i].x,e--;
			else
			ans+=c[i].y;
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+7;
struct node
{
	int x,y,q;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.q>f.q;
}
bool cmp2(node e,node f)
{
	return e.x-e.y>f.x-f.y;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c[i].x,&c[i].y);
			c[i].q=c[i].x*pow(2,a)-c[i].y;
		}
		sort(c+1,c+n+1,cmp);
		int ans=0;
		if(a)
		ans+=c[1].x*pow(2,a),b--;
		else
		{
			if(c[1].x>c[1].y&&b)
			ans+=c[1].x,b--;
			else
			ans+=c[1].y;
		}
	//	sort(c+1,c+n+1,cmp2);
		for(int i=2;i<=n;i++){
			if(c[i].x>c[i].y&&b)
			ans+=c[i].x,b--;
			else
			ans+=c[i].y;
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+7;
struct node
{
	int x,y,q,id;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.q>f.q;
}
bool cmp2(node e,node f)
{
	return e.x-e.y>f.x-f.y;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c[i].x,&c[i].y);
			c[i].q=c[i].x*pow(2,a)-c[i].y;
			c[i].id=i;
		}
		sort(c+1,c+n+1,cmp);
		int ans=0,p=c[1].id;
		if(a)
		ans+=c[1].x*pow(2,a),b--;
		else
		{
			if(c[1].x>c[1].y&&b)
			ans+=c[1].x,b--;
			else
			ans+=c[1].y;
		}
	//	printf("%d %d\n",ans,c[1].x);
		sort(c+1,c+n+1,cmp2);
		for(int i=1;i<=n;i++){
			if(p==c[i].id)
			continue;
			if(c[i].x>c[i].y&&b)
			ans+=c[i].x,b--;
			else
			ans+=c[i].y;
	//		printf("%d %d %d\n",ans,c[i].y,c[i].x);
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+7;
struct node
{
	int x,y,q;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.x>f.x;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c[i].x,&c[i].y);
			c[i].q=c[i].x-c[i].y;
		}
		sort(c+1,c+n+1,cmp);
		int ans=0;
		if(a)
		ans+=c[1].x*pow(2,a);
		else
		{
			if(c[1].x>c[1].y)
			ans+=c[1].x,b--;
			else
			ans+=c[1].y;
		}
		for(int i=2;i<=n;i++){
			if(c[i].x>c[i].y&&b)
			ans+=c[i].x,b--;
			else
			ans+=c[i].y;
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+7;
struct node
{
	int x,y,q;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.q>f.q;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c[i].x,&c[i].y);
			c[i].q=c[i].x*pow(2,a)-c[i].y;
		}
		sort(c+1,c+n+1,cmp);
		int ans=0;
		if(a)
		ans+=c[1].x*pow(2,a);
		else
		{
			if(c[1].x>c[1].y&&b)
			ans+=c[1].x,b--;
			else
			ans+=c[1].y;
		}
		for(int i=2;i<=n;i++){
			if(c[i].x>c[i].y&&b)
			ans+=c[i].x,b--;
			else
			ans+=c[i].y;
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long int
const int MAXN=2*1e5+7;
struct node
{
	LL x,y,q,d;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.d>f.d;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		LL p=1<<a,ans=0,sum=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%lld%lld",&c[i].x,&c[i].y);
			c[i].q=c[i].x*p;
			c[i].d=max(0ll,c[i].x-c[i].y);
			sum+=c[i].y;
		}
		b=min(n,b);
		if(b==0)
		{
			printf("%lld\n",sum);
			continue;
		}
		LL temp=0;
		sort(c+1,c+n+1,cmp);
		for(int i=1;i<=b;i++)
		temp+=c[i].d;
		for(int i=1;i<=b;i++)
		ans=max(ans,temp-c[i].d+c[i].q-c[i].y);
		for(int i=b+1;i<=n;i++)
		ans=max(ans,temp-c[b].d+c[i].q-c[i].y);
		printf("%lld\n",ans+sum);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long int
const int MAXN=2*1e5+7;
struct node
{
	LL x,y,q,d;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.d>f.d;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		LL p=1<<a,ans=0,sum=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%lld%lld",&c[i].x,&c[i].y);
			c[i].q=c[i].x*p;
			c[i].d=c[i].x-c[i].y;
			sum+=c[i].y;
		}
		b=min(n,b);
		if(b==0)
		{
			printf("%lld\n",sum);
			continue;
		}
		LL temp=0;
		sort(c+1,c+n+1,cmp);
		for(int i=1;i<=b;i++)
		temp+=c[i].d;
		for(int i=1;i<=b;i++)
		ans=max(ans,temp-c[i].d+c[i].q-c[i].y);
		for(int i=b+1;i<=n;i++)
		ans=max(ans,temp-c[b].d+c[i].q-c[i].y);
		printf("%lld\n",ans+sum);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+7;
struct node
{
	int x,y,q;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.q>f.q;
}
bool cmp2(node e,node f)
{
	return e.x-e.y>f.x-f.y;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c[i].x,&c[i].y);
			c[i].q=c[i].x*pow(2,a)-c[i].y;
		}
		sort(c+1,c+n+1,cmp);
		int ans=0;
		if(a)
		ans+=c[1].x*pow(2,a),b--;
		else
		{
			if(c[1].x>c[1].y&&b)
			ans+=c[1].x,b--;
			else
			ans+=c[1].y;
		}
		sort(c+1,c+n+1,cmp2);
		for(int i=2;i<=n;i++){
			if(c[i].x>c[i].y&&b)
			ans+=c[i].x,b--;
			else
			ans+=c[i].y;
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long int
const int MAXN=2*1e5+7;
struct node
{
	LL x,y,q,d;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.d>f.d;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		LL p=1<<a,ans=0,sum=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%lld%lld",&c[i].x,&c[i].y);
			c[i].q=c[i].x*p;
			c[i].d=max(0ll,c[i].x-c[i].y);
			sum+=c[i].y;
		}
		b=min(n,b);
		LL temp=0;
		sort(c+1,c+n+1,cmp);
		for(int i=1;i<=b;i++)
		temp+=c[i].d;
		for(int i=1;i<=b;i++)
		ans=max(ans,temp-c[i].d+c[i].q-c[i].y);
		for(int i=b+1;i<=n;i++)
		ans=max(ans,temp-c[b].d+c[i].q-c[i].y);
		printf("%lld\n",ans+sum);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+7;
struct node
{
	int x,y,q;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.q>f.q;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c[i].x,&c[i].y);
			c[i].q=c[i].x*pow(2,a)-c[i].y;
		}
		sort(c+1,c+n+1,cmp);
		int ans=0;
		if(a)
		ans+=c[1].x*pow(2,a);
		else
		{
			if(c[1].x>c[1].y)
			ans+=c[1].x,b--;
			else
			ans+=c[1].y;
		}
		for(int i=2;i<=n;i++){
			if(c[i].x>c[i].y&&b)
			ans+=c[i].x,b--;
			else
			ans+=c[i].y;
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long int
const int MAXN=2*1e5+7;
struct node
{
	LL x,y,q,id;
}c[MAXN];
bool cmp(node e,node f)
{
	return e.q>f.q;
}
bool cmp2(node e,node f)
{
	return e.x-e.y>f.x-f.y;
}
int main()
{
	int n,a,b;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		int MIN=min(a,b);
		for(int i=1;i<=n;i++)
		{
			scanf("%lld%lld",&c[i].x,&c[i].y);
			c[i].q=c[i].x*pow(2,a)-c[i].y;
			c[i].id=i;
		}
		sort(c+1,c+n+1,cmp);
		LL ans=0,p=c[1].id;
		if(a)
		ans+=c[1].x*pow(2,a),b--;
		else
		{
			if(c[1].x>c[1].y&&b)
			ans+=c[1].x,b--;
			else
			ans+=c[1].y;
		}
	//	printf("%d %d\n",ans,c[1].x);
		sort(c+1,c+n+1,cmp2);
		for(int i=1;i<=n;i++){
			if(p==c[i].id)
			continue;
			if(c[i].x>c[i].y&&b)
			ans+=c[i].x,b--;
			else
			ans+=c[i].y;
	//		printf("%d %d %d\n",ans,c[i].y,c[i].x);
		}
		printf("%lld\n",ans);
	}
}


//#include<math.h>
#include<vector>
#include<time.h>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define vint vector<int>
#define itn int
#define ll long long
#define _s(x) scanf("%s",x)
#define con continue
#define gtc getchar()
#define itr iterator
#define emp empty()
#define siz size()
#define ins insert
#define ptc putchar
#define lb(x) ((x)&-(x))
#define bt(x,i) ((x)&(1<<(i)))
#define __ printf
#define dou double
#define eps 0.00000000001
#define llma 1010000000000000000ll
#define rint register int
#define opr operator
#define cl(x,a) memset(x,a,sizeof(x))
#define fo0(i,k) for(i=fr[k];i;i=nx[i])
#define fo1(i,l,r) for(i=l;i<=r;i++)
#define fo2(i,l,r) for(i=l;i>=r;i--)
#define fo(i,n) for(i=1;i<=n;i++)
#define x first
#define cint const int
#define y second
#define opi(x) freopen(x,"r",stdin)
#define opo(x) freopen(x,"w",stdout)
#define tpl template<typename T>
#define priq priority_queue
#define priq1(t) priority_queue<t,vector<t>,greater<t> >
#define mp make_pair
#define use using namespace
#define pb push_back
#define pint pair<int,int>
use std;
cint N=533333,EE=100000000,GG=1000000000,ima=2147483647;
int eq(dou a,dou b){return a+eps>=b&&b+eps>=a;}
tpl void _ma(T &a,T b){if(a<b)a=b;}tpl void _mi(T &a,T b){if(a>b)a=b;}
namespace io
{
	void _(int &k){char c;int e=1;k=0;while((c=gtc)>'9'||c<'0')if(c=='-')e=-1;k=c-'0';while((c=gtc)<='9'&&c>='0'){k*=10;k+=c-'0';}k*=e;}
	void _(ll &k){char c;int e=1;k=0;while((c=gtc)>'9'||c<'0')if(c=='-')e=-1;k=c-'0';while((c=gtc)<='9'&&c>='0'){k*=10;k+=c-'0';}k*=e;}
	void _(int &a,int &b){_(a);_(b);}void _(int &a,int &b,int &c,int &d,int &e){_(a);_(b);_(c);_(d);_(e);}
	void _(int &a,int &b,int &c,int &d){_(a);_(b);_(c);_(d);}void _(int &a,int &b,int &c){_(a);_(b);_(c);}
	void _(ll &a,ll &b){_(a);_(b);}void _(ll &a,ll &b,ll &c,ll &d,ll &e){_(a);_(b);_(c);_(d);_(e);}
	void _(ll &a,ll &b,ll &c){_(a);_(b);_(c);}void _(ll &a,ll &b,ll &c,ll &d){_(a);_(b);_(c);_(d);}
	void _c(char &c){while((c=gtc)==' '||c=='\n');}void _p0(int k){if(k>=10)_p0(k/10);ptc(k%10+'0');}
	void _p0(ll k){if(k>=10)_p0(k/10);ptc(k%10+'0');}void _p(int k){if(k<0){ptc('-');_p0(-k);}else _p0(k);}
	void _p(ll k){if(k<0){ptc('-');_p0(-k);}else _p0(k);}void __p(int k){_p(k);ptc(' ');}
	void _pn(int k){_p(k);ptc('\n');}void __p(ll k){_p(k);ptc(' ');}void _pn(ll k){_p(k);ptc('\n');}
	void _p(int a,int b){__p(a);_pn(b);}void _p(int a,int b,int c){__p(a);__p(b);_pn(c);}
	void _p(int a,int b,int c,int d){__p(a);__p(b);__p(c);_pn(d);}
}
namespace graph
{
	int fr[N],nx[N],t[N],w[N],j2;
	void me(int s1,int t1){nx[++j2]=fr[s1];fr[s1]=j2;t[j2]=t1;}
	void me(int s1,int t1,int w1){nx[++j2]=fr[s1];fr[s1]=j2;t[j2]=t1;w[j2]=w1;}
	void me1(int s1,int t1){me(s1,t1);me(t1,s1);}
	void me1(int s1,int t1,int w1){me(s1,t1,w1);me(t1,s1,w1);}
}
namespace ufs
{
	int fa[N];
	void _init(int n){int i;fo(i,n)fa[i]=i;}
	int fi(int k){return fa[k]=fa[k]==k?k:fi(fa[k]);}
	void hb(int a,int b){a=fi(a);b=fi(b);fa[a]=b;}
}
use io;
int n,m,k;
ll an,sm[N],a1,t;
struct cr
{
	ll a,b;
	ll d()
	{
		return a-b;
	}
}a[N];
int opr <(cr a,cr b)
{
	return a.a-a.b>b.a-b.b;
}
int main()
{
	int i,j,n1;
	_(n,m,k);
	fo(i,n)
	{
		_(a[i].a,a[i].b);
		an+=a[i].b;
	}
	sort(a+1,a+n+1);
	fo(i,n)
	{
		if(a[i].d()<0)
			break;
		sm[i]=sm[i-1]+a[i].d();
	}
	n1=i-1;
	a1=sm[min(k,n1)];
	if(k>n1)
	{
		fo(i,n)
		{
			t=(a[i].a<<m);
			if(i<=n1)
				_ma(a1,sm[n1]+t-a[i].a);
			else
				_ma(a1,sm[n1]+t-a[i].b);
		}
	}
	else
	{
		fo(i,n)
		{
			t=(a[i].a<<m);
			if(i<=k)
				_ma(a1,sm[k]+t-a[i].a);
			else
				_ma(a1,sm[k-1]+t-a[i].b);
		}
	}
	_p(an+a1);
}


//#include<math.h>
#include<vector>
#include<time.h>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define vint vector<int>
#define itn int
#define ll long long
#define _s(x) scanf("%s",x)
#define con continue
#define gtc getchar()
#define itr iterator
#define emp empty()
#define siz size()
#define ins insert
#define ptc putchar
#define lb(x) ((x)&-(x))
#define bt(x,i) ((x)&(1<<(i)))
#define __ printf
#define dou double
#define eps 0.00000000001
#define llma 1010000000000000000ll
#define rint register int
#define opr operator
#define cl(x,a) memset(x,a,sizeof(x))
#define fo0(i,k) for(i=fr[k];i;i=nx[i])
#define fo1(i,l,r) for(i=l;i<=r;i++)
#define fo2(i,l,r) for(i=l;i>=r;i--)
#define fo(i,n) for(i=1;i<=n;i++)
#define x first
#define cint const int
#define y second
#define opi(x) freopen(x,"r",stdin)
#define opo(x) freopen(x,"w",stdout)
#define tpl template<typename T>
#define priq priority_queue
#define priq1(t) priority_queue<t,vector<t>,greater<t> >
#define mp make_pair
#define use using namespace
#define pb push_back
#define pint pair<int,int>
use std;
cint N=533333,EE=100000000,GG=1000000000,ima=2147483647;
int eq(dou a,dou b){return a+eps>=b&&b+eps>=a;}
tpl void _ma(T &a,T b){if(a<b)a=b;}tpl void _mi(T &a,T b){if(a>b)a=b;}
namespace io
{
	void _(int &k){char c;int e=1;k=0;while((c=gtc)>'9'||c<'0')if(c=='-')e=-1;k=c-'0';while((c=gtc)<='9'&&c>='0'){k*=10;k+=c-'0';}k*=e;}
	void _(ll &k){char c;int e=1;k=0;while((c=gtc)>'9'||c<'0')if(c=='-')e=-1;k=c-'0';while((c=gtc)<='9'&&c>='0'){k*=10;k+=c-'0';}k*=e;}
	void _(int &a,int &b){_(a);_(b);}void _(int &a,int &b,int &c,int &d,int &e){_(a);_(b);_(c);_(d);_(e);}
	void _(int &a,int &b,int &c,int &d){_(a);_(b);_(c);_(d);}void _(int &a,int &b,int &c){_(a);_(b);_(c);}
	void _(ll &a,ll &b){_(a);_(b);}void _(ll &a,ll &b,ll &c,ll &d,ll &e){_(a);_(b);_(c);_(d);_(e);}
	void _(ll &a,ll &b,ll &c){_(a);_(b);_(c);}void _(ll &a,ll &b,ll &c,ll &d){_(a);_(b);_(c);_(d);}
	void _c(char &c){while((c=gtc)==' '||c=='\n');}void _p0(int k){if(k>=10)_p0(k/10);ptc(k%10+'0');}
	void _p0(ll k){if(k>=10)_p0(k/10);ptc(k%10+'0');}void _p(int k){if(k<0){ptc('-');_p0(-k);}else _p0(k);}
	void _p(ll k){if(k<0){ptc('-');_p0(-k);}else _p0(k);}void __p(int k){_p(k);ptc(' ');}
	void _pn(int k){_p(k);ptc('\n');}void __p(ll k){_p(k);ptc(' ');}void _pn(ll k){_p(k);ptc('\n');}
	void _p(int a,int b){__p(a);_pn(b);}void _p(int a,int b,int c){__p(a);__p(b);_pn(c);}
	void _p(int a,int b,int c,int d){__p(a);__p(b);__p(c);_pn(d);}
}
namespace graph
{
	int fr[N],nx[N],t[N],w[N],j2;
	void me(int s1,int t1){nx[++j2]=fr[s1];fr[s1]=j2;t[j2]=t1;}
	void me(int s1,int t1,int w1){nx[++j2]=fr[s1];fr[s1]=j2;t[j2]=t1;w[j2]=w1;}
	void me1(int s1,int t1){me(s1,t1);me(t1,s1);}
	void me1(int s1,int t1,int w1){me(s1,t1,w1);me(t1,s1,w1);}
}
namespace ufs
{
	int fa[N];
	void _init(int n){int i;fo(i,n)fa[i]=i;}
	int fi(int k){return fa[k]=fa[k]==k?k:fi(fa[k]);}
	void hb(int a,int b){a=fi(a);b=fi(b);fa[a]=b;}
}
use io;
int n,m,k;
ll an,sm[N],a1,t;
struct cr
{
	ll a,b;
	ll d()
	{
		return a-b;
	}
}a[N];
int opr <(cr a,cr b)
{
	return a.a-a.b>b.a-b.b;
}
int main()
{
	int i,j,n1;
	_(n,m,k);
	fo(i,n)
	{
		_(a[i].a,a[i].b);
		an+=a[i].b;
	}
	sort(a+1,a+n+1);
	fo(i,n)
	{
		if(a[i].d()<0)
			break;
		sm[i]=sm[i-1]+a[i].d();
	}
	n1=i-1;
	a1=sm[min(k,n1)];
	if(!k)
	{
		_pn(an);
		return 0;
	}
	if(k>n1)
	{
		fo(i,n)
		{
			t=(a[i].a<<m);
			if(i<=n1)
				_ma(a1,sm[n1]+t-a[i].a);
			else
				_ma(a1,sm[n1]+t-a[i].b);
		}
	}
	else
	{
		fo(i,n)
		{
			t=(a[i].a<<m);
			if(i<=k)
				_ma(a1,sm[k]+t-a[i].a);
			else
				_ma(a1,sm[k-1]+t-a[i].b);
		}
	}
	_pn(an+a1);
}


#include <algorithm>

using namespace std;

typedef long long ll;

int n, a, b;
ll ans, tmp;

struct Node
{
    ll hp, dm;
}nd[200005];

bool cmp(Node x, Node y)
{
    return x.hp-x.dm>y.hp-y.dm;
}

int main()
{
    cin>>n>>a>>b;
    for(int i=1; i<=n; i++)
        scanf("%I64d %I64d", &nd[i].hp, &nd[i].dm);
    sort(nd+1, nd+1+n, cmp);
    for(int i=1; i<=n; i++)
        if(i<=b)    ans += max(nd[i].hp, nd[i].dm);
        else    ans += nd[i].dm;
    if(b==0){
        printf("%I64d\n", ans);
        return 0;
    }
    tmp = ans;
    for(int i=1; i<=n; i++){
        ll qaq=tmp;
        if(i<=b){
            qaq -= max(nd[i].hp, nd[i].dm);
            qaq += max(nd[i].dm, max(nd[i].hp*(1<<a), nd[i].dm));
            ans = max(ans, qaq);
        }
        else{
            qaq -= nd[i].dm;
            qaq += max(nd[i].dm, max(nd[i].hp*(1<<a), nd[i].dm));
            qaq -= max(nd[b].hp, nd[b].dm);
            qaq += nd[b].dm;
            ans = max(ans, qaq);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define maxn 200007
#define ll long long int
using namespace std;

ll ans=0;
ll hp[maxn],dmg[maxn],vis[maxn]={0};
struct edge{ll v,id;}f[maxn];

inline bool cmp(edge a,edge b){return a.v>b.v;}

inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(ll x){writ(x);putchar('\n');}

int main()
{
	int n,a,b,g=0;
	ll mx=0,mn,id=0,s,num=0;
	n=read(),a=read(),b=read();
	for (int i=1;i<=n;++i) hp[i]=read(),dmg[i]=read();
	if (b==0)
	{
		for (int i=1;i<=n;++i) ans+=dmg[i];
		write(ans);
		return 0;
	}
	ll k=(1<<a);
	for (int i=1;i<=n;++i) f[i].v=hp[i]-dmg[i],f[i].id=i;
	sort(f+1,f+n+1,cmp);
	for (int i=1;i<=b;++i) if (f[i].v>0) s=dmg[f[i].id],id=f[i].id,dmg[f[i].id]=hp[f[i].id],vis[f[i].id]=1,g=i;else break;
	for (int i=1;i<=n;++i) ans+=dmg[i];
	mn=ans;
	for (int i=1;i<=n;++i)
	{
		mx=mn;
		if (vis[i]) mx+=dmg[i]*(k-1);
		else {mx+=hp[i]*k-dmg[i];if (g==b) mx+=s-dmg[id];}
		ans=max(ans,mx);
	}
	write(ans);
	return 0;
}//


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Node{
	ll h, d, g;
};
Node a[200010];

bool cmp(Node p, Node q) {
	return p.h - p.d > q.h - q.d;
}

int n, sum, b;

ll p,maxx,kkk,ans;

int main() {
	scanf("%d %d %d", &n, &sum, &b);
	p = 1 << sum;
	for (int i = 1; i <= n; i++) {
		scanf("%I64d %I64d", &a[i].h, &a[i].d);
		ans+=a[i].d;
		a[i].g = a[i].h * p - a[i].d;
		maxx=max(a[i].g,maxx);
		if(a[i].g==maxx) kkk=i;
	}
	if(b==0)
	{
		cout<<ans;
		return 0;
	}
	if(a==0){
		sort(a + 1, a + 1 + n, cmp);
		for(int i=1;i<=b;i++){
			if(a[i].h<a[i].d) break;
			ans+=a[i].h-a[i].d;
		}
		printf("%I64d\n",ans);
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(i==kkk)ans+=a[i].g;

	}
	sort(a + 1, a + 1 + n, cmp);
	for(int i=1;i<=b-1;i++)
	{
		if (i == kkk) {
			continue;
		}
		if(a[i].h<a[i].d) break;
		ans+=a[i].h-a[i].d;
	}
	cout<<ans;
}


//============================================================================
// Name        : e.cpp
// Author      : ququuy
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cstdio>
#include <algorithm>
#define LL long long
#define N 200200
using namespace std;

int a, b, n;
LL ans;
struct nod{
	LL hp, dmg;
}node[N];
LL calcu_a(nod x){
	return (x.hp<<a) - max(x.hp, x.dmg);
}
LL calcu_b(nod x){
	return x.hp - x.dmg;
}
bool cmpa(nod x, nod y){
	return calcu_a(x) > calcu_a(y);
}
bool cmpb(nod x, nod y){
	return calcu_b(x) > calcu_b(y);
}
int main() {
	scanf("%d%d%d", &n, &a, &b);
	for(int i = 1; i <= n; ++i) {
		scanf("%I64d%I64d", &node[i].hp, &node[i].dmg);
	}
	int i = 1;
	if(b){

		sort(node+1, node+1+n, cmpa);
		node[1].hp <<= a;

		sort(node+1, node+1+n, cmpb);
		for(i = 1; i <= n && i <= b; ++i){
			ans += max(node[i].hp, node[i].dmg);
		}
	}
	/*else if(a){
		for(int k = 1; k <= a; ++k){
			sort(node+1, node+1+n, cmpa);
			node[1].hp <<= 1;
		}
	}*/

	for(; i <= n; ++i) ans += node[i].dmg;

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

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Node{
	ll h, d, g;
};
Node a[200010];

bool cmp(Node p, Node q) {
	return p.h - p.d > q.h - q.d;
}

int n, sum, b;

ll p,maxx,kkk,ans;

int main() {
	scanf("%d %d %d", &n, &sum, &b);
	p = 1 << sum;
	for (int i = 1; i <= n; i++) {
		scanf("%I64d %I64d", &a[i].h, &a[i].d);
		ans+=a[i].d;
		a[i].g = a[i].h * p - a[i].d;
		maxx=max(a[i].g,maxx);
		if(a[i].g==maxx) kkk=i;
	}
	if(b==0)
	{
		cout<<ans;
		return 0;
	}
	if(a==0){
		sort(a + 1, a + 1 + n, cmp);
		for(int i=1;i<=b;i++){
			if(a[i].h<a[i].d) break;
			ans+=a[i].h-a[i].d;
		}
		printf("%I64d\n",ans);
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(i==kkk)ans+=a[i].g;
	}

	for(int i=1;i<=b-1;i++)
	{
		if(a[i].h<a[i].d) break;
		ans+=a[i].h-a[i].d;
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
ll p[10000001];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        scanf("%I64d", a+i);
    ll lo = 0;
    ll hi = 10000001;
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        fill(p, p+mid, 0);
        for(int i=mid; i<10000001; i++){
            p[i] = max(1LL, p[i/2]+p[i-i/2]);
        }
        for(int i=0; i<n; i++){
            tk += p[a[i]];
        }
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n, k, a, z;
    priority_queue<long long> pq;
    while(cin >> n >> k){
        while(!pq.empty())
            pq.pop();
        for(int i=0; i<n; i++){
            cin >> a;
            pq.push(a);
        }
        while(n < k){
            z = pq.top();
            pq.pop();

            if(z == 1) break;
            n++;
            pq.push(z/2);
            pq.push(z/2+(z%2));
        }
        //cout << "n" << n << endl;
        if(n < k) cout << -1 << endl;
        else {
            while(--k) pq.pop();
            cout << pq.top() << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int p[10000001];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000001;
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        fill(p, p+mid, 0);
        fill(p+mid, p+min(2*mid, 10000001LL), 1);
        for(int i=min(2*mid, 10000000LL); i<10000001; i++){
            p[i] = p[i/2]+p[i-i/2];
        }
        for(int i=0; i<n; i++){
            tk += p[a[i]];
        }
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000000;
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        for(int i=0; i<n; i++){
            ll tmp = a[i];
            ll tx = 0;
            if(tmp >= mid) tx = 1;
            while(tmp/2 >= mid){
                tx *= 2;
                tmp /= 2;
            }
            tk += tx;
        }
        //cout << lo << " " << hi << " " << mid << " " << tk << endl;
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int p[10000001];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000000;
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        fill(p, p+mid, 0);
        fill(p+mid, p+min(2*mid, 10000001LL), 1);
        for(int i=min(2*mid, 10000000LL); i<10000001; i++){
            p[i] = p[i/2]+p[i-i/2];
        }
        for(int i=0; i<n; i++){
            tk += p[a[i]];
        }
        //cout << lo << " " << hi << " " << mid << " " << tk << endl;
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int cache[10000000];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000000;
    int v;
    for(int i=0; i<31; i++){
        v = (1<<i);
        for(int j=0; j<v && v < 10000000; j++){
            if(v+j < 10000000)
                cache[v+j] = v;
        }
    }
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        for(int i=0; i<n; i++){
            //cout << a[i]/mid << " " << cache[a[i]/mid] << endl;
            tk += cache[a[i]/mid];
        }
        //cout << lo << " " << hi << " " << mid << " " << tk << endl;
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int p[10000001];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000000;
    while(lo+1 < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        fill(p, p+mid, 0);
        fill(p+mid, p+min(2*mid, 10000001LL), 1);
        for(int i=min(2*mid, 10000000LL); i<10000001; i++){
            p[i] = p[i/2]+p[i-i/2];
        }
        for(int i=0; i<n; i++){
            tk += p[a[i]];
        }
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n, k, a, z;
    priority_queue<int> pq;
    while(cin >> n >> k){
        while(!pq.empty())
            pq.pop();
        for(int i=0; i<n; i++){
            cin >> a;
            pq.push(a);
        }
        while(n < k){
            z = pq.top();
            pq.pop();
            if(z == 1) break;
            n++;
            pq.push(z/2);
            pq.push(z-z/2);
        }
        //cout << "n" << n << endl;
        if(n < k) cout << -1 << endl;
        else {
            while(--k) pq.pop();
            cout << pq.top() << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int cache[10000000];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000000;
    int v;
    for(int i=0; i<31; i++){
        v = (1<<i);
        for(int j=0; j<v && v <= 10000000; j++){
            if(v+j <= 10000000)
                cache[v+j] = v;
        }
    }
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        for(int i=0; i<n; i++){
            tk += cache[a[i]/mid];
        }
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int cache[10000000];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000000;
    int v;
    for(int i=0; i<31; i++){
        v = (1<<i);
        for(int j=0; j<v && v < 10000000; j++){
            if(v+j <= 10000000)
                cache[v+j] = v;
        }
    }
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        for(int i=0; i<n; i++){
            tk += cache[a[i]/mid];
        }
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, a[1000000];
int cache[10000001];
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll lo = 0;
    ll hi = 10000000;
    int v;
    fill(cache, cache+10000001, 0);
    for(int i=0; i<31; i++){
        v = (1<<i);
        for(int j=0; j<v && v <= 10000000; j++){
            if(v+j <= 10000000)
                cache[v+j] = v;
        }
    }
    while(lo < hi){
        ll mid = lo+(hi-lo+1)/2;
        ll tk = 0;
        for(int i=0; i<n; i++){
            tk += cache[a[i]/mid];
        }
        if(tk < k) hi = mid-1;
        else lo = mid;
    }
    cout << (lo ? lo : -1) << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 10000010
#define upp (mx+1)/2
#define low mx/2
#define nwc cnt[mx]
ll n,k,i,nw,mx,ans,cnt[N];
inline int rd(){int t;scanf("%d",&t);mx=max(mx,0ll+t);return t;}
int main(){
	n=rd(),k=rd(),mx=0;
	for (i=1;i<=n;i++) ++cnt[rd()];
	for (nw=cnt[ans=mx];nw<k&&ans!=0;nw+=cnt[--ans]){
		while (upp>=ans-1) {if (upp==ans) nw+=nwc;
			cnt[upp]+=nwc,cnt[low]+=nwc,nw-=nwc,mx--;
		}
	}
	cout<<(ans?ans:-1)<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 10000010
#define upp (mx+1)/2
#define low mx/2
#define nwc cnt[mx]
ll n,k,i,nw,mx,ans,cnt[N];
inline int rd(){int t;scanf("%d",&t);mx=max(mx,0ll+t);return t;}
int main(){
	n=rd(),k=rd(),mx=0;
	for (i=1;i<=n;i++) ++cnt[rd()];
	for (nw=cnt[ans=mx];nw<k&&ans!=0;nw+=cnt[--ans]){
		while (upp>=ans-1) {if (upp>=ans) nw+=nwc;if (low>=ans) nw+=nwc;
			cnt[upp]+=nwc,cnt[low]+=nwc,nw-=nwc,mx--;
		}if (nw>=k) break;
	}
	cout<<(ans?ans:-1)<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 10000010
#define upp (mx+1)/2
#define low mx/2
#define nwc cnt[mx]
ll n,k,i,nw,mx,ans,cnt[N];
inline int rd(){int t;scanf("%d",&t);mx=max(mx,0ll+t);return t;}
int main(){
	//freopen("1.in","r",stdin);
	n=rd(),k=rd(),mx=0;
	for (i=1;i<=n;i++) ++cnt[rd()];
	for (nw=cnt[ans=mx];nw<k&&ans!=0;nw+=cnt[--ans]){
		while (mx>=2 && upp>=ans-1) {
			cnt[upp]+=nwc,cnt[low]+=nwc,nw-=nwc,cnt[mx]=0,mx--;
		}
	}
	cout<<(ans?ans:-1)<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 10000010
#define upp (mx+1)/2
#define low mx/2
#define nwc cnt[mx]
ll n,k,i,nw,mx,ans,cnt[N];
inline int rd(){int t;scanf("%d",&t);mx=max(mx,0ll+t);return t;}
int main(){
	n=rd(),k=rd(),mx=0;
	for (i=1;i<=n;i++) ++cnt[rd()];
	for (nw=cnt[ans=mx];nw<k&&ans!=0;nw+=cnt[--ans]){
		ans=ans+1-1;
		while (upp>=ans-1) {
			cnt[upp]+=nwc,cnt[low]+=nwc,nw-=nwc,mx--;
		}
	}
	cout<<(ans?ans:-1)<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 10000010
#define upp (mx+1)/2
#define low mx/2
#define nwc cnt[mx]
ll n,k,i,nw,mx,ans,cnt[N];
inline int rd(){int t;scanf("%d",&t);mx=max(mx,0ll+t);return t;}
int main(){
	n=rd(),k=rd();
	for (i=1;i<=n;i++) ++cnt[rd()];
	for (nw=cnt[ans=mx];nw<k&&ans;nw+=cnt[--ans])
		while (upp>=ans-1) {
			cnt[upp]+=nwc,cnt[low]+=nwc,nw-=nwc,mx--;
		}
	cout<<(ans?ans:-1)<<"\n";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	return getcount(val>>1,num) + getcount((val+1)>>1,num);

}

LL count(LL num)
{
	LL sum=0,i;

	//memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

	cin>>n >>k;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		if(count(m)>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(count(m)>=k)
			l=m+1;
		else
			r=m-1;
	}

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		int cm =count(m);
		if(cm>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(cm>=k)
			l=m+1;
		else
			r=m-1;
	}

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

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>2,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

	cin>>n >>k;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		if(count(m)>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(count(m)>=k)
			l=m+1;
		else
			r=m-1;
	}

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < (num<<1)) return 1;

	if(dp[val]==-1)
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);

	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	sort(a,a+n,greater<int>());

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		int cm =count(m);
		if(cm>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(cm>=k)
			l=m+1;
		else
			r=m-1;
	}

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

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < (num<<1)) return 1;

	if(dp[val] !=0)
		return dp[val];

	else if(val&1)
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	else
		dp[val] = getcount(val>>1,num)<<1;
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,0,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		int cm =count(m);
		if(cm>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(cm>=k)
			l=m+1;
		else
			r=m-1;
	}

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

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		if(count(m)>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(count(m)>=k)
			l=m+1;
		else
			r=m-1;
	}

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < (num<<1)) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		int cm =count(m);
		if(cm>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(cm>=k)
			l=m+1;
		else
			r=m-1;
	}

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

}


#include <bits/stdc++.h>

using namespace std;

// #define pb push_back
// #define mp make_pair
// #define forn(i, n) for (int i = 0; i < (int)(n); ++i)
// typedef  int int;
// typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

int a[1000000],dp[10000001],n,k;

int getcount(int val,int num)
{
	if(val<num) return 0;
	if(val >= num && val < (num<<1)) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	return dp[val];
}

long long int count(int num)
{
	long long int sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	int i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		int cm =count(m);
		if(cm>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(cm>=k)
			l=m+1;
		else
			r=m-1;
	}

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

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef  long long LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL cnt[10000001],sub[10000001],n,k;

// int getcount(int val,int num)
// {
// 	if(val<num) return 0;
// 	if(val >= num && val < (num<<1)) return 1;

// 	if(dp[val] !=-1)
// 		return dp[val];

// 	else
// 		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
// 	return dp[val];
// }

// long long int count(int num)
// {
// 	long long int sum=0,i;

// 	memset(dp,-1,sizeof(dp));

// 	for(i=0;i<n;i++)
// 	{
// 		sum += getcount(a[i],num);
// 		if(sum>=k)
// 			return sum;
// 		//cout<<a[i]<<" i : sum "<<sum<<endl;
// 	}

// 	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
// 	return sum;
// }

int main(int argv, char** args)
{
	int i,ans=-1,l,m,a;
	long long sum=0;

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

	memset(cnt,0,sizeof(cnt));
	memset(sub,0,sizeof(sub));
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		cnt[a]++;

	}

	long long int curr=0;
	for(i=10000000;i>=1;i--)
	{
		curr += cnt[i];
		curr -= sub[i];
		cnt[i>>1] += cnt[i];
		cnt[(i+1)>>1] += cnt[i];
		sub[(i+1)>>1] += cnt[i];

		if(curr>=k)
		{
			printf("%d\n",i );
			return 0;
		}
	}

	cout<<-1<<endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef  long long LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

int a[1000000],dp[10000001],n,k;

int getcount(int val,int num)
{
	if(val<num) return 0;
	if(val >= num && val < (num<<1)) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	return dp[val];
}

long long int count(int num)
{
	long long int sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	int i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		int cm =count(m);
		if(cm>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(cm>=k)
			l=m+1;
		else
			r=m-1;
	}

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

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef  long long LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

int a[1000000],cnt[10000001],sub[10000001],n,k;

// int getcount(int val,int num)
// {
// 	if(val<num) return 0;
// 	if(val >= num && val < (num<<1)) return 1;

// 	if(dp[val] !=-1)
// 		return dp[val];

// 	else
// 		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
// 	return dp[val];
// }

// long long int count(int num)
// {
// 	long long int sum=0,i;

// 	memset(dp,-1,sizeof(dp));

// 	for(i=0;i<n;i++)
// 	{
// 		sum += getcount(a[i],num);
// 		if(sum>=k)
// 			return sum;
// 		//cout<<a[i]<<" i : sum "<<sum<<endl;
// 	}

// 	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
// 	return sum;
// }

int main(int argv, char** args)
{
	int i,r=0,ans=-1,l,m,sum=0;

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

	memset(cnt,0,sizeof(cnt));
	memset(sub,0,sizeof(sub));
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		sum+=a[i];
		r=max(r,a[i]);
	}

	if(sum<k)
	{	cout<<-1<<endl;
		return 0;
	}

	int curr=0;
	for(i=10000000;i>=1;i--)
	{
		curr += cnt[i];
		curr -= sub[i];
		cnt[i>>1] += cnt[i];
		cnt[(i+1)>>1] += cnt[i];
		sub[(i+1)>>1] += cnt[i];

		if(curr>=k)
		{
			printf("%d\n",i );
			return 0;
		}
	}

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

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

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}

	sort(a,a+n,greater<int>());

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		int cm =count(m);
		if(cm>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(cm>=k)
			l=m+1;
		else
			r=m-1;
	}

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

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val/2,num) + getcount((val+1)/2,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL k,i,r=0,ans=-1,l,m;

	cin>>n >>k;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)/2;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		if(count(m)>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(count(m)>=k)
			l=m+1;
		else
			r=m-1;
	}

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef  long long LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000000],cnt[10000001],sub[10000001],n,k;

// int getcount(int val,int num)
// {
// 	if(val<num) return 0;
// 	if(val >= num && val < (num<<1)) return 1;

// 	if(dp[val] !=-1)
// 		return dp[val];

// 	else
// 		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
// 	return dp[val];
// }

// long long int count(int num)
// {
// 	long long int sum=0,i;

// 	memset(dp,-1,sizeof(dp));

// 	for(i=0;i<n;i++)
// 	{
// 		sum += getcount(a[i],num);
// 		if(sum>=k)
// 			return sum;
// 		//cout<<a[i]<<" i : sum "<<sum<<endl;
// 	}

// 	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
// 	return sum;
// }

int main(int argv, char** args)
{
	int i,r=0,ans=-1,l,m;
	long long sum=0;

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

	memset(cnt,0,sizeof(cnt));
	memset(sub,0,sizeof(sub));
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		sum+=a[i];
	}

	if(sum<k)
	{	cout<<-1<<endl;
		return 0;
	}

	int curr=0;
	for(i=10000000;i>=1;i--)
	{
		curr += cnt[i];
		curr -= sub[i];
		cnt[i>>1] += cnt[i];
		cnt[(i+1)>>1] += cnt[i];
		sub[(i+1)>>1] += cnt[i];

		if(curr>=k)
		{
			printf("%d\n",i );
			return 0;
		}
	}

	cout<<1<<endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef  long long LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL cnt[10000001],sub[10000001],n,k;

// int getcount(int val,int num)
// {
// 	if(val<num) return 0;
// 	if(val >= num && val < (num<<1)) return 1;

// 	if(dp[val] !=-1)
// 		return dp[val];

// 	else
// 		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
// 	return dp[val];
// }

// long long int count(int num)
// {
// 	long long int sum=0,i;

// 	memset(dp,-1,sizeof(dp));

// 	for(i=0;i<n;i++)
// 	{
// 		sum += getcount(a[i],num);
// 		if(sum>=k)
// 			return sum;
// 		//cout<<a[i]<<" i : sum "<<sum<<endl;
// 	}

// 	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
// 	return sum;
// }

int main(int argv, char** args)
{
	int i,ans=-1,l,m;
	long long sum=0;

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

	memset(cnt,0,sizeof(cnt));
	memset(sub,0,sizeof(sub));
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;

	}

	long long int curr=0;
	for(i=10000000;i>=1;i--)
	{
		curr += cnt[i];
		curr -= sub[i];
		cnt[i>>1] += cnt[i];
		cnt[(i+1)>>1] += cnt[i];
		sub[(i+1)>>1] += cnt[i];

		if(curr>=k)
		{
			printf("%d\n",i );
			return 0;
		}
	}

	cout<<-1<<endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n,k;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val>>1,num) + getcount((val+1)>>1,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		if(sum>=k)
			return sum;
		//cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	//cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL i,r=0,ans=-1,l,m;

	cin>>n >>k;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)>>1;
		//cout<<l <<" "<<m<<" "<<r<<endl;
		if(count(m)>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(count(m)>=k)
			l=m+1;
		else
			r=m-1;
	}

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long int LL;
typedef pair<int, int> PII;

// void addEdge(int u,int v,list<int> adj[])
// {
// 	adj[u].push_back(v);
// 	adj[v].push_back(u);
// }

// void dfs(int u, int *m, int *n)
// {
// 	//cout<<u<<endl;
// 	vst[u]=1;
// 	*n = *n+1;
// 	*m = *m + adj[u].size();

// 	list<int>::iterator it;

// 	for(it=adj[u].begin();it!=adj[u].end();it++)
// 	{
// 		int v=*it;
// 		if(!vst[v])
// 			dfs(v,m,n);
// 	}

// }

// void f(vector<string> v,int *pos, int lev)
// {
// 	if(*pos>=n)
// 		return;
// 	if(depth < lev)
// 		depth = lev;

// 	ans[lev].push_back(v[(*pos)++]);
// 	int ch = atoi((v[(*pos)++]).c_str());

// 	//cout<<lev<<" "<<v[*pos-2]<<" "<<depth<<" "<<ans[lev].size()<<endl;
// 	for(int i=0;i<ch;i++)
// 		f(v,pos,lev+1);

// 	return;

// }

// char str[1000005];

//long long int a[1000005];

LL a[1000005],dp[10000005],n;

LL getcount(LL val,LL num)
{
	if(val<num) return 0;
	if(val >= num && val < 2*num) return 1;

	if(dp[val] !=-1)
		return dp[val];

	else
		dp[val] = getcount(val/2,num) + getcount((val+1)/2,num);
	return dp[val];
}

LL count(LL num)
{
	LL sum=0,i;

	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++)
	{
		sum += getcount(a[i],num);
		cout<<a[i]<<" i : sum "<<sum<<endl;
	}

	cout<< "num : sum "<<num<<" : "<<sum<<endl;
	return sum;
}

int main(int argv, char** args)
{
	LL k,i,r=0,ans=-1,l,m;

	cin>>n >>k;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		r=max(r,a[i]);
	}

	sort(a,a+n);

	l=1;
	while(l<=r)
	{
		m=(l+r)/2;
		cout<<l <<" "<<m<<" "<<r<<endl;
		if(count(m)>=k && (m==r || count(m+1)<k) )
		{
			ans = m;
			break;
		}
		else if(count(m)>=k)
			l=m+1;
		else
			r=m-1;
	}

	cout<<ans<<endl;

}