#include <bits/stdc++.h>

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";

    return os;
}

ll solve(int N, int A, int B, vector<ii>& xs)
{
    sort(xs.begin(), xs.end(), [](const ii& x, const ii& y) {
        auto a = x.first - x.second;
        auto b = y.first - y.second;

        if (a != b)
            return a > b;

        return x.second > y.second;
    });

    LOGV(xs, endl);

    ll sum = 0;

    for (int i = 0; i < N; ++i)
    {
        auto [h, dmg] = xs[i];

        sum += (i < B ? max(h, dmg) : dmg);
    }

    LOG(sum, endl);

    if (A == 0)
        return sum;

    ll ans = sum, k = (1 << A);

    for (int i = 0; i < N; ++i)
    {
        auto res = sum;
        auto [h, dmg] = xs[i];

        if (i < B)
        {
            sum -= max(h, dmg);
            sum += max(k*h, dmg);
        } else if (B and k*h > dmg)
        {
            sum -= dmg;
            sum += k*h;
            sum -= max(xs[B - 1].first, xs[B - 1].second);
            sum += xs[B - 1].second;
        }

        ans = max(ans, res);
    }

    return ans;

}

int main()
{
    ios::sync_with_stdio(false);

    int N, A, B;
    cin >> N >> A >> B;

    vector<ii> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i].first >> xs[i].second;

    auto ans = solve(N, A, B, xs);

    cout << ans << '\n';

    return 0;
}


#include <bits/stdc++.h>

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";

    return os;
}

ll solve(int N, int A, int B, const vector<ii>& xs)
{
    ll ans = 0, best = 0, v = 0, j = -1;

    for (int i = 0; i < N; ++i)
    {
        auto [h, dmg] = xs[i];

        for (int k = 0; k < A; ++k)
            h *= 2;

        if (h > dmg and (h - dmg > best or (h - dmg == best and xs[i].second < xs[j].second)))
        {
            best = h - dmg;
            v = h;
            j = i;
        }
    }

    LOGM("=== "); LOG(best, ' '); LOG(j, endl);

    if (j >= 0 and B)
    {
        if (v > xs[j].second)
            --B;

        ans += v;
    } else
        j = -1;

    LOG(ans, ' '); LOG(B, endl);

    priority_queue<ii> pq;

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

        auto [h, dmg] = xs[i];

        pq.push(ii(h - dmg, i));
    }

    while (not pq.empty())
    {
        auto [x, i] = pq.top();
        pq.pop();

        LOGM("--- "); LOG(x, ' '); LOG(i, ' '); LOG(xs[i], endl);

        if (x > 0 and B)
        {
            ans += xs[i].first;
            --B;
        } else
            ans += xs[i].second;

        LOG(ans, ' '); LOG(B, endl);
    }

    return ans;

}

int main()
{
    ios::sync_with_stdio(false);

    int N, A, B;
    cin >> N >> A >> B;

    vector<ii> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i].first >> xs[i].second;

    auto ans = solve(N, A, B, xs);

    cout << ans << '\n';

    return 0;
}


#include <bits/stdc++.h>

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = tuple<int, int, int>;

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";

    return os;
}

const int MAX { 410 }, MAXA { 22 }, MAXB { 22 };

ll st[MAX][MAXA][MAXB];
map<iii, int> ps;

ll dp(int i, int a, int b, int N, const vector<ii>& xs)
{
    if (i == N)
        return 0;

    if (st[i][a][b] != -1)
        return st[i][a][b];

    auto [h, dmg] = xs[i];

    auto res = dp(i + 1, a, b, N, xs);

    if (b > 0)
    {
        auto x = h;

        for (int k = 1; k <= a; ++k)
        {
            x *= 2;

            if (x > dmg)
            {
                auto sol = dp(i + 1, a - k, b - 1, N, xs) + (x - dmg);

                if (sol > res)
                {
                    res = sol;
                    ps[iii(i, a, b)] = k;
                }
            }
        }
    }

    st[i][a][b] = res;
    return res;
}

ll solve(int N, int A, int B, const vector<ii>& xs)
{
    priority_queue<ii, vector<ii>, greater<ii>> min_heap;

    for (int i = 0; i < N; ++i)
    {
        auto [h, dmg] = xs[i];

        for (int k = 1; k <= A; ++k)
        {
            h *= 2;

            if (h > dmg)
            {
                min_heap.push(ii(h - dmg, i));

                if (min_heap.size() > MAX)
                    min_heap.pop();
            }
        }
    }

    vector<ii> ys;
    vector<ll> is;
    set<ll> marked;

    while (not min_heap.empty())
    {
        auto [_, j] = min_heap.top();
        min_heap.pop();

        if (not marked.count(j))
        {
            marked.insert(j);
            ys.push_back(xs[j]);
            is.push_back(j);
        }
    }

    ll ans = 0;
    set<ll> used;
    memset(st, -1, sizeof st);

    LOGV(ys, endl);
    LOGV(is, endl);

    dp(0, A, min(B, A), (int) ys.size(), ys);

    int i = 0, a = A, b = min(B, A);

    while (i < N)
    {
        auto k = ps[iii(i, a, b)];

        if (k)
        {
            used.insert(is[i]);

            auto [x, y] = ys[i];

            for (int r = 0; r < k; ++r)
                x *= 2;

            ans += x;

            a -= k;
            b -= 1;
            --B;
        }

        ++i;
    }

    LOG(ans, endl);
    LOGV(used, endl);

    priority_queue<ii> pq;

    for (int j = 0; j < N; ++j)
    {
        if (used.count(j))
            continue;

        auto [h, dmg] = xs[j];

        if (h > dmg)
            pq.push(ii(h - dmg, j));
    }

    while (B and not pq.empty())
    {
        auto [x, j] = pq.top();
        pq.pop();

        ans += xs[j].first;
        used.insert(j);
        --B;
    }

    for (int j = 0; j < N; ++j)
        if (used.count(j) == 0)
            ans += xs[j].second;

    return ans;

}

