stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

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

#define mod 1000000007

typedef long long ll;

using namespace std;

ll n,m;

priority_queue<ll>q;

int main()

{

    abdelrahman001

    cin >> n >> m;

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

        cin >> x,q.push(x);

    while(m--)

    {

        ll x = q.top();

        q.pop();

        q.push(x/2);

    }

    ll ans = 0;

    while(!q.empty())

        ans+=q.top(),q.pop();

    cout << ans;

    return 0;

}


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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

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

using namespace std;

#define F first

#define S second

#define X real()

#define Y imag()

#define cross(a, b) ((conj(a) * (b)).Y)

#define dot(a, b) ((conj(a) * (b)).X)

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

#define allr(v) (v).rbegin(),(v).rend()

#define EPS 1e-7

#define iof freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

long long mod = 1e9;

const int N = 1e9;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

const double pi = acos(-1);

typedef complex <ll> point;

typedef tuple<int, int, int> line;

typedef vector<point> polygon;

ll n, m, x, ans;

priority_queue<ll> q;

int main()

{

    em3

    cin >> n >> m;

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

        cin >> x, q.push(x);

    while(m--)

    {

        ll temp = q.top();

        q.pop();

        q.push(temp / 2);

    }

    while(!q.empty())

    {

        ans += q.top();

        q.pop();

    }

    cout << ans << endl;



    return 0;

}




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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

using namespace std;

typedef long long ll;



int main(){

    ll N,M;

    cin >> N >> M;

    priority_queue<ll, vector<ll>, less<ll>> pq;

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

        ll a_i; cin >> a_i;

        pq.push(a_i);

    }

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

        ll top = pq.top();

        pq.pop();

        top = top/2;

        pq.push(top);

    }

    ll cost = 0;

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

        cost += pq.top();

        pq.pop();

    }

    cout << cost << "\n";

    return 0;

}

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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

using namespace std;



long long sum;

int n,m,a,p;

priority_queue< int >q;



int main()

{



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



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

		scanf("%d",&a),q.push(a);

		

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

		p = q.top(),q.pop(),p /= 2,q.push(p);



	while(!q.empty())

		p = q.top(),q.pop(),sum += p;



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

	

	return 0;

}

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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<queue>

#include<cmath>

using namespace std;

#define maxn 100010

int n,m;

long long a[maxn];

int main()

{

	priority_queue<long long>q;

	 

	cin>>n>>m;

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

	{

		cin>>a[i];

		q.push(a[i]);

	 } 

	while(m)

	{

		m--;

		long long tmp=q.top();

		q.pop();

		tmp/=2;

		

		q.push(tmp);

	}

	long long sum=0;

    while(!q.empty())

    {

    	sum+=q.top();

    	q.pop();

	}

	long long ans=sum;

	cout<<ans;

	return 0;

}

 

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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

#include <cstdio>

#include <algorithm>

using namespace std;

typedef long long LL;



int n, m;

LL ans;



priority_queue <int> Q;



int main()

{

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

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

	{

		scanf("%d", &x);

		Q.push(x);

	}

	while (m --)

	{

		int t = Q.top();

		Q.pop();

		Q.push(t / 2);

	}

	while (!Q.empty())

	{

		ans += Q.top();

		Q.pop();

	}

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

	return 0;

}

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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

#include<cstdio>

#include<queue>



typedef long long ll ;



using namespace std ;





int main()

{

    priority_queue <double> q ;



    int n , m ; scanf("%d%d",&n,&m) ;

    int i, x ;

    double y ;

    ll sum = 0 ;

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

    {

        scanf("%d",&x) ;

        q.push(x) ;

    }



    while(m--)

    {

        y = q.top() ;

        q.pop() ;

        y /= 2 ;

        q.push(y) ;

    }

    while(n--)

    {

        y = q.top() ;

        sum += (int) y ;

        q.pop() ;

    }



    cout << sum ;

    return 0 ;

}


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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

#include <vector>

#include <utility>

#include <map>

#include <algorithm>

#include <queue>

#include <cmath>

#include <string>



using namespace std;



int main() {

  int n,m;

  cin >> n >> m;

  priority_queue<long> q;

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

    int a;

    cin >> a;

    q.push(a);

  }



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

    int a = q.top();

    q.pop();

    q.push((int)((double)a/2.0));

  }



  long ans = 0;

  while(! q.empty()) {

    ans += q.top();

    q.pop();

  }



  cout << ans << endl;

}

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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

#include <string>

#include <vector>

#include <deque>

#include <algorithm>

using namespace std;

typedef long long ll;

#define N 100005

//week_9_A

void relocate(ll a[], int len)

{

    int fath = 0;

    ll val;

    while(1)

    {

        int son = fath*2+1;

        val = a[fath];

        if(son+1 < len && a[son] < a[son+1])

            son++;

        if( val < a[son] )

        {

            a[fath] = a[son];

            a[son] = val;

            fath = son;

        }

        else if (val >= a[son])

            break;

    }

}

void shiftdown(ll a[], int fath, int len)

{

    int ffath = fath;

    ll val = a[fath];

    int son = ffath*2 + 1;

    while(son < len)

    {

        if(son+1 < len && a[son] < a[son+1])

            son++;

        if(val < a[son])

        {

            a[ffath] = a[son];

            a[son] = val;

            ffath = son;

        }

        else

            break;

        son = ffath*2+1;

    }

}



void week_9_A()

{

    static ll a[100005];

    int n, m;

    cin >> n >> m;

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

        cin >> a[i];

    for (int fath = (n-2)/2; fath >= 0; fath--)

        shiftdown(a, fath, n);

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

//        cout << a[i] << " ";

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

    {

        a[0] /= 2;

        shiftdown(a, 0, n);

    }

    ll ans = 0;

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

        ans += a[i];

    cout << ans;

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    week_9_A();

}

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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

#include<algorithm>

#include<queue>

using namespace std;



int main(){

    int n,m;

    cin>>n>>m;

    long long int x;

    priority_queue<long long int> a;

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

        cin>>x;

        a.push(x);

    }

    while(m--){

        x=a.top()/2;

        a.pop();

        a.push(x);

    }

    long long int sum=0;

    while(!a.empty()){

        sum+=a.top();

        a.pop();

    }

    cout<<sum;

    return 0;

}


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



typedef long long LL;



const int MAXN=100005;



void fix_down(int *h,int i,int n)

{

    int j=i,k,t=h[i];

    while ((j<<1)+1<n)

    {

        k=(j<<1)+1;

        if (k+1<n&&h[k+1]>h[k]) k=k+1;

        if (t>=h[k]) break;

        h[j]=h[k];

        j=k;

    }

    h[j]=t;

}



int main()

{

    int N,M,t;

    LL ans=0LL;

    static int h[MAXN];



    scanf("%d%d",&N,&M);

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

        scanf("%d",&h[i]);



    for (int i=N-1;i>=0;--i)

        fix_down(h,i,N);

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

    {

        if (h[0]==0) break;

        h[0]=h[0]>>1;

        fix_down(h,0,N);

    }

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

        ans=ans+h[i];

    printf("%lld",ans);



    return 0;

}




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

#define ll long long

#define ull unsinged long long

#define ld long double

#define mem(a,b) memset(a,b,sizeof(a))

#define inf (1LL<<62)

#define sf scanf

#define pf printf

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

#define rep(i,a,b) for(ll i=a;i<=b;++i)

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

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

#define mod 1000000007



using namespace std;



struct cmp

{

    bool operator()(const double &a,const double b)const

    {

        return a>b;

    }

};



multiset<double,cmp> s;

multiset<double,cmp>::iterator it;



int main()

{

    //std::ios::sync_with_stdio(false);

    int n,m;

    double x;

    sf("%d%d",&n,&m);

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

    {

        cin>>x;

        s.insert(x);

    }

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

    {

        double a=*s.begin();

        s.erase(s.begin());

        s.insert(a*1.0/2);

    }

    ll ans=0;

    for(it=s.begin();it!=s.end();++it)

    {

        ans+=(int)*it;

    }

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



    return 0;

}


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

#include <cctype>

#include <queue>

#define int long long



std::priority_queue<int > a;

int n, m;



int read() {

    int ret, f = 1;

    char ch;

    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);

    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');

    return ret * f;

}



void print(int x) {

    if(x < 0) putchar('-'), x = -x;

    if(x > 9) print(x / 10);

    putchar(x % 10 + '0');

}



signed main() {

    n = read(), m = read();

    for(int i = 1; i <= n; ++i) a.push(read());

    while(m--) {

        int t = a.top();

        a.pop();

        a.push(t >> 1);

    }

    int ans = 0;

    while(!a.empty()) ans += a.top(), a.pop();

    print(ans);

    return 0;

}

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



using namespace std;

const int MAX = 1e5 + 5;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int n , k ;

    cin>>n>>k;

    

    priority_queue<int>pq;

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

        int tmp;

        cin>>tmp;

        pq.push(tmp);

    }

    

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

        int top = pq.top();

        pq.pop();

        pq.push(top/2);

    }

    long long int ans = 0;

    while( !pq.empty()) {

        ans += pq.top();

        pq.pop();

    }

    cout<<ans<<'\n';

    return 0;

}

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

#include <cctype>

#include <queue>

#define int long long



std::priority_queue<int > a;

int n, m;



int read() {

    int ret, f = 1;

    char ch;

    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);

    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');

    return ret * f;

}