int main()
{
    ios::sync_with_stdio(false);

    int N, A, B;
    cin >> N >> A >> B;

    vector<ii> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i].first >> xs[i].second;

    auto ans = solve(N, A, B, xs);

    cout << ans << '\n';

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll read() {
	char c; ll x; while (c = getchar(), c<'0' || c>'9'); x = c - '0';
	while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0'; return x;
}
ll n, a, b, pl = 0, tot, ans, all, c[200005];
struct node {
	ll att, def;
}f[200005];
ll pows(ll a, ll b) {
	ll base = 1;
	while (b) {
		if (b & 1) base = base * a;
		a = a * a; b /= 2;
	}
	return base;
}
ll cmp(ll a, ll b) { return a > b; }
int main()
{
	n = read(); a = read(); b = read(); c[0] = 1e18;
	for (ll i = 0; i < n; i++) {
		f[i].def = read(); f[i].att = read(); tot += f[i].att;
		c[i] = f[i].def - f[i].att;
	}
	ans = tot;
	if (b == 0) { printf("%I64d", ans); return 0; }
	sort(c , c  + n, cmp);
	for (ll i = 0; i < b - 1; i++) if (c[i] > 0) all += c[i], pl = i+1;
	for (ll i = 0; i < n; i++) {
		ll x = all;
		if (f[i].def - f[i].att >= c[pl]) x -= f[i].def - f[i].att, x += c[pl] > 0 ? c[pl] : 0;
		x += f[i].def * pows(2, a) - f[i].att;
		ans = max(ans, x + tot);
	}
	printf("%I64d", ans);
	getchar();
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll read(){
    char c;ll x;while(c=getchar(),c<'0'||c>'9');x=c-'0';
    while(c=getchar(),c>='0'&&c<='9') x=x*10+c-'0';return x;
}
ll n,a,b,pl=0,tot,ans,all,c[200005];
struct node{
    ll att,def;
}f[200005];
ll pows(ll a,ll b){
    ll base=1;
    while(b){
        if(b&1) base=base*a;
        a=a*a;b/=2;
    }
    return base;
}
ll cmp(ll a,ll b){return a>b;}
int main()
{
    n=read();a=read();b=read();
    for(ll i=1;i<=n;i++){
        f[i].def=read();f[i].att=read();tot+=f[i].att;
        c[i]=f[i].def-f[i].att;
    }
    ans=tot;
    if(b==0){printf("%I64d",ans);return 0;}
    sort(c+1,c+1+n,cmp);
    for(ll i=1;i<=b-1;i++) if(c[i]>0) all+=c[i],pl=i;
    for(ll i=1;i<=n;i++){
        ll x=all;
        if(f[i].def-f[i].att>=c[pl]) x-=f[i].def-f[i].att,x+=c[pl+1]>0?c[pl+1]:0;
        x+=f[i].def*pows(2,a)-f[i].att;
        ans=max(ans,x+tot);
    }
    printf("%I64d",ans);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
ll pows[]{ 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576 };
inline int read() {
	int X = 0, w = 0; char ch = 0;
	while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
	while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
	return w ? -X : X;
}
inline void out(ll x){
	//if (x < 0) putchar('-'), x = -x;
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
}
ll n,p,q,index=0,atksum,res,sum,tmp,delta[200005];
ll orc[200005][2];//0-hp 1-atk
ll cmp(ll a,ll b){
	return a>b;
}
int main(){
    n=read();p=read();q=read(); delta[0]=1e18;
    for(ll i=1;i<=n;i++){
		orc[i][0]=read(); orc[i][1] =read();
		atksum += orc[i][1];
		delta[i]= orc[i][0] - orc[i][1];
    }
	res = atksum;
	if (q != 0) {
		std::sort(delta + 1, delta + 1 + n, cmp);
		for (ll i = 1; i <= q - 1; i++) {
			if (delta[i] > 0) {
				sum += delta[i];
				index = i;
			}
		}
		for (ll i = 1; i <= n; i++) {
			tmp = sum;
			if (orc[i][0] - orc[i][1] >= delta[index]) {
				tmp -= orc[i][0] - orc[i][1];
				tmp += delta[index + 1] > 0 ? delta[index + 1] : 0;
			}
			tmp += orc[i][0] * pows[p] - orc[i][1];
			res = res > tmp + atksum ? res : tmp + atksum;
		}
	}
    out(res);
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll read() {
	char c; ll x; while (c = getchar(), c<'0' || c>'9'); x = c - '0';
	while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0'; return x;
}
ll n, a, b, pl = 0, tot, ans, all, c[200005];
struct node {
	ll att, def;
}f[200005];
ll pows(ll a, ll b) {
	ll base = 1;
	while (b) {
		if (b & 1) base = base * a;
		a = a * a; b /= 2;
	}
	return base;
}
ll cmp(ll a, ll b) { return a > b; }
int main()
{
	n = read(); a = read(); b = read(); c[0] = 1e18;
	for (ll i = 0; i < n; i++) {
		f[i].def = read(); f[i].att = read(); tot += f[i].att;
		c[i] = f[i].def - f[i].att;
	}
	ans = tot;
	if (b == 0) { printf("%I64d", ans); return 0; }
	sort(c , c  + n, cmp);
	for (ll i = 0; i < b - 1; i++) if (c[i] > 0) all += c[i], pl = i;
	for (ll i = 0; i < n; i++) {
		ll x = all;
		if (f[i].def - f[i].att >= c[pl]) x -= f[i].def - f[i].att, x += c[pl] > 0 ? c[pl] : 0;
		x += f[i].def * pows(2, a) - f[i].att;
		ans = max(ans, x + tot);
	}
	printf("%I64d", ans);
	getchar();
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
ll pows[]{ 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576 };
inline int read() {
	int X = 0, w = 0; char ch = 0;
	while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
	while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
	return w ? -X : X;
}
inline void out(ll x){
	//if (x < 0) putchar('-'), x = -x;
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
}
ll n,a,b,pl=0,atksum,res,sum,delta[200005];
ll orc[200005][2];//0-hp 1-atk
ll cmp(ll a,ll b){
	return a>b;
}
int main(){
    n=read();a=read();b=read(); delta[0]=1e18;
    for(ll i=1;i<=n;i++){
		orc[i][0]=read(); orc[i][1] =read();
		atksum += orc[i][1];
		delta[i]= orc[i][0] - orc[i][1];
    }
	res = atksum;
	if (b != 0) {
		std::sort(delta + 1, delta + 1 + n, cmp);
		for (ll i = 1; i <= b - 1; i++) {
			if (delta[i] > 0) {
				sum += delta[i];
				pl = i;
			}
		}
		for (ll i = 1; i <= n; i++) {
			ll x = sum;
			if (orc[i][0] - orc[i][1] >= delta[pl]) {
				x -= orc[i][0] - orc[i][1];
				x += delta[pl + 1] > 0 ? delta[pl + 1] : 0;
			}
			x += orc[i][0] * pows[a] - orc[i][1];
			res = res > x + atksum ? res : x + atksum;
		}
	}
    printf("%I64d", res);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
ll pows[]{ 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576 };
inline int read() {
	int X = 0, w = 0; char ch = 0;
	while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
	while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
	return w ? -X : X;
}
inline void out(ll x){
	//if (x < 0) putchar('-'), x = -x;
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
}
ll n,p,q,index=0,atksum,res,sum,delta[200005];
ll orc[200005][2];//0-hp 1-atk
ll cmp(ll a,ll b){
	return a>b;
}
int main(){
    n=read();p=read();q=read(); delta[0]=1e18;
    for(ll i=1;i<=n;i++){
		orc[i][0]=read(); orc[i][1] =read();
		atksum += orc[i][1];
		delta[i]= orc[i][0] - orc[i][1];
    }
	res = atksum;
	if (q != 0) {
		std::sort(delta + 1, delta + 1 + n, cmp);
		for (ll i = 1; i <= q - 1; i++) {
			if (delta[i] > 0) {
				sum += delta[i];
				index = i;
			}
		}
		for (ll i = 1; i <= n; i++) {
			ll x = sum;
			if (orc[i][0] - orc[i][1] >= delta[index]) {
				x -= orc[i][0] - orc[i][1];
				x += delta[index + 1] > 0 ? delta[index + 1] : 0;
			}
			x += orc[i][0] * pows[p] - orc[i][1];
			res = res > x + atksum ? res : x + atksum;
		}
	}
    out(res);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll read(){
    char c;ll x;while(c=getchar(),c<'0'||c>'9');x=c-'0';
    while(c=getchar(),c>='0'&&c<='9') x=x*10+c-'0';return x;
}
ll n,a,b,pl=0,tot,ans,all,c[200005];
struct node{
    ll att,def;
}f[200005];
ll pows(ll a,ll b){
    ll base=1;
    while(b){
        if(b&1) base=base*a;
        a=a*a;b/=2;
    }
    return base;
}
ll cmp(ll a,ll b){return a>b;}
int main()
{
    n=read();a=read();b=read();c[0]=1e18;
    for(ll i=1;i<=n;i++){
        f[i].def=read();f[i].att=read();tot+=f[i].att;
        c[i]=f[i].def-f[i].att;
    }
    ans=tot;
    if(b==0){printf("%I64d",ans);return 0;}
    sort(c+1,c+1+n,cmp);
    for(ll i=1;i<=b-1;i++) if(c[i]>0) all+=c[i],pl=i;
    for(ll i=1;i<=n;i++){
        ll x=all;
        if(f[i].def-f[i].att>=c[pl]) x-=f[i].def-f[i].att,x+=c[pl+1]>0?c[pl+1]:0;
        x+=f[i].def*pows(2,a)-f[i].att;
        ans=max(ans,x+tot);
    }
    printf("%I64d",ans);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
ll pows[]{ 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576 };
inline int read() {
	int X = 0, w = 0; char ch = 0;
	while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
	while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
	return w ? -X : X;
}
inline void out(ll x){
	//if (x < 0) putchar('-'), x = -x;
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
}
ll n,a,b,pl=0,tot,ans,all,c[200005];
struct node{
    ll att,def;
}f[200005];
ll cmp(ll a,ll b){
	return a>b;
}
int main(){
    n=read();a=read();b=read();c[0]=1e18;
    for(ll i=1;i<=n;i++){
        f[i].def=read();f[i].att=read();tot+=f[i].att;
        c[i]=f[i].def-f[i].att;
    }
    ans=tot;
	if (b != 0) {
		std::sort(c + 1, c + 1 + n, cmp);
		for (ll i = 1; i <= b - 1; i++) {
			if (c[i] > 0) {
				all += c[i];
				pl = i;
			}
		}
		for (ll i = 1; i <= n; i++) {
			ll x = all;
			if (f[i].def - f[i].att >= c[pl]) {
				x -= f[i].def - f[i].att;
				x += c[pl + 1] > 0 ? c[pl + 1] : 0;
			}
			x += f[i].def * pows[a] - f[i].att;
			ans = ans > x + tot ? ans : x + tot;
		}
	}
    printf("%I64d",ans);
    return 0;
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

bool cmp(const pair<lli, lli> &a, const pair<lli, lli> &b) {
	return(a.first - a.second > b.first - b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a, b; cin >> n >> a >> b;
	vector<pair<lli, lli>> arr;
	for (int i = 0; i < n; i++) {
		lli hp, dmg; cin >> hp >> dmg;
		arr.push_back({ hp,dmg });
	}
	sort(arr.begin(), arr.end(), cmp);
	lli sum = 0; lli temp = b;
	vector<int> inc(n, 0);
	for (int i = 0; i < n; i++) {
		if (arr[i].first - arr[i].second >= 0 && temp) {
			sum += arr[i].first;
			temp--;
			inc[i] = 1;
		}
		else sum += arr[i].second;
	}
	lli ans = sum;
	for (int i = 0; i < n; i++) {
		lli temp = sum;
		temp += ((1 << a) * arr[i].first - ((inc[i]) ? arr[i].first : arr[i].second));
		ans = max(ans, temp);
	}
	cout << ans;
	//system("PAUSE");
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

bool cmp(const pair<lli, lli> &a, const pair<lli, lli> &b) {
	return(a.first - a.second > b.first - b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a, b; cin >> n >> a >> b;
	vector<pair<lli, lli>> arr;
	for (int i = 0; i < n; i++) {
		lli hp, dmg; cin >> hp >> dmg;
		arr.push_back({ hp,dmg });
	}
	sort(arr.begin(), arr.end(), cmp);
	lli sum = 0; lli temp = b;
	vector<int> inc(n, 0);
	for (int i = 0; i < n; i++) {
		if (arr[i].first - arr[i].second >= 0 && temp) {
			sum += arr[i].first;
			temp--;
			inc[i] = 1;
		}
		else sum += arr[i].second;
	}
	lli ans = sum;
	for (int i = 0; i < n &&a &&b; i++) {
		if (inc[i]) {
			lli temp = sum;
			temp += ((1 << a) * arr[i].first - (arr[i].first ));
			ans = max(ans, temp);
		}
		else {
			lli temp = sum;
			temp += (1 << a)*arr[i].first - (arr[i].second);
			temp -= max(arr[b - 1].first,arr[b-1].second); temp += arr[b - 1].second;
			ans = max(ans, temp);
		}
	}
	cout << ans;
	//system("PAUSE");
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

bool cmp(const pair<lli, lli> &a, const pair<lli, lli> &b) {
	return(a.first - a.second > b.first - b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a, b; cin >> n >> a >> b;
	vector<pair<lli, lli>> arr;
	for (int i = 0; i < n; i++) {
		lli hp, dmg; cin >> hp >> dmg;
		arr.push_back({ hp,dmg });
	}
	sort(arr.begin(), arr.end(), cmp);
	lli sum = 0; lli temp = b;
	vector<int> inc(n, 0);
	for (int i = 0; i < n; i++) {
		if (arr[i].first - arr[i].second >= 0 && temp) {
			sum += arr[i].first;
			temp--;
			inc[i] = 1;
		}
		else sum += arr[i].second;
	}
	lli ans = sum;
	for (int i = 0; i < n &&a; i++) {
		lli temp = sum;
		temp += ((1 << a) * arr[i].first - ((inc[i]) ? arr[i].first : arr[i].second));
		ans = max(ans, temp);
	}
	cout << ans;
	//system("PAUSE");
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

bool cmp(const pair<lli, lli> &a, const pair<lli, lli> &b) {
	return(a.first - a.second > b.first - b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	lli n, a, b; cin >> n >> a >> b;
	vector<pair<lli, lli>> arr;
	for (int i = 0; i < n; i++) {
		lli hp, dmg; cin >> hp >> dmg;
		arr.push_back({ hp,dmg });
	}
	sort(arr.begin(), arr.end(), cmp);
	lli sum = 0; lli temp = b;
	vector<int> inc(n, 0);
	for (int i = 0; i < n; i++) {
		if (arr[i].first - arr[i].second >= 0 && temp) {
			sum += arr[i].first;
			temp--;
			inc[i] = 1;
		}
		else sum += arr[i].second;
	}
	lli ans = sum;
	for (int i = 0; i < n &&a &&b; i++) {
		if (inc[i]) {
			lli temp = sum;
			temp += ((1 << a) * arr[i].first - (arr[i].first ));
			ans = max(ans, temp);
		}
		else {
			lli temp = sum;
			temp += (1 << a)*arr[i].first - (arr[i].second);
			temp -= max(arr[min(b - 1,n-1)].first,arr[min(b-1,n-1)].second); temp += arr[min(b - 1,n-1)].second;
			ans = max(ans, temp);
		}
	}
	cout << ans;
	//system("PAUSE");
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

bool cmp(const pair<lli, lli> &a, const pair<lli, lli> &b) {
	return(a.first - a.second > b.first - b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a, b; cin >> n >> a >> b;
	vector<pair<lli, lli>> arr;
	for (int i = 0; i < n; i++) {
		lli hp, dmg; cin >> hp >> dmg;
		arr.push_back({ hp,dmg });
	}
	sort(arr.begin(), arr.end(), cmp);
	lli sum = 0; lli temp = b;
	vector<int> inc(n, 0);
	for (int i = 0; i < n; i++) {
		if (arr[i].first - arr[i].second >= 0 && temp) {
			sum += arr[i].first;
			temp--;
			inc[i] = 1;
		}
		else sum += arr[i].second;
	}
	lli ans = sum;
	for (int i = 0; i < n &&a; i++) {
		if (inc[i]) {
			lli temp = sum;
			temp += ((1 << a) * arr[i].first - (arr[i].first ));
			ans = max(ans, temp);
		}
		else {
			lli temp = sum;
			temp += (1 << a)*arr[i].first - (arr[i].second);
			temp -= arr[b - 1].first; temp += arr[b - 1].second;
			ans = max(ans, temp);
		}
	}
	cout << ans;
	//system("PAUSE");
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

bool cmp(const pair<lli, lli> &a, const pair<lli, lli> &b) {
	return(a.first - a.second > b.first - b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a, b; cin >> n >> a >> b;
	vector<pair<lli, lli>> arr;
	for (int i = 0; i < n; i++) {
		lli hp, dmg; cin >> hp >> dmg;
		arr.push_back({ hp,dmg });
	}
	sort(arr.begin(), arr.end(), cmp);
	lli sum = 0; lli temp = b;
	vector<int> inc(n, 0);
	for (int i = 0; i < n; i++) {
		if (arr[i].first - arr[i].second >= 0 && temp) {
			sum += arr[i].first;
			temp--;
			inc[i] = 1;
		}
		else sum += arr[i].second;
	}
	lli ans = sum;
	for (int i = 0; i < n &&a; i++) {
		if (inc[i]) {
			lli temp = sum;
			temp += ((1 << a) * arr[i].first - (arr[i].first ));
			ans = max(ans, temp);
		}
		else {
			lli temp = sum;
			temp += (1 << a)*arr[i].first - (arr[i].second);
			temp -= max(arr[b - 1].first,arr[b-1].second); temp += arr[b - 1].second;
			ans = max(ans, temp);
		}
	}
	cout << ans;
	//system("PAUSE");
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<cerrno>
#include<cfenv>

typedef long long int lli;
typedef long long ll;
typedef double long dl;
using namespace std;

const int mod = 998244353;
const dl pi = std::acos(-1);

ll gcd(ll a, ll b) {
	if (!b) {
		return a;
	}
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y & 1) {
			res = (res * x) % mod;
		}
		y >>= 1;
		x = (x * x) % mod;
	}
	return res;
}

ll inverse(ll x) {
	return power(x, mod - 2);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		int n, a, b;
		cin >> n >> a >> b;
		ll temp = 1;
		while (a--) {
			temp <<= 1;
		}
		vector<pair<ll, ll>>aa(n);
		for (int i = 0; i < n; i += 1) {
			cin >> aa[i].first >> aa[i].second;
		}
		ll ans3 = 0;
		vector<pair<ll, int>>x;
		for (int i = 0; i < n; i += 1) {
			x.push_back({ max(aa[i].first - aa[i].second,0LL),i });
		}
		sort(x.begin(), x.end());
		reverse(x.begin(), x.end());
		ll ans = 0;
		for (int i = 0; i < n; i += 1) {
			ans3 += aa[i].second;
		}
		if (!b) {
			cout << ans << "\n";
			continue;
		}
		ll ans2 = 0;
		for (int i = 0; i < min(b, n); i += 1) {
			ans2 += x[i].first;
		}
		for (int i = 0; i < n; i += 1) {
			if (i < b) {
				ans = max(ans, ans2 - x[i].first + max(temp * aa[x[i].second].first, aa[x[i].second].second) - aa[x[i].second].second);
			}
			else {
				ans = max(ans, ans2 - x[b-1].first + max(temp * aa[x[i].second].first, aa[x[i].second].second) - aa[x[i].second].second);
			}
		}
		cout << ans + ans3 << "\n";
	}
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<cerrno>
#include<cfenv>

typedef long long int lli;
typedef long long ll;
typedef double long dl;
using namespace std;

const int mod = 998244353;
const dl pi = std::acos(-1);

ll gcd(ll a, ll b) {
	if (!b) {
		return a;
	}
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y & 1) {
			res = (res * x) % mod;
		}
		y >>= 1;
		x = (x * x) % mod;
	}
	return res;
}

ll inverse(ll x) {
	return power(x, mod - 2);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		int n, a, b;
		cin >> n >> a >> b;
		ll temp = 1;
		while (a--) {
			temp <<= 1;
		}
		vector<pair<ll, ll>>aa(n);
		for (int i = 0; i < n; i += 1) {
			cin >> aa[i].first >> aa[i].second;
		}
		int idx = -1;
		ll idx_check = 0;
		for (int i = 0; i < n; i += 1) {
			if (idx_check < max(aa[i].first * temp, aa[i].second)-aa[i].second) {
				idx = i;
				idx_check = max(aa[i].first * temp, aa[i].second) - aa[i].second;
			}
		}
		vector<pair<ll, int>>x;
		for (int i = 0; i < n; i += 1) {
			if (aa[i].first > aa[i].second) {
				x.push_back({ aa[i].first - aa[i].second,i });
			}
		}
		sort(x.begin(), x.end());
		reverse(x.begin(), x.end());
		ll ans = 0;
		for (int i = 0; i < n; i += 1) {
			if (b && i == idx && idx_check > 0) {
				b -= 1;
				ans += idx_check;
			}
			ans += aa[i].second;
		}
		if (!b) {
			cout << ans << "\n";
			continue;
		}
		for (auto y : x) {
			if (y.second != idx) {
				ans += y.first;
				b -= 1;
				if (!b) {
					break;
				}
			}
		}
		cout << ans << "\n";
	}
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<cerrno>
#include<cfenv>

typedef long long int lli;
typedef long long ll;
typedef double long dl;
using namespace std;

const int mod = 998244353;
const dl pi = std::acos(-1);

ll gcd(ll a, ll b) {
	if (!b) {
		return a;
	}
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y & 1) {
			res = (res * x) % mod;
		}
		y >>= 1;
		x = (x * x) % mod;
	}
	return res;
}

ll inverse(ll x) {
	return power(x, mod - 2);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		int n, a, b;
		cin >> n >> a >> b;
		ll temp = 1;
		while (a--) {
			temp <<= 1;
		}
		vector<pair<ll, ll>>aa(n);
		for (int i = 0; i < n; i += 1) {
			cin >> aa[i].first >> aa[i].second;
		}
		int idx = -1;
		ll idx_check = 0;
		for (int i = 0; i < n; i += 1) {
			if (idx_check < max(aa[i].first * temp, aa[i].second)) {
				idx = i;
				idx_check = max(aa[i].first * temp, aa[i].second) - aa[i].second;
			}
		}
		vector<pair<ll, int>>x;
		for (int i = 0; i < n; i += 1) {
			if (aa[i].first > aa[i].second) {
				x.push_back({ aa[i].first - aa[i].second,i });
			}
		}
		sort(x.begin(), x.end());
		reverse(x.begin(), x.end());
		ll ans = 0;
		for (int i = 0; i < n; i += 1) {
			if (b && i == idx && idx_check > 0) {
				b -= 1;
				ans += idx_check;
			}
			ans += aa[i].second;
		}
		if (!b) {
			cout << ans << "\n";
			continue;
		}
		for (auto y : x) {
			if (y.second != idx) {
				ans += y.first;
				b -= 1;
				if (!b) {
					break;
				}
			}
		}
		cout << ans << "\n";
	}
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<cerrno>
#include<cfenv>

typedef long long int lli;
typedef long long ll;
typedef double long dl;
using namespace std;

const int mod = 998244353;
const dl pi = std::acos(-1);

ll gcd(ll a, ll b) {
	if (!b) {
		return a;
	}
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y & 1) {
			res = (res * x) % mod;
		}
		y >>= 1;
		x = (x * x) % mod;
	}
	return res;
}

ll inverse(ll x) {
	return power(x, mod - 2);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		int n, a, b;
		cin >> n >> a >> b;
		ll temp = 1;
		while (a--) {
			temp <<= 1;
		}
		vector<pair<ll, ll>>aa(n);
		for (int i = 0; i < n; i += 1) {
			cin >> aa[i].first >> aa[i].second;
		}
		int idx = -1;
		ll idx_check = -1;
		for (int i = 0; i < n; i += 1) {
			if (idx_check < max(aa[i].first * temp, aa[i].second)-aa[i].second) {
				idx = i;
				idx_check = max(aa[i].first * temp, aa[i].second)-aa[i].second;
			}
		}
		vector<pair<ll, int>>x;
		for (int i = 0; i < n; i += 1) {
			if (aa[i].first > aa[i].second) {
				x.push_back({ aa[i].first - aa[i].second,i });
			}
		}
		sort(x.rbegin(), x.rend());
		ll ans = 0;
		for (int i = 0; i < n; i += 1) {
			if (b && i == idx) {
				b -= 1;
				ans += idx_check;
			}
			ans += aa[i].second;
		}
		if (!b) {
			cout << ans << "\n";
			continue;
		}
		for (auto y : x) {
			if (y.second != idx) {
				ans += y.first;
			}
		}
		cout << ans << "\n";
	}
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<cerrno>
#include<cfenv>

typedef long long int lli;
typedef long long ll;
typedef double long dl;
using namespace std;

const int mod = 998244353;
const dl pi = std::acos(-1);

ll gcd(ll a, ll b) {
	if (!b) {
		return a;
	}
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y & 1) {
			res = (res * x) % mod;
		}
		y >>= 1;
		x = (x * x) % mod;
	}
	return res;
}

ll inverse(ll x) {
	return power(x, mod - 2);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		int n, a, b;
		cin >> n >> a >> b;
		ll temp = 1;
		while (a--) {
			temp <<= 1;
		}
		vector<pair<ll, ll>>aa(n);
		for (int i = 0; i < n; i += 1) {
			cin >> aa[i].first >> aa[i].second;
		}
		ll ans3 = 0;
		vector<pair<ll, int>>x;
		for (int i = 0; i < n; i += 1) {
			x.push_back({ max(aa[i].first - aa[i].second,0LL),i });
		}
		sort(x.begin(), x.end());
		reverse(x.begin(), x.end());
		ll ans = 0;
		for (int i = 0; i < n; i += 1) {
			ans3 += aa[i].second;
		}
		if (!b) {
			cout << ans3 << "\n";
			continue;
		}
		ll ans2 = 0;
		for (int i = 0; i < min(b, n); i += 1) {
			ans2 += x[i].first;
		}
		for (int i = 0; i < n; i += 1) {
			if (i < b) {
				ans = max(ans, ans2 - x[i].first + max(temp * aa[x[i].second].first, aa[x[i].second].second) - aa[x[i].second].second);
			}
			else {
				ans = max(ans, ans2 - x[b-1].first + max(temp * aa[x[i].second].first, aa[x[i].second].second) - aa[x[i].second].second);
			}
		}
		cout << ans + ans3 << "\n";
	}
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<cerrno>
#include<cfenv>

typedef long long int lli;
typedef long long ll;
typedef double long dl;
using namespace std;

const int mod = 998244353;
const dl pi = std::acos(-1);

ll gcd(ll a, ll b) {
	if (!b) {
		return a;
	}
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y & 1) {
			res = (res * x) % mod;
		}
		y >>= 1;
		x = (x * x) % mod;
	}
	return res;
}

ll inverse(ll x) {
	return power(x, mod - 2);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		int n, a, b;
		cin >> n >> a >> b;
		ll temp = 1;
		while (a--) {
			temp <<= 1;
		}
		vector<pair<ll, ll>>aa(n);
		for (int i = 0; i < n; i += 1) {
			cin >> aa[i].first >> aa[i].second;
		}
		int idx = -1;
		ll idx_check = -1;
		for (int i = 0; i < n; i += 1) {
			if (idx_check < max(aa[i].first * temp, aa[i].second)-aa[i].second) {
				idx = i;
				idx_check = max(aa[i].first * temp, aa[i].second)-aa[i].second;
			}
		}
		vector<pair<ll, int>>x;
		for (int i = 0; i < n; i += 1) {
			if (aa[i].first > aa[i].second) {
				x.push_back({ aa[i].first - aa[i].second,i });
			}
		}
		sort(x.rbegin(), x.rend());
		ll ans = 0;
		for (int i = 0; i < n; i += 1) {
			if (b && i == idx) {
				b -= 1;
				ans += idx_check;
			}
			ans += aa[i].second;
		}
		if (!b) {
			cout << ans << "\n";
			continue;
		}
		for (auto y : x) {
			if (y.second != idx) {
				ans += y.first;
			}
			b -= 1;
			if (!b) {
				break;
			}
		}
		cout << ans << "\n";
	}
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>
#include<stdio.h>
#include <math.h>
#include <stack>
#define int long long
using namespace std;
struct MyOtr
{
	int dm;
	int hp;
};

MyOtr a[300000];
int n, m, k, a1, b1;
bool comp(const MyOtr &o, const MyOtr &t)
{
	return o.hp-o.dm > t.hp-t.dm;
}
void main()
{
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	cin >> n >> a1 >> b1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].hp >> a[i].dm;
	}
	sort(a, a + n, comp);
	int f = pow(2.0, (double)a1);
	int max;
	int summ = 0;
	int in = b1;
	for (int i = 0; i < n ; i++)
	{
		if (i < b1)
		{
			if (a[i].hp >= a[i].dm)
			{
				summ += a[i].hp;
			}
			else
			{
				b1 = i;
				summ += a[i].dm;
			}
		}
		else
		{
			summ += a[i].dm;
		}
	}
	max = summ;
	int d = b1;
	b1 = in;
	in = d;
	for (int j = 0; j < n; j++)
	{
		if (j < in)
		{
			if (max < summ - a[j].hp + a[j].hp*f)
			{
				max = summ - a[j].hp + a[j].hp*f;
			}
		}
		else
		{
			if (b1 != 0)
			{
				if (b1 == in)
				{
					if (max < summ - a[b1 - 1].hp + a[b1 - 1].dm + a[j].hp*f - a[j].dm)
					{
						max = summ - a[b1 - 1].hp + a[b1 - 1].dm + a[j].hp*f - a[j].dm;
					}
				}
				else
				{
					if (max < summ + a[j].hp*f - a[j].dm)
					{
						max = summ  + a[j].hp*f - a[j].dm;
					}
				}
			}
		}
	}
	cout << max;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>
#include<stdio.h>
#include <math.h>
#include <stack>
#define int long long
using namespace std;
struct MyOtr
{
	int dm;
	int hp;
};

MyOtr a[300000];
int n, m, k, a1, b1;
bool comp(const MyOtr &o, const MyOtr &t)
{
	return o.hp-o.dm > t.hp-t.dm;
}
void main()
{
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	cin >> n >> a1 >> b1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].hp >> a[i].dm;
	}
	sort(a, a + n, comp);
	int f = pow(2, a1);
	int max;
	int summ = 0;
	int in = b1;
	for (int i = 0; i < n ; i++)
	{
		if (i < b1)
		{
			if (a[i].hp >= a[i].dm)
			{
				summ += a[i].hp;
			}
			else
			{
				b1 = i;
				summ += a[i].dm;
			}
		}
		else
		{
			summ += a[i].dm;
		}
	}
	max = summ;
	int d = b1;
	b1 = in;
	in = d;
	for (int j = 0; j < n; j++)
	{
		if (j < in)
		{
			if (max < summ - a[j].hp + a[j].hp*f)
			{
				max = summ - a[j].hp + a[j].hp*f;
			}
		}
		else
		{
			if (b1 != 0)
			{
				if (b1 == in)
				{
					if (max < summ - a[b1 - 1].hp + a[b1 - 1].dm + a[j].hp*f - a[j].dm)
					{
						max = summ - a[b1 - 1].hp + a[b1 - 1].dm + a[j].hp*f - a[j].dm;
					}
				}
				else
				{
					if (max < summ + a[j].hp*f - a[j].dm)
					{
						max = summ  + a[j].hp*f - a[j].dm;
					}
				}
			}
		}
	}
	cout << max;
}


#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<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int n,A,B,t;LL Ans,Sum,Num;
struct xcw{LL hp,dam;bool operator <(const xcw b)const{return (hp-dam)>(b.hp-b.dam);}}a[200005];
LL read(){
    LL ret=0;char ch=getchar();bool f=1;
    for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');
    for(; isdigit(ch);ch=getchar()) ret=ret*10+ch-'0';
    return ret;
}
int main(){
//  freopen("E.in","r",stdin);
//  freopen("E.out","w",stdout);
    n=read(),A=read(),B=read();
    for(int i=1;i<=n;i++) a[i]=(xcw){read(),read()},Num+=a[i].dam;
    if(!B){cout<<Num<<endl;return 0;}
    sort(a+1,a+1+n);
    for (int i=1;i<=B;i++) Sum+=max(0LL,a[i].hp-a[i].dam);
    for (int i=1;i<=B;i++) Ans=max(Ans,Sum-max(0LL,a[i].hp-a[i].dam)-a[i].dam+(a[i].hp<<A));
    for (int i=B+1;i<=n;i++) Ans=max(Ans,Sum-max(0LL,a[B].hp-a[B].dam)-a[i].dam+(a[i].hp<<A));
    cout<<Ans+Num<<endl;
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_N = 200005;
typedef long long LL;
struct node{
	LL h, d, c;
}p[MAX_N];

bool cmp(node A, node B){
	return A.c > B.c;
}

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

	LL ans = 0;
	sort(p+1, p+1+n, cmp);
	int left = b;			//剩下的药数量
	for(int i = 1; i <= n; i++)
	{
		if(p[i].c > 0 && left)
			ans += p[i].h, left--;
		else
			ans += p[i].d;
	}

	if(a > 0 && b > 0)
	{	//有血药和转换药,若无前者之前便已处理，若无后者用了血药也无用
		LL t, pw = 2, res = ans;
		for(int i = 1; i < a; i++)
			pw *= 2;

		int use = b - left; //use是转换提升最小的那个的下标
		for(int i = 1; i <= n; i++) {
			if(i <= use) { 	//用过了转换药
				t = res-p[i].h + p[i].h*pw;
				if(ans < t)
					ans = t;
			} else {		//未用过转换药
				if(left) {	//还有多的转换药
					t = res-p[i].d + p[i].h*pw;
					if(ans < t)
						ans = t;
				} else {	//无转换药,比较  转换提升最小的那个和这个  谁转换提升更高(贪心)
					t = res-p[use].h+p[use].d - p[i].d+p[i].h*pw;	//前面b>0若漏了,use便有可能是0,WANG
					if(ans < t)
						ans = t;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

typedef long long LL;

struct monster
{
	LL health;
	LL damage;
	LL value;
};

bool comp(monster &lhs, monster &rhs)
{
	return lhs.value > rhs.value;
}

const int maxn = 2 * 1e5 + 5;
bool done[maxn];

int n, a, b;
vector<monster> monsters;
int Main()
{
	cin >> n >> a >> b;
	b = min(b, n);

	LL pw = 1;
	for (int i = 0; i < a; ++i) pw <<= 1;

	for (int i = 0; i < n; ++i)
	{
		monster mon;
		cin >> mon.health >> mon.damage;
		mon.value = mon.health - mon.damage;
		monsters.push_back(mon);
	}
	sort(monsters.begin(), monsters.end(), comp);

	LL sum = 0;
	int smallest = -1;
	for (int i = 0; i < b; ++i)
	{
		if (monsters[i].value <= 0) break;

		++smallest;
		sum += monsters[i].health;
	}

	for (int i = smallest + 1; i < n; ++i)
	{
		sum += monsters[i].damage;
	}

	if (pw > 1 && b > 0)
	{
		LL ans = sum;
		for (int i = 0; i <= smallest; ++i)
		{
			LL dam = monsters[i].health * pw;
			ans = max(ans, sum - monsters[i].health + dam);
		}

		for (int i = smallest + 1; i < n; ++i)
		{
			LL dam = monsters[i].health * pw;
			LL old = smallest == -1 ? 0 : monsters[smallest].damage - monsters[smallest].health;
			ans = max(ans, sum + old + dam - monsters[i].damage);
		}
		sum = ans;
	}

	cout << sum << endl;

	return 0;
}

int main()
{
#ifdef DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	Main();

	return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

typedef long long LL;

struct monster
{
	LL health;
	LL damage;
	LL value;
};

bool comp(monster &lhs, monster &rhs)
{
	return lhs.value > rhs.value;
}

const int maxn = 2 * 1e5 + 5;
bool done[maxn];

int n, a, b;
vector<monster> monsters;
int Main()
{
	cin >> n >> a >> b;
	b = min(b, n);

	LL pw = 1;
	for (int i = 0; i < a; ++i) pw <<= 1;

	for (int i = 0; i < n; ++i)
	{
		monster mon;
		cin >> mon.health >> mon.damage;
		mon.value = mon.health - mon.damage;
		monsters.push_back(mon);
	}
	sort(monsters.begin(), monsters.end(), comp);

	LL sum = 0;
	int smallest = -1;
	for (int i = 0; i < b; ++i)
	{
		if (monsters[i].value <= 0) break;

		++smallest;
		sum += monsters[i].health;
	}

	for (int i = smallest + 1; i < n; ++i)
	{
		sum += monsters[i].damage;
	}

	if (pw > 1 && b > 0)
	{
		LL ans = sum;
		for (int i = 0; i <= smallest; ++i)
		{
			LL dam = monsters[i].health * pw;
			ans = max(ans, sum - monsters[i].health + dam);
		}

		for (int i = smallest + 1; i < n; ++i)
		{
			LL dam = monsters[i].health * pw;
			LL old = 0;
			if(smallest == b - 1)
			{
				old = monsters[smallest].damage - monsters[smallest].health;
			}

			ans = max(ans, sum + old + dam - monsters[i].damage);
		}
		sum = ans;
	}

	cout << sum << endl;

	return 0;
}

int main()
{
#ifdef DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	Main();

	return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

typedef long long LL;

struct monster
{
	LL health;
	LL damage;
	LL value1;
	LL value2;
	int ind;
};

bool comp1(monster &lhs, monster &rhs)
{
	if (lhs.value1 == rhs.value1)
		return lhs.value2 < rhs.value2;
	return lhs.value1 > rhs.value1;
}

bool comp2(monster &lhs, monster &rhs)
{
	if (lhs.value2 == rhs.value2)
		return lhs.value1 < rhs.value1;
	return lhs.value2 > rhs.value2;
}

const int maxn = 2 * 1e5;
bool done[maxn];

int n, a, b;
vector<monster> monsters1, monsters2;
int Main()
{
	cin >> n >> a >> b;
	b = min(b, n);
	a = min(a, b);

	for (int i = 0; i < n; ++i)
	{
		monster m; m.ind = i;
		cin >> m.health >> m.damage;
		m.value1 = m.health - m.damage;
		m.value2 = 2 * m.health - m.damage;
		monsters1.push_back(m);
		monsters2.push_back(m);
	}

	sort(monsters1.begin(), monsters1.end(), comp1);
	sort(monsters2.begin(), monsters2.end(), comp2);

	LL sum = 0;
	int ra = a, rb = b, fst = 0, snd = 0;
	while ((rb > 0 && monsters1[fst].value1 > 0) || (ra > 0 && monsters2[snd].value2 > 0))
	{
		if (ra > 0 && monsters2[snd].value2 > monsters1[fst].value1)
		{
			done[monsters2[snd].ind] = true;
			sum += monsters2[snd].health * 2;
			--ra, --rb;
			while (done[monsters2[snd].ind] && snd < n) ++snd;
		}
		else
		{
			done[monsters1[fst].ind] = true;
			sum += monsters1[fst].health;
			--rb;
			while (done[monsters1[fst].ind] && fst < n) ++fst;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		if (!done[monsters1[i].ind]) sum += monsters1[i].damage;
	}

	cout << sum << endl;

	return 0;
}

int main()
{
#ifdef DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	Main();

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <cmath>
#include <iterator>
using namespace std;
struct node
{
public:
	long long int hp;
	long long int dmg;
	int a;
	node() {};
	node(long long int a,  long long int b,int s)
	{
		this->hp = a;
		this->dmg = b;
		this->a = s;
	}
};
bool pr(node z, node z1)
{
	if (z.hp-z.dmg>z1.hp-z1.dmg)
	{
		return 1;
	}
	else
	return 0;
}

int main()
{
	int a,ind=-100;
	long long int max = -99999,max1=0;
	bool p = true;
	 long long int n, b, hp, dmg, sum = 0, count = 0;
	cin >> n >> a >> b;
	node *arr = new node[2 * pow(10.0,5)];
	for (int i = 0;i < n;i++)
	{
		cin >> hp >> dmg;
		arr[i] = node(hp, dmg, a);
	}
	if (b == 0)
	{
		for (int i = 0;i < n;i++)
		{
			sum += arr[i].dmg;
		}
		cout << sum << endl;
		return 0;
	}
	sort(arr, arr + n, pr);
	if (a != 0)
	{
		for (int i = 0;i < n;i++)
		{
			if (arr[i].hp*pow(2.0, a) - arr[i].dmg >= max)
			{
				max = arr[i].hp*pow(2.0, a) - arr[i].dmg;
				max1 = arr[i].hp*pow(2.0, a);
				ind = i;
			}
		}
		if (max > 0)
		{
			sum += max1;
			count++;
		}
		else
			ind = -100;
	}
	for (int i = 0;i < n;i++)
	{
		if (i==ind)
		{
			continue;
		}
		if (arr[i].hp > arr[i].dmg)
		{
			if (count < b)
			{
				count++;
				sum += arr[i].hp;
			}
			else
				sum += arr[i].dmg;
		}
		else
		{
			sum += arr[i].dmg;
		}
	}
	cout << sum << endl;

	return 0;
}


#include<iostream>
#include <algorithm>

#define ll long long int
using namespace std;
struct node {
	ll x, y, z;
}d[200005];
bool cmp(node a, node b)
{
	return a.z>b.z;
}
int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = 0;
	for (int i = 1;i <= n;i++) {
		cin >> d[i].x >> d[i].y;
		d[i].z = d[i].x - d[i].y;
		ans += d[i].y;
	}
	sort(d + 1, d + 1 + n, cmp);
	b = min(n, b);
	if (b == 0)
	{
		cout << ans << endl;
		return 0;
	}
	for (int i = 1;i <= b;i++) {
		if (d[i].z<0)break;
		ans += d[i].z;
	}
	ll Ans = ans;
	for (int i = 1;i <= n;i++)
	{
		ll tans = ans;
		if (i <= b)
		{
			tans += max(d[i].x << a, d[i].y) - d[i].y;
			tans -= max((ll)0, d[i].z);
		}
		else {
			tans += max(d[i].x << a, d[i].y) - d[i].y;
			tans -= max((ll)0, d[b].z);
		}
		Ans = max(Ans, tans);
	}
	cout << Ans << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <cmath>
#include <iterator>
using namespace std;
struct node
{
public:
	unsigned long long hp;
	unsigned long long dmg;
	int a;
	node() {};
	node(unsigned long long a, unsigned long long b,int s)
	{
		this->hp = a;
		this->dmg = b;
		this->a = s;
	}
};
bool pr(node z, node z1)
{
	if (z.hp-z.dmg>z1.hp-z1.dmg)
	{
		return 1;
	}
	else
	return 0;
}

int main()
{
	int a;
	long long int max = -99999,max1=0;
	bool p = true;
	 long long int n, b, hp, dmg, sum = 0, count = 0;
	cin >> n >> a >> b;
	node *arr = new node[2 * pow(10.0,5)];
	for (int i = 0;i < n;i++)
	{
		cin >> hp >> dmg;
		arr[i] = node(hp, dmg, a);
	}
	if (b == 0)
	{
		for (int i = 0;i < n;i++)
		{
			sum += arr[i].dmg;
		}
		cout << sum << endl;
		return 0;
	}
	sort(arr, arr + n, pr);
	if (a != 0)
	{
		for (int i = 0;i < n;i++)
		{
			if (arr[i].hp*pow(2.0, a) - arr[i].dmg > max)
			{
				max = arr[i].hp*pow(2.0, a) - arr[i].dmg;
				max1 = arr[i].hp*pow(2.0, a);
			}
		}
		if (max > 0)
			sum += max1;
	}
	for (int i = 0;i < n;i++)
	{
		if (arr[i].hp*pow(2.0, a) - arr[i].dmg==max&&p == true)
		{
			p = false;
			continue;
		}
		if (arr[i].hp > arr[i].dmg)
		{
			if (count <= b)
			{
				count++;
				sum += arr[i].hp;
			}
			else
				sum += arr[i].dmg;
		}
		else
		{
			sum += arr[i].dmg;
		}
	}
	cout << sum << endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <cmath>
#include <iterator>
using namespace std;
struct node
{
public:
	long long int hp;
	long long int dmg;
	int a;
	node() {};
	node(long long int a,  long long int b,int s)
	{
		this->hp = a;
		this->dmg = b;
		this->a = s;
	}
};
bool pr(node z, node z1)
{
	if (z.hp-z.dmg>z1.hp-z1.dmg)
	{
		return 1;
	}
	else
	return 0;
}

int main()
{
	int a,ind=-100;
	long long int max = -99999,max1=0;
	bool p = true;
	 long long int n, b, hp, dmg, sum = 0, count = 0;
	cin >> n >> a >> b;
	node *arr = new node[2 * pow(10.0,5)];
	for (int i = 0;i < n;i++)
	{
		cin >> hp >> dmg;
		arr[i] = node(hp, dmg, a);
	}
	if (b == 0)
	{
		for (int i = 0;i < n;i++)
		{
			sum += arr[i].dmg;
		}
		cout << sum << endl;
		return 0;
	}
	sort(arr, arr + n, pr);
	if (a != 0)
	{
		for (int i = 0;i < n;i++)
		{
			if (arr[i].hp*pow(2.0, a) - arr[i].dmg >= max)
			{
				max = arr[i].hp*pow(2.0, a) - arr[i].dmg;
				max1 = arr[i].hp*pow(2.0, a);
				ind = i;
			}
		}
		if (max > 0)
		{
			sum += max1;
			count++;
		}
	}
	for (int i = 0;i < n;i++)
	{
		if (i==ind)
		{
			continue;
		}
		if (arr[i].hp > arr[i].dmg)
		{
			if (count < b)
			{
				count++;
				sum += arr[i].hp;
			}
			else
				sum += arr[i].dmg;
		}
		else
		{
			sum += arr[i].dmg;
		}
	}
	cout << sum << endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <cmath>
#include <iterator>
using namespace std;
struct node
{
public:
	unsigned long long hp;
	unsigned long long dmg;
	int a;
	node() {};
	node(unsigned long long a, unsigned long long b,int s)
	{
		this->hp = a;
		this->dmg = b;
		this->a = s;
	}
};
bool pr(node z, node z1)
{
	if (z.hp-z.dmg>z1.hp-z1.dmg)
	{
		return 1;
	}
	else
	return 0;
}

int main()
{
	int a;
	long long int max = -99999,max1=0;
	bool p = true;
	 long long int n, b, hp, dmg, sum = 0, count = 0;
	cin >> n >> a >> b;
	node *arr = new node[2 * pow(10.0,5)];
	for (int i = 0;i < n;i++)
	{
		cin >> hp >> dmg;
		arr[i] = node(hp, dmg, a);
	}
	if (b == 0)
	{
		for (int i = 0;i < n;i++)
		{
			sum += arr[i].dmg;
		}
		cout << sum << endl;
	}
	sort(arr, arr + n, pr);
	if (a != 0)
	{
		for (int i = 0;i < n;i++)
		{
			if (arr[i].hp*pow(2.0, a) - arr[i].dmg > max)
			{
				max = arr[i].hp*pow(2.0, a) - arr[i].dmg;
				max1 = arr[i].hp*pow(2.0, a);
			}
		}
		if (max > 0)
			sum += max1;
	}
	for (int i = 0;i < n;i++)
	{
		if (arr[i].hp*pow(2.0, a) - arr[i].dmg==max&&p == true)
		{
			p = false;
			continue;
		}
		if (arr[i].hp > arr[i].dmg)
		{
			if (count <= b)
			{
				count++;
				sum += arr[i].hp;
			}
			else
				sum += arr[i].dmg;
		}
		else
		{
			sum += arr[i].dmg;
		}
	}
	cout << sum << endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <cmath>
#include <iterator>
using namespace std;
struct node
{
public:
	unsigned long long hp;
	unsigned long long dmg;
	int a;
	node() {};
	node(unsigned long long a, unsigned long long b,int s)
	{
		this->hp = a;
		this->dmg = b;
		this->a = s;
	}
};
bool pr(node z, node z1)
{
	if (z.hp-z.dmg>z1.hp-z1.dmg)
	{
		return 1;
	}
	else
	return 0;
}

int main()
{
	int a;
	long long int max = -99999,max1=0;
	bool p = true;
	 long long int n, b, hp, dmg, sum = 0, count = 0;
	cin >> n >> a >> b;
	node *arr = new node[2 * pow(10,5)];
	for (int i = 0;i < n;i++)
	{
		cin >> hp >> dmg;
		arr[i] = node(hp, dmg, a);
	}
	if (b == 0)
	{
		for (int i = 0;i < n;i++)
		{
			sum += arr[i].dmg;
		}
		cout << sum << endl;
	}
	sort(arr, arr + n, pr);
	if (a != 0)
	{
		for (int i = 0;i < n;i++)
		{
			if (arr[i].hp*pow(2, a) - arr[i].dmg > max)
			{
				max = arr[i].hp*pow(2, a) - arr[i].dmg;
				max1 = arr[i].hp*pow(2, a);
			}
		}
		if (max > 0)
			sum += max1;
	}
	for (int i = 0;i < n;i++)
	{
		if (arr[i].hp*pow(2, a) - arr[i].dmg==max&&p == true)
		{
			p = false;
			continue;
		}
		if (arr[i].hp > arr[i].dmg)
		{
			if (count <= b)
			{
				count++;
				sum += arr[i].hp;
			}
			else
				sum += arr[i].dmg;
		}
		else
		{
			sum += arr[i].dmg;
		}
	}
	cout << sum << endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <cmath>
#include <iterator>
using namespace std;
struct node
{
public:
	long long int hp;
	long long int dmg;
	int a;
	node() {};
	node(long long int a,  long long int b,int s)
	{
		this->hp = a;
		this->dmg = b;
		this->a = s;
	}
};
bool pr(node z, node z1)
{
	if (z.hp-z.dmg>z1.hp-z1.dmg)
	{
		return 1;
	}
	else
	return 0;
}

int main()
{
	int a,ind;
	long long int max = -99999,max1=0;
	bool p = true;
	 long long int n, b, hp, dmg, sum = 0, count = 0;
	cin >> n >> a >> b;
	node *arr = new node[2 * pow(10.0,5)];
	for (int i = 0;i < n;i++)
	{
		cin >> hp >> dmg;
		arr[i] = node(hp, dmg, a);
	}
	if (b == 0)
	{
		for (int i = 0;i < n;i++)
		{
			sum += arr[i].dmg;
		}
		cout << sum << endl;
		return 0;
	}
	sort(arr, arr + n, pr);
	if (a != 0)
	{
		for (int i = 0;i < n;i++)
		{
			if (arr[i].hp*pow(2.0, a) - arr[i].dmg >= max)
			{
				max = arr[i].hp*pow(2.0, a) - arr[i].dmg;
				max1 = arr[i].hp*pow(2.0, a);
				ind = i;
			}
		}
		if (max > 0)
		{
			sum += max1;
			count++;
		}
	}
	for (int i = 0;i < n;i++)
	{
		if (i==ind)
		{
			continue;
		}
		if (arr[i].hp > arr[i].dmg)
		{
			if (count < b)
			{
				count++;
				sum += arr[i].hp;
			}
			else
				sum += arr[i].dmg;
		}
		else
		{
			sum += arr[i].dmg;
		}
	}
	cout << sum << endl;

	return 0;
}


#include<stack>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

const int maxn = 2e5 + 10;

int n, a, b;
LL sumh, sumd, sumx, ans;
LL h[maxn], d[maxn], preh[maxn], pred[maxn];

struct Node {
	LL h, d, id;

	bool operator<(const Node &b) const {
		return h > b.h;
	}

};

vector<Node> v,v2;

int main()
{
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> h[i] >> d[i];
		Node tmp;
		tmp.h = h[i]; tmp.d = d[i];
		tmp.id = i;
		if (h[i] < d[i]) v.push_back(tmp);
		else v2.push_back(tmp);
		//sumx += max(h[i], d[i]);
	}
	if (!b) {

		return 0;
	}
	sort(v.begin(), v.end());
	sort(v2.begin(), v2.end());
	for (int i = 0; i < v.size(); i++) {
		sumh += v[i].h;
		sumd += v[i].d;
	}
	for (int i = 0; i < v2.size(); i++) {
		preh[i] = v2[i].h;
		pred[i] = v2[i].d;
		if (i >= 1) {
			preh[i] += preh[i - 1];
			pred[i] += pred[i - 1];
		}
	}
	ans = sumd + pred[v2.size() - 1];
	if (!b) {
		cout << ans << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++) {
		LL tmp = v[i].h;
		for (int j = 1; j <= a; j++)
			tmp *= 2;
		if (tmp >= v[i].d) {
			if (!v2.size()) {
				ans = max(ans, tmp + sumd - v[i].d);
				continue;
			}
			int siz = min((int)v2.size() - 1, b - 2);
			ans = max(ans, tmp + sumd - v[i].d + b - 1 >= 1 ? pred[v2.size() - 1] - pred[siz] + preh[siz] : pred[v2.size() - 1]);
		}
	}
	if (!v2.size()) {
		cout << ans << endl;
		return 0;
	}
	LL tmp = v2[0].h;
	for (int j = 1; j <= a; j++)
		tmp *= 2;
	for (int i = 1; i < v2.size(); i++)
		tmp += b - 1 >= i ? v2[i].h : v2[i].d;
	tmp += sumd;
	ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}


#include<stack>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

const int maxn = 2e5 + 10;

int n, a, b;
LL sumh, sumd, sumx, ans;
LL h[maxn], d[maxn], preh[maxn], pred[maxn];

struct Node {
	LL h, d, id;

	bool operator<(const Node &b) const {
		return h > b.h;
	}

};

vector<Node> v,v2;

int main()
{
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> h[i] >> d[i];
		Node tmp;
		tmp.h = h[i]; tmp.d = d[i];
		tmp.id = i;
		if (h[i] < d[i]) v.push_back(tmp);
		else v2.push_back(tmp);
		//sumx += max(h[i], d[i]);
	}
	sort(v.begin(), v.end());
	sort(v2.begin(), v2.end());
	for (int i = 0; i < v.size(); i++) {
		sumh += v[i].h;
		sumd += v[i].d;
	}
	for (int i = 0; i < v2.size(); i++) {
		preh[i] = v2[i].h;
		pred[i] = v2[i].d;
		if (i >= 1) {
			preh[i] += preh[i - 1];
			pred[i] += pred[i - 1];
		}
	}
	ans = sumd + pred[v2.size() - 1];
	if (!b) {
		cout << ans << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++) {
		LL tmp = v[i].h;
		for (int j = 1; j <= a; j++)
			tmp *= 2;
		if (tmp >= v[i].d) {
			if (!v2.size()) {
				ans = max(ans, tmp + sumd - v[i].d);
				continue;
			}
			int siz = min((int)v2.size() - 1, b - 2);
			ans = max(ans, tmp + sumd - v[i].d + b - 1 >= 1 ? pred[v2.size() - 1] - pred[siz] + preh[siz] : pred[v2.size() - 1]);
		}
	}
	if (!v2.size()) {
		cout << ans << endl;
		return 0;
	}
	LL tmp = v2[0].h;
	for (int j = 1; j <= a; j++)
		tmp *= 2;
	for (int i = 1; i < v2.size(); i++)
		tmp += b - 1 >= i ? v2[i].h : v2[i].d;
	tmp += sumd;
	ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}


#include<stack>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

const int maxn = 2e5 + 10;

int n, a, b;
LL sumh, sumd, sumx, ans;
LL h[maxn], d[maxn], preh[maxn], pred[maxn];

struct Node {
	LL h, d, id;

	bool operator<(const Node &b) const {
		return h > b.h;
	}

};

vector<Node> v,v2;

int main()
{
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> h[i] >> d[i];
		Node tmp;
		tmp.h = h[i]; tmp.d = d[i];
		tmp.id = i;
		if (h[i] < d[i]) v.push_back(tmp);
		else v2.push_back(tmp);
		//sumx += max(h[i], d[i]);
	}
	if (!b) {

		return 0;
	}
	sort(v.begin(), v.end());
	sort(v2.begin(), v2.end());
	for (int i = 0; i < v.size(); i++) {
		sumh += v[i].h;
		sumd += v[i].d;
	}
	for (int i = 0; i < v2.size(); i++) {
		preh[i] = v2[i].h;
		pred[i] = v2[i].d;
		if (i >= 1) {
			preh[i] += preh[i - 1];
			pred[i] += pred[i - 1];
		}
	}
	ans = sumd + pred[v2.size() - 1];
	for (int i = 0; i < v.size(); i++) {
		LL tmp = v[i].h;
		for (int j = 1; j <= a; j++)
			tmp *= 2;
		if (tmp >= v[i].d) {
			if (!v2.size()) {
				ans = max(ans, tmp + sumd - v[i].d);
				continue;
			}
			int siz = min((int)v2.size() - 1, b - 2);
			ans = max(ans, tmp + sumd - v[i].d + b - 1 >= 1 ? pred[v2.size() - 1] - pred[siz] + preh[siz] : pred[v2.size() - 1]);
		}
	}
	if (!v2.size()) {
		cout << ans << endl;
		return 0;
	}
	LL tmp = v2[0].h;
	for (int j = 1; j <= a; j++)
		tmp *= 2;
	for (int i = 1; i < v2.size(); i++)
		tmp += b - 1 >= i ? v2[i].h : v2[i].d;
	tmp += sumd;
	ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}


#include<stack>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

const int maxn = 2e5 + 10;

int n, a, b, flag;
LL ans;
LL h[maxn], d[maxn], preh[maxn], pred[maxn];

struct Node {
	LL h, d, id;

	bool operator<(const Node &b) const {
		return h - d > b.h - b.d;
	}

}c[maxn];

int main()
{
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> h[i] >> d[i];
		Node tmp;
		tmp.h = h[i];
		tmp.d = d[i];
		tmp.id = i;
		c[i] = tmp;
		//sumx += max(h[i], d[i]);
	}
	sort(c + 1, c + n + 1);
	for (int i = 1; i <= n; i++) {
		if (c[i].h > c[i].d) flag = i;
		preh[i] = preh[i - 1] + c[i].h;
		pred[i] = pred[i - 1] + c[i].d;
	}
	ans = pred[n];
	if (!b) {
		cout << ans << endl;
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		LL tmp = c[i].h;
		for (int j = 1; j <= a; j++)
			tmp *= 2LL;
		if (tmp <= c[i].d) continue;
		if (b == 1) {
			ans = max(ans, tmp + pred[n] - c[i].d);
			continue;
		}
		if (i <= min(flag, b)) ans = max(ans, tmp + preh[min(b, flag)] - c[i].h + pred[n] - pred[min(b, flag)]);
		else ans = max(ans, tmp + preh[min(b - 1, flag)] + pred[n] - pred[min(b - 1, flag)] - c[i].d);
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b;
	long long ans;
	long long sum = 0;
	cin >> n >> a >> b;
	b = min(n, b);
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	for (int i = 0; i < n - b; i++)
	{
		sum += q[i].d;
	}
	for (int i = n - b; i < n; i++)
	{
		sum += max(q[i].d, q[i].h);
	}
	ans = sum;
	if (b)
	{
		for (int i = 0; i < n - b; i++)
		{
			ans= max(ans, sum+q[i].h*po - q[i].d - max(q[n - b].d, q[n - n].h) + q[n - b].d);
		}
		for (int i = n - b; i < n; i++)
		{
			ans = max(ans, sum + q[i].h*po - max(q[i].h, q[i].d));
		}
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b, pos = -1, ma1 = 0,ma2=0;
	long long sum = 0;
	cin >> n >> a >> b;
	b = min(n, b);
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	if (b > 0)
	{
		for (int i = 0; i < n - b; i++)
		{
			if (q[i].h*po - q[i].d > ma1&&q[i].h*po - q[i].d>q[n-b].h-q[n-b].d)
			{
				ma1 = q[i].h*po - q[i].d;
			}
		}
		for (int i = n - b; i < n; i++)
		{
			if (q[i].h*po - max(q[i].d, q[i].h)>ma2)
			{
				ma2 = q[i].h*po - max(q[i].d, q[i].h);
			}
		}
		sum += max(ma1, ma2);
	}
	for (int i = n-1; i >= 0; i--)
	{
		if (b == 0)
		{
			sum += q[i].d;
		}
		else
		{
			sum += max(q[i].d, q[i].h);
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po=1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b,pos=-1,min=0;
	long long sum = 0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	for (int i = 0; i < n; i++)
	{
		if (q[i].h*po - q[i].d > min)
		{
			min = q[i].h*po - q[i].d;
			pos = i;
		}
	}
	if (pos != -1)
	{
		sum += min+q[pos].d;
		b--;
	}
	for (int i = n; i >=0; i--)
	{
		if (i == pos)
			continue;
		if (b == 0)
		{
			sum += q[i].d;
		}
		else
		{
			sum += max(q[i].d, q[i].h);
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b, pos = -1, min = 0;
	long long sum = 0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	if (b > 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (q[i].h*po - q[i].d > min)
			{
				min = q[i].h*po - q[i].d;
				pos = i;
			}
		}
		if (pos != -1&&min>q[n-b].h-q[n-b].d)
		{
			sum += min + q[pos].d;
			b--;
		}
	}
	for (int i = n; i >= 0; i--)
	{
		if (i == pos)
			continue;
		if (b == 0)
		{
			sum += q[i].d;
		}
		else
		{
			sum += max(q[i].d, q[i].h);
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b, pos = -1, ma1 = 0,ma2=0;
	long long sum = 0;
	cin >> n >> a >> b;
	b = min(n, b);
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	if (b > 0)
	{
		for (int i = 0; i < n - b; i++)
		{
			if (q[i].h*po - q[i].d > ma1&&q[i].h*po - q[i].d>max(q[n-b].h,q[n-b].d)-q[n-b].d)
			{
				ma1 = q[i].h*po - q[i].d;
			}
		}
		for (int i = n - b; i < n; i++)
		{
			if (q[i].h*po - max(q[i].d, q[i].h)>ma2)
			{
				ma2 = q[i].h*po - max(q[i].d, q[i].h);
			}
		}
		if (ma1- (max(q[n - b].h, q[n - b].d) - q[n - b].d) > ma2)
			b--;
		sum += max(ma1, ma2);
	}
	for (int i = n-1; i >= 0; i--)
	{
		if (b == 0)
		{
			sum += q[i].d;
		}
		else
		{
			sum += max(q[i].d, q[i].h);
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b, pos = -1, ma1 = 0,ma2=0;
	long long sum = 0;
	cin >> n >> a >> b;
	b = min(n, b);
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	if (b > 0)
	{
		for (int i = 0; i < n - b; i++)
		{
			if (q[i].h*po - q[i].d > ma1&&q[i].h*po - q[i].d>q[n-b].h-q[n-b].d)
			{
				ma1 = q[i].h*po - q[i].d;
			}
		}
		for (int i = n - b; i < n; i++)
		{
			if (q[i].h*po - max(q[i].d, q[i].h)>ma2)
			{
				ma2 = q[i].h*po - max(q[i].d, q[i].h);
			}
		}
		if (ma1 > ma2)
			b--;
		sum += max(ma1, ma2);
	}
	for (int i = n-1; i >= 0; i--)
	{
		if (b == 0)
		{
			sum += q[i].d;
		}
		else
		{
			sum += max(q[i].d, q[i].h);
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b, pos = -1, min = 0;
	long long sum = 0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	if (b > 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (q[i].h*po - q[i].d > min)
			{
				min = q[i].h*po - q[i].d;
				pos = i;
			}
		}
		if (pos != -1&&min>q[n-b].h-q[n-b].d)
		{
			sum += min + q[pos].d;
			b--;
		}
	}
	for (int i = n-1; i >= 0; i--)
	{
		if (i == pos)
			continue;
		if (b == 0)
		{
			sum += q[i].d;
		}
		else
		{
			sum += max(q[i].d, q[i].h);
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po=1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b,pos=-1,min=0;
	long long sum = 0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	if (b > 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (q[i].h*po - q[i].d > min)
			{
				min = q[i].h*po - q[i].d;
				pos = i;
			}
		}
		if (pos != -1)
		{
			sum += min + q[pos].d;
			b--;
		}
	}
	for (int i = n; i >=0; i--)
	{
		if (i == pos)
			continue;
		if (b == 0)
		{
			sum += q[i].d;
		}
		else
		{
			sum += max(q[i].d, q[i].h);
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b, pos = -1, ma1 = 0,ma2=0;
	long long sum = 0;
	cin >> n >> a >> b;
	b = min(n, b);
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	for (int i = 0; i < n - b; i++)
	{
		sum += q[i].d;
	}
	for (int i = n - b; i < n; i++)
	{
		sum += max(q[i].d, q[i].h);
	}
	if (b)
	{
		for (int i = 0; i < n - b; i++)
		{
			sum = max(sum, sum+q[i].h*po - q[i].d - max(q[n - b].d, q[n - n].h) + q[n - b].d);
		}
		for (int i = n - b; i < n; i++)
		{
			sum = max(sum, sum + q[i].h*po - max(q[i].h, q[i].d));
		}
	}
	cout << sum << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b;
	long long ans;
	long long sum = 0;
	cin >> n >> a >> b;
	b = min(n, b);
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	for (int i = 0; i < n - b; i++)
	{
		sum += q[i].d;
	}
	for (int i = n - b; i < n; i++)
	{
		sum += max(q[i].d, q[i].h);
	}
	ans = sum;
	if (b)
	{
		for (int i = 0; i < n - b; i++)
		{
			ans= max(ans, sum+q[i].h*po - q[i].d - max(q[n - b].d, q[n - b].h) + q[n - b].d);
		}
		for (int i = n - b; i < n; i++)
		{
			ans = max(ans, sum + q[i].h*po - max(q[i].h, q[i].d));
		}
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
using namespace std;
long long po = 1;
struct point
{
	long long h, d;
}q[200005];
bool cmp1(point a, point b)
{
	return a.h - a.d < b.h - b.d;
}
int main()
{
	int n, a, b;
	long long ans;
	long long sum = 0;
	cin >> n >> a >> b;
	b = min(n, b);
	for (int i = 0; i < n; i++)
	{
		cin >> q[i].h >> q[i].d;
	}
	for (int i = 0; i < a; i++)
	{
		po *= 2;
	}
	sort(q, q + n, cmp1);
	for (int i = 0; i < n - b; i++)
	{
		sum += q[i].d;
	}
	for (int i = n - b; i < n; i++)
	{
		sum += max(q[i].d, q[i].h);
	}
	ans = sum;
	if (b)
	{
		for (int i = 0; i < n - b; i++)
		{
			ans= max(ans, sum+q[i].h*po - q[i].d - max(q[n - b].d, q[n - b].h) + q[n - b].d);
		}
		for (int i = n - b; i < n; i++)
		{
			ans = max(ans, sum + q[i].h*po - max(q[i].h, q[i].d));
		}
	}
	cout << sum << endl;
	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 2 * 100000 + 10;
int n, a, b;
ll dbl[30][2];
bool used[N];

struct Elem
{
	ll hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0, delta = 0;

	for (int i = 0; i < n; i++)
	{
		sum += (ll)p[i].dmg;
		used[i] = false;
	}

	sort(p, p + n);

	const int m = min(a, b);

	if (m > 0)
	{
		for (int i = 0; i < n; i++)
		{
			ll d = (ll)p[i].hp * 2 - (ll)p[i].dmg;

			for (int j = 0; j < m; j++)
			{
				if (d > dbl[j][0])
				{
					for (int k = m - 1; k > j; k--)
					{
						dbl[k][0] = dbl[k - 1][0];
						dbl[k][1] = dbl[k - 1][1];
					}

					dbl[j][0] = d;
					dbl[j][1] = p[i].index;

					break;
				}
			}
		}

		for (int i = 0; i < m; i++)
		{
			if (dbl[i][0] > 0)
			{
				delta += dbl[i][0];
				b--;

				used[dbl[i][1]] = true;
			}
		}
	}

	if (b > 0)
	{
		for (int i = n - 1; i >= 0; i--)
		{
			if (!used[p[i].index] && (p[i].hp - p[i].dmg) > 0)
			{
				used[p[i].index] = true;
				delta += (p[i].hp - p[i].dmg);
				b--;

				if (b == 0)
				{
					break;
				}
			}
		}
	}

	cout << sum + delta;

	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 2 * 100000 + 10;
int n, a, b;
ll dbl[30][2];
bool used[N];

struct Elem
{
	ll hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0, delta = 0;

	for (int i = 0; i < n; i++)
	{
		sum += (ll)p[i].dmg;
		used[i] = false;
	}

	sort(p, p + n);

	if (a > 0 && b > 0)
	{
		ll kk = 1 << a, mx = 0, ind = -1;
		for (int i = 0; i < n; i++)
		{
			ll d = (ll)p[i].hp *kk - (ll)p[i].dmg;

			if (d > 0 && (ind == -1 || d > mx))
			{
				ind = p[i].index;
				mx = d;
			}
		}

		if (ind > -1)
		{
			delta += mx;
			used[ind] = true;
			b--;
		}
	}

	if (b > 0)
	{
		for (int i = n - 1; i >= 0; i--)
		{
			if (!used[p[i].index] && (p[i].hp - p[i].dmg) > 0)
			{
				used[p[i].index] = true;
				delta += (p[i].hp - p[i].dmg);
				b--;

				if (b == 0)
				{
					break;
				}
			}
		}
	}

	cout << sum + delta;

	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 2 * 100000 + 10;
int n, a, b;
ll dbl[30][2];
bool used[N];

struct Elem
{
	ll hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0;

	sort(p, p + n);

	for (int i = n - 1; i >= 0; i--)
	{
		if (i < n - b)
		{
			sum += max(p[i].hp, p[i].dmg);
		}
		else
		{
			sum += p[i].dmg;
		}
	}

	if (b > 0)
	{
		ll st = 1 << a;

		for (int i = n - 1; i >= 0; i--)
		{
			ll delta = sum;

			if (i < n - b)
			{
				delta -= max(p[i].hp, p[i].dmg);
			}
			else
			{
				delta -= p[i].dmg;
				delta -= max(p[n - b].hp, p[n - b].dmg);
				delta += p[n - b].dmg;
			}

			delta += p[i].hp * st;

			sum = max(sum, delta);
		}
	}

	cout << sum;

	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 2 * 100000 + 10;
int n, a, b;
ll dbl[30][2];
bool used[N];

struct Elem
{
	int hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0, delta = 0;

	for (int i = 0; i < n; i++)
	{
		sum += (ll)p[i].dmg;
		used[i] = false;
	}

	sort(p, p + n);

	const int m = min(a, b);

	if (m > 0)
	{
		for (int i = 0; i < n; i++)
		{
			ll d = (ll)p[i].hp * 2 - (ll)p[i].dmg;

			for (int j = 0; j < m; j++)
			{
				if (d > dbl[j][0])
				{
					for (int k = m - 1; k > j; k--)
					{
						dbl[k][0] = dbl[k - 1][0];
						dbl[k][1] = dbl[k - 1][1];
					}

					dbl[j][0] = d;
					dbl[j][1] = p[i].index;

					break;
				}
			}
		}

		for (int i = 0; i < m; i++)
		{
			if (dbl[i][0] > 0)
			{
				delta += dbl[i][0];
				b--;

				used[dbl[i][1]] = true;
			}
		}
	}

	if (b > 0)
	{
		for (int i = n - 1; i >= 0; i--)
		{
			if (!used[p[i].index] && (p[i].hp - p[i].dmg) > 0)
			{
				used[p[i].index] = true;
				delta += (p[i].hp - p[i].dmg);
				b--;

				if (b == 0)
				{
					break;
				}
			}
		}
	}

	cout << sum + delta;

	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 2 * 100000 + 10;
int n, a, b;
ll dbl[30][2];
bool used[N];

struct Elem
{
	ll hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0;

	sort(p, p + n);

	for (int i = n - 1; i >= 0; i--)
	{
		if (i >= n - b)
		{
			sum += max(p[i].hp, p[i].dmg);
		}
		else
		{
			sum += p[i].dmg;
		}
	}

	ll res = sum;

	if (a > 0 && b > 0)
	{
		ll st = 1 << a;

		for (int i = n - 1; i >= 0; i--)
		{
			ll delta = sum;

			if (i >= n - b)
			{
				delta -= max(p[i].hp, p[i].dmg);
			}
			else
			{
				delta -= p[i].dmg;
				delta -= max(p[n - b].hp, p[n - b].dmg);
				delta += p[n - b].dmg;
			}

			delta += p[i].hp * st;

			res = max(res, delta);
		}
	}

	cout << res;

	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 2 * 100000 + 10;
int n, a, b;
ll dp[N][25][25];
bool used[N];

struct Elem
{
	ll hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0, delta = 0;

	for (int i = 0; i < n; i++)
	{
		sum += (ll)p[i].dmg;
		used[i] = false;
	}

	sort(p, p + n);

	if (a > 0 && b > 0)
	{
		int m = min(a, b);
		ll kk = 1 << a, mx = 0, ind = -1;

		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j <= a; j++)
			{
				for (int k = 0; k < min(m, i + 1); k++)
				{
					if (i == 0)
					{
						dp[i][j][k] = p[i].hp * (1 << j) - p[i].dmg;
					}
					else
					{
						dp[i][j][k] = dp[i - 1][j][k];

						for (int z = 1; z <= j; z++)
						{
							dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - z][k - 1] + p[i].hp * (1 << z) - p[i].dmg);
						}
					}
				}
			}
		}

		int k = 0;

		for (int i = 0; i < m; i++)
		{
			if (dp[n - 1][a][i] > dp[n - 1][a][k])
			{
				k = i;
			}
		}

		int i = n - 1, j = a;

		if (dp[n - 1][a][k] > delta)
		{
			delta = dp[n - 1][a][k];

			while (k > 0)
			{
				if (i > 0 && dp[i][j][k] == dp[i - 1][j][k])
				{
					i--;
				}
				else
				{
					for (int z = 1; z <= j; z++)
					{
						if (dp[i][j][k] == dp[i - 1][j - z][k - 1] + p[i].hp * (1 << z) - p[i].dmg)
						{
							used[p[i].index] = true;
							b--;
							break;
						}
					}
				}
			}
		}
	}

	if (b > 0)
	{
		for (int i = n - 1; i >= 0; i--)
		{
			if (!used[p[i].index] && (p[i].hp - p[i].dmg) > 0)
			{
				used[p[i].index] = true;
				delta += (p[i].hp - p[i].dmg);
				b--;

				if (b == 0)
				{
					break;
				}
			}
		}
	}

	cout << sum + delta;

	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 300 + 10;
int n, a, b;
ll dbl[30][2];
bool used[N];

struct Elem
{
	int hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0, delta = 0;

	for (int i = 0; i < n; i++)
	{
		sum += (ll)p[i].dmg;
		used[i] = false;
	}

	sort(p, p + n);

	const int m = min(a, b);

	if (m > 0)
	{
		for (int i = 0; i < n; i++)
		{
			ll d = (ll)p[i].hp * 2 - (ll)p[i].dmg;

			for (int j = 0; j < m; j++)
			{
				if (d > dbl[j][0])
				{
					for (int k = m - 1; k > j; k--)
					{
						dbl[k][0] = dbl[k - 1][0];
						dbl[k][1] = dbl[k - 1][1];
					}

					dbl[j][0] = d;
					dbl[j][1] = p[i].index;
				}
			}
		}

		for (int i = 0; i < m; i++)
		{
			if (dbl[i][0] > 0)
			{
				delta += dbl[i][0];
				b--;

				used[dbl[i][1]] = true;
			}
		}
	}

	if (b > 0)
	{
		for (int i = n - 1; i >= 0; i--)
		{
			if (!used[p[i].index] && (p[i].hp - p[i].dmg) > 0)
			{
				used[p[i].index] = true;
				delta += (p[i].hp - p[i].dmg);
				b--;

				if (b == 0)
				{
					break;
				}
			}
		}
	}

	cout << sum + delta;

	return 0;
}


#include <cstdio>;
#include <iostream>;
#include <string>;
#include <vector>;
#include <set>;
#include <queue>;
#include <map>;
#include <algorithm>;
using namespace std;
typedef long long ll;
const int N = 2 * 100000 + 10;
int n, a, b;
ll dbl[30][2];
bool used[N];

struct Elem
{
	ll hp, dmg, index;
}p[N];

bool operator<(Elem a, Elem b)
{
	return (a.hp - a.dmg) < (b.hp - b.dmg);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].hp >> p[i].dmg;
		p[i].index = i;
	}

	ll sum = 0;

	sort(p, p + n);

	for (int i = n - 1; i >= 0; i--)
	{
		if (i >= n - b)
		{
			sum += max(p[i].hp, p[i].dmg);
		}
		else
		{
			sum += p[i].dmg;
		}
	}

	if (b > 0)
	{
		ll st = 1 << a;

		for (int i = n - 1; i >= 0; i--)
		{
			ll delta = sum;

			if (i >= n - b)
			{
				delta -= max(p[i].hp, p[i].dmg);
			}
			else
			{
				delta -= p[i].dmg;
				delta -= max(p[n - b].hp, p[n - b].dmg);
				delta += p[n - b].dmg;
			}

			delta += p[i].hp * st;

			sum = max(sum, delta);
		}
	}

	cout << sum;

	return 0;
}


#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<tuple>
#include<set>
#include<utility>
#include<map>
#include<unordered_map>
#include<bitset>
using namespace std;
typedef long long ll;
struct node {
	ll hp, dmg, d;
	node(ll a, ll b) {
		hp = a; dmg = b; d = hp - dmg;
	}
	node() {

	}
};
bool operator < (node &a, node &b) {
	return a.d < b.d;
}
int main() {
	int i, aa, bb;
	int n; cin >> n >> aa >> bb;
	vector<node> A(n);
	for (i = 0; i < n; i++) {
		cin >> A[i].hp >> A[i].dmg;
		A[i].d = A[i].hp - A[i].dmg;
	}
	sort(A.begin(), A.end());
	ll ans = 0, sum = 0;
	if (bb == 0) {
		for (i = 0; i < n; i++) {
			ans += A[i].dmg;
		}
		cout << ans;
		return 0;
	}
	if (bb > n) bb = n;
	for (i = 0; i < bb; i++) {
		sum += max(A[i].hp, A[i].dmg);
	}
	for (i = bb; i < n; i++) {
		sum += A[i].dmg;
	}
	ll xx = 1, mx = 0; // delta의 최대값
	for (i = 1; i <= aa; i++) xx *= 2;
	for (i = 0; i < bb; i++) {
		ll a, b, c, d;
		a = A[i].hp*xx;
		b = max(a, A[i].dmg); // 변경값
		c = max(A[i].hp, A[i].dmg); // 기존값
		d = b - c;
		if (d > mx) mx = d;
	}
	for (i = bb; i < n; i++) {
		ll a, b, c, d;
		a = A[i].hp*xx;
		b = A[bb-1].dmg + max(a, A[i].dmg); // 변경값
		c = max(A[bb - 1].hp, A[bb - 1].dmg) + A[i].dmg; // 기존값
		d = b - c;
		if (d > mx) mx = d;
	}
	cout << sum + mx;
}


#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<tuple>
#include<set>
#include<utility>
#include<map>
#include<unordered_map>
#include<bitset>
using namespace std;
typedef long long ll;
struct node {
	ll hp, dmg, d;
	node(ll a, ll b) {
		hp = a; dmg = b; d = hp - dmg;
	}
	node() {

	}
};
bool operator < (node &a, node &b) {
	return a.d < b.d;
}
int main() {
	int i, aa, bb;
	int n; cin >> n >> aa >> bb;
	vector<node> A(n);
	for (i = 0; i < n; i++) {
		cin >> A[i].hp >> A[i].dmg;
		A[i].d = A[i].dmg - A[i].hp;
	}
	sort(A.begin(), A.end());
	ll ans = 0, sum = 0;
	if (bb == 0) {
		for (i = 0; i < n; i++) {
			ans += A[i].dmg;
		}
		cout << ans;
		return 0;
	}
	if (bb > n) bb = n;
	for (i = 0; i < bb; i++) {
		sum += max(A[i].hp, A[i].dmg);
	}
	for (i = bb; i < n; i++) {
		sum += A[i].dmg;
	}
	ll xx = 1, mx = 0; // delta의 최대값
	for (i = 1; i <= aa; i++) xx *= 2;
	for (i = 0; i < bb; i++) {
		ll a, b, c, d;
		a = A[i].hp*xx;
		b = max(a, A[i].dmg); // 변경값
		c = max(A[i].hp, A[i].dmg); // 기존값
		d = b - c;
		if (d > mx) mx = d;
	}
	for (i = bb; i < n; i++) {
		ll a, b, c, d;
		a = A[i].hp*xx;
		b = A[bb-1].dmg + max(a, A[i].dmg); // 변경값
		c = max(A[bb - 1].hp, A[bb - 1].dmg) + A[i].dmg; // 기존값
		d = b - c;
		if (d > mx) mx = d;
	}
	cout << sum + mx;
}


N, A, B = map(int, input().split())
hp = []
dmg = []
for _ in range(N):
    h, d = map(int, input().split())
    hp.append(h)
    dmg.append(d)

if B == 0:
    print(sum(dmg))
    quit()
if B == 1:
    surplus = [hp[i] * (2 ** A) - dmg[i] for i in range(N)]
    # surplus = [0] * N
    # max_index = -1
    # max_surplus = 0
    # surplus[0] = hp[0] * (2 ** A) - dmg[0]
    # if max_surplus < surplus[0]:
    #     max_surplus = surplus[0]
    #     max_index = 0
    # for i in range(1, N):
    #     surplus[i] = hp[i] * (2 ** A) - dmg[i]
    #     if max_surplus < surplus[i]:
    #         max_surplus = surplus[i]
    #         max_index = i
    max_surplus = max(surplus)
    # max_index = surplus.index(max_surplus)

    print(sum(dmg) + max(0, max_surplus))
    quit()

# surplus = [0] * N
surplus = [hp[i] * (2 ** A) - dmg[i] for i in range(N)]
# max_index = -1
# max_surplus = 0

# surplus[0] = hp[0] * (2 ** A) - dmg[0]
# if max_surplus < surplus[0]:
#     max_surplus = surplus[0]
#     max_index = 0
# for i in range(1, N):
#     surplus[i] = hp[i] * (2 ** A) - dmg[i]
#     if max_surplus < surplus[i]:
#         max_surplus = surplus[i]
#         max_index = i

max_surplus = max(surplus)
max_index = surplus.index(max_surplus)

if max_surplus > 0:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]
    sur[max_index][1] = max_surplus

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)

else:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)


N, A, B = map(int, input().split())
hp = []
dmg = []
for _ in range(N):
    h, d = map(int, input().split())
    hp.append(h)
    dmg.append(d)

if B == 0:
    print(sum(dmg))
    quit()
if B == 1:
    surplus = [(hp[i] << A) - dmg[i] for i in range(N)]
    max_surplus = max(surplus)

    print(sum(dmg) + max(0, max_surplus))
    quit()

surplus = [(hp[i] << A) - dmg[i] for i in range(N)]

max_surplus = max(surplus)
max_index = surplus.index(max_surplus)

if max_surplus > 0:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]
    sur[max_index][1] = max_surplus

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)

else:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)


# python3
from sys import stdin

def main():
    def parseints(line): return tuple(map(int, line.split()))
    def bdiff(creature): return max(0, creature[0] - creature[1])

    n, a, b = parseints(input())
    hand = list(map(parseints, stdin.readlines()))

    ans = sum(creature[1] for creature in hand)  # default damage
    if b:
        hand.sort(key=bdiff)

        best = 0
        if n > b:
            lost = bdiff(hand[n - b])
            for creature in hand[:n-b]:
                best = max(best, (creature[0] << a) - creature[1] - lost)

        for creature in hand[max(0,n-b):]:
            best = max(best, (creature[0] << a) - max(creature))
            ans += bdiff(creature)
        ans += best

    print(ans)

main()


def main():
    N, A, B = map(int, input().split())
    hp = []
    dmg = []
    for _ in range(N):
        h, d = map(int, input().split())
        hp.append(h)
        dmg.append(d)

    if B == 0:
        print(sum(dmg))
        quit()
    if B == 1:
        surplus = [(hp[i] << A) - dmg[i] for i in range(N)]
        max_surplus = max(surplus)

        print(sum(dmg) + max(0, max_surplus))
        quit()

    surplus = [(hp[i] << A) - dmg[i] for i in range(N)]

    max_surplus = max(surplus)
    max_index = surplus.index(max_surplus)

    if max_surplus > 0:
        sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]
        sur[max_index][1] = max_surplus

        sur.sort(key=lambda x: x[1], reverse=True)
        ans = 0
        for i in range(N):
            if B > 0:
                ans += dmg[sur[i][0]] + sur[i][1]
                B -= 1
            else:
                ans += dmg[sur[i][0]]

        print(ans)

    else:
        sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]

        sur.sort(key=lambda x: x[1], reverse=True)
        ans = 0
        for i in range(N):
            if B > 0:
                ans += dmg[sur[i][0]] + sur[i][1]
                B -= 1
            else:
                ans += dmg[sur[i][0]]

        print(ans)

main()