void print(int x) {

    if(x < 0) putchar('-'), x = -x;

    if(x > 9) print(x / 10);

    putchar(x % 10 + '0');

}



signed main() {

    n = read(), m = read();

    for(int i = 1; i <= n; ++i) a.push(read());

    while(m--) {

        int t = a.top();

        a.pop();

        a.push(t >> 1);

    }

    int ans = 0;

    while(!a.empty()) ans += a.top(), a.pop();

    print(ans);

    return 0;

}

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

#include<stdio.h>

#include<string>

#include<stdlib.h>

#include<math.h>

#include<queue>

#include<algorithm>

using namespace std;

int n,m;

double x;

long long s,s1;

priority_queue<double> p;

int main()

{

	int i;

	cin>>n>>m;

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

	{

		cin>>x;

		p.push(x);

	}

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

	{

		x=p.top();

		p.pop();

		x/=2;

		p.push(x);

	}

	s=0;

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

	{

		s1=(long long)p.top();

		s+=s1;

		p.pop();

	}

	printf("%Ild\n",s);

	return 0;

}

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

#include <cctype>

#include <queue>

#define int long long



std::priority_queue<int > a;

int n, m;



int read() {

    int ret, f = 1;

    char ch;

    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);

    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');

    return ret * f;

}



void print(int x) {

    if(x < 0) putchar('-'), x = -x;

    if(x > 9) print(x / 10);

    putchar(x % 10 + '0');

}



signed main() {

    n = read(), m = read();

    for(int i = 1; i <= n; ++i) a.push(read());

    while(m--) {

        int t = a.top();

        a.pop();

        a.push(t >> 1);

    }

    int ans = 0;

    while(!a.empty()) ans += a.top(), a.pop();

    print(ans);

    return 0;

}

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

#include<cmath>

#include<algorithm>

#include<queue>

using namespace std;

int main() 

{

	priority_queue<int>x;

	int m, n, t;

	cin >> n >> m;

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

	{

		scanf("%d",&t);

		x.push(t);

	}

	long long sum = 0;

	while (m) 

	{

		t = x.top() / 2;

		x.pop();

		x.push(t);

		m--;

	}

	while (!x.empty()) 

	{

		sum += x.top();

		x.pop();

	}

	cout << sum<<endl;

	return 0;

}

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

#include <cctype>

#include <queue>

#define int long long



std::priority_queue<int > a;

int n, m;



int read() {

    int ret, f = 1;

    char ch;

    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);

    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');

    return ret * f;

}



void print(int x) {

    if(x < 0) putchar('-'), x = -x;

    if(x > 9) print(x / 10);

    putchar(x % 10 + '0');

}



signed main() {

    n = read(), m = read();

    for(int i = 1; i <= n; ++i) a.push(read());

    while(m--) {

        int t = a.top();

        a.pop();

        a.push(t >> 1);

    }

    int ans = 0;

    while(!a.empty()) ans += a.top(), a.pop();

    print(ans);

    return 0;

}

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

#define endl '\n';

typedef long long ll;

const ll INF = 1e17 + 1;

const ll MAX = 2147483647;

const ll MOD = 1000003;



using namespace std;



ll min(ll x, ll y, ll z)

{

    return min(min(x, y), z);

}

ll max(ll x, ll y, ll z)

{

    return max(max(x, y), z);

}



ll min(ll x, ll y, ll z, ll o)

{

    return min(min(x, y, z), o);

}



ll _power(ll b, ll p)

{

    ll res = 1;

    while (p)

    {

        if (p % 2)

            res = (res * b) % MOD;

        b = (b * b) % MOD;

        p /= 2;

    }

    return res;

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll n, m;

    cin >> n >> m;

    vector<ll> arr(n + 1);

    priority_queue<ll> pq;

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

    {

        cin >> arr[i];

        pq.push(arr[i]);

    }

    while (m--)

    {

        ll top = pq.top();

        pq.pop();

        pq.push(top / 2);

    }

    ll sum = 0;

    while (!pq.empty())

    {

        sum += pq.top();

        pq.pop();

    }

    cout << sum << endl;



    return 0;

}


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

#include <cctype>

#include <queue>

#define int long long



std::priority_queue<int > a;

int n, m;



int read() {

    int ret, f = 1;

    char ch;

    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);

    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');

    return ret * f;

}



void print(int x) {

    if(x < 0) putchar('-'), x = -x;

    if(x > 9) print(x / 10);

    putchar(x % 10 + '0');

}



signed main() {

    n = read(), m = read();

    for(int i = 1; i <= n; ++i) a.push(read());

    while(m--) {

        int t = a.top();

        a.pop();

        a.push(t >> 1);

    }

    int ans = 0;

    while(!a.empty()) ans += a.top(), a.pop();

    print(ans);

    return 0;

}

// Fastest known solution for this problem: