criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

struct hoge {

};

int main(void){
	ios::sync_with_stdio(false);
	long A, B, i, j, k, M, N;
	lint res;
	cin >> N >> M;
	long nedan;
	double nlog;
	double a, b, c;
	b = 1.0 / log(2.0);
	for (i = 0; i < N; i++) {
		cin >> nedan[i];
		nlog[i] = log(nedan[i])) *b;
	}
	for (j = 0; j < M; j++) {
		a = 0.0;
		k = 0;
		for (i = 0; i < N; i++) {
			if (nlog[i] > a) {
				k = i;
				a = nlog[i];
			}
		}
		nedan[k] /= 2;
		nlog[k] = log(double(nedan[k]))*b;
	}
	res = 0;
	for (i = 0; i < N; i++) {
		res += nedan[i];
	}
	cout << res;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:29: error: invalid types 'long int[long int]' for array subscript
   25 |                 cin >> nedan[i];
      |                             ^
a.cc:26:21: error: invalid types 'double[long int]' for array subscript
   26 |                 nlog[i] = log(nedan[i])) *b;
      |                     ^
a.cc:26:36: error: invalid types 'long int[long int]' for array subscript
   26 |                 nlog[i] = log(nedan[i])) *b;
      |                                    ^
a.cc:32:33: error: invalid types 'double[long int]' for array subscript
   32 |                         if (nlog[i] > a) {
      |                                 ^
a.cc:34:41: error: invalid types 'double[long int]' for array subscript
   34 |                                 a = nlog[i];
      |                                         ^
a.cc:37:22: error: invalid types 'long int[long int]' for array subscript
   37 |                 nedan[k] /= 2;
      |                      ^
a.cc:38:21: error: invalid types 'double[long int]' for array subscript
   38 |                 nlog[k] = log(double(nedan[k]))*b;
      |                     ^
a.cc:38:43: error: invalid types 'long int[long int]' for array subscript
   38 |                 nlog[k] = log(double(nedan[k]))*b;
      |                                           ^
a.cc:42:29: error: invalid types 'long int[long int]' for array subscript
   42 |                 res += nedan[i];
      |                             ^
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    priority_queue<int> pq;
    for(int i = 0;i<n;i++){
    	int t;
    	cin>>t;
    	pq.push(t);
    }
    while(m){
    	int temp = pq.top();
    	pq.pop();
    	temp/=2;
    	pq.push(temp);
    	m--;
    }
    int ans = 0;
    while(!pq.empty()){
    	ans += pq.top();
    	pq.pop()
    }
    cout<<ans<<endl;
    return 0;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:45:17: error: expected ';' before '}' token
   45 |         pq.pop()
      |                 ^
      |                 ;
   46 |     }
      |     ~
Language: C++

include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main()
{
  int N, M;
  vector<int> a[100];
  ll res=0;
  cin >> N >> M;

  int max_b = 0;
  for(int i=0;i<N;i++){
    int in;
    cin >> in;
    int tmp = in;
    int bucket = 0;
    while(tmp >0){
      tmp /= 2;
      bucket++;
    }
    a[bucket].push_back(in);
    max_b = max(bucket, max_b);
    //    printf("in:%d, max_b:%d, bucket:%d\n", in, max_b, bucket);
  }


  //  rep(j,max_b+1)
  //    for(auto itr=a[j].begin();itr<a[j].end();itr++)
  //      printf("bucket:%d num:%d\n", j, *itr);
  
  rep(i,M){
    auto itr = a[max_b].begin();
    if(*itr/2>0) {
      a[max_b-1].push_back(*itr/2);
      a[max_b].erase(itr);
    } else{
      *itr = *itr/2;
    }
    while(a[max_b].empty()) max_b--;
    
    while(*(itr+1)>*(itr)){
      int buf = *(itr+1);
      *(itr+1) = *itr;
      *itr = buf;
      itr++;
    }
    //    rep(j,max_b+1)
    //      for(auto itr=a[j].begin();itr<a[j].end();itr++)
    //  printf("iteration:%d bucket:%d num:%d\n", i, j, *itr);
  

  }
  rep(i,max_b+1)
    res += accumulate(a[i].begin(),a[i].end(),0LL);
  
  cout << res << endl;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> a[100];
      |   ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> a[100];
      |          ^~~
a.cc:11:3: error: 'cin' was not declared in this scope
   11 |   cin >> N >> M;
      |   ^~~
a.cc:23:5: error: 'a' was not declared in this scope
   23 |     a[bucket].push_back(in);
      |     ^
a.cc:24:13: error: 'max' was not declared in this scope; did you mean 'max_b'?
   24 |     max_b = max(bucket, max_b);
      |             ^~~
      |             max_b
a.cc:34:16: error: 'a' was not declared in this scope
   34 |     auto itr = a[max_b].begin();
      |                ^
a.cc:56:23: error: 'a' was not declared in this scope
   56 |     res += accumulate(a[i].begin(),a[i].end(),0LL);
      |                       ^
a.cc:56:12: error: 'accumulate' was not declared in this scope
   56 |     res += accumulate(a[i].begin(),a[i].end(),0LL);
      |            ^~~~~~~~~~
a.cc:58:3: error: 'cout' was not declared in this scope
   58 |   cout << res << endl;
      |   ^~~~
a.cc:58:18: error: 'endl' was not declared in this scope
   58 |   cout << res << endl;
      |                  ^~~~
Language: C++

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int N,M;
  cin >> N >> M;
  array<long long> A(N);
  REP(i,N) {
    cin >> A[i];
  }
  long long sum = 0;
  REP(i,M) {
    *max_element(ALL(A)) /= 2;
  }
  REP(i,N) {
    sum += A[i];
  }
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: wrong number of template arguments (1, should be 2)
   12 |   array<long long> A(N);
      |                  ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: provided for 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:14:13: error: invalid types 'int[int]' for array subscript
   14 |     cin >> A[i];
      |             ^
a.cc:7:18: error: request for member 'begin' in 'A', which is of non-class type 'int'
    7 | #define ALL(v) v.begin(), v.end()
      |                  ^~~~~
a.cc:18:18: note: in expansion of macro 'ALL'
   18 |     *max_element(ALL(A)) /= 2;
      |                  ^~~
a.cc:7:29: error: request for member 'end' in 'A', which is of non-class type 'int'
    7 | #define ALL(v) v.begin(), v.end()
      |                             ^~~
a.cc:18:18: note: in expansion of macro 'ALL'
   18 |     *max_element(ALL(A)) /= 2;
      |                  ^~~
a.cc:21:13: error: invalid types 'int[int]' for array subscript
   21 |     sum += A[i];
      |             ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;

int main () {
int n, m;
  cin >> n >> m;
  vector<int64_t> a(n);
  priority_queue<int64_t> b;
  rep(i,n) {
    cin >> a.at(i);
    b.push(a.at(i));
  rep(i,m) {
    b.top() /=2;
  }
  int64_t sum;
  rep(i,n) sum += a.at(i);
  cout << sum;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: assignment of read-only location 'b.std::priority_queue<long int>::top()'
   14 |     b.top() /=2;
      |     ~~~~~~~~^~~
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:5:13: note: to match this '{'
    5 | int main () {
      |             ^
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
using namespace std;

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> a(N);

  for(ll i=0;i<N;i++){
    cin>>a[i];
  }


  sort(ALL(a));
  reverse(ALL(a));


ll ai = 0;
ll tmp1;
ll nowk=0;
vector<queue<ll>> ss(4);

for(ll i=0;i<N;i++){
  ss[0].push(a[i]);
}


for(ll i=0;i<M;i++){
  
  
  
  if(ss[1].empty()){
    ss[1].push(ss[0].front()/2);
    ss[0].pop();
  }
  else if(ss[0].front()>=ss[1].front()){
    ss[1].push(ss[0].front()/2);
    ss[0].pop();
  }
  else{
    ss[2].push(ss[1].front()/2);
    ss[1].pop();
  }

  if(ss[0].empty()){
    ss[0]= ss[1];
    ss[1]= ss[2];
    ss[2]= ss[3];
  }

  if(ss[1].empty()&&!(ss[2].empty())){
    auto ssss=ss[2];
    ss[2]=ss[1];
    ss[1]=ssss;
  }




}



  ll ans=0;
  for(ll i=0;i<4;i++){
    for(ll j=0;j<ss[i].size();j++){
      ans+=ss[i].front();
        ans+=ss.pop_back();
    }
  }

  cout<<ans<<endl;

}

/*

for(ll i=0;i<M;i++){
    if(now+1<a.size()&&a[now]<a[now+1]){
      tmp1=a[now];
      a[now]=a[now+1];
      a[now+1]=tmp1;
    }
    a[0]/=2;
    now=0;


  }

  
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:70:25: error: void value not ignored as it ought to be
   70 |         ans+=ss.pop_back();
      |              ~~~~~~~~~~~^~
Language: C++

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

int main(void){

  long long n,m;
  cin >> n >> m;
  vector<long long> a(n);
  long long i = 0;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  long long max = 0;
  sort(a.begin(),a.end(),std::greater<int>());
  
  long long sum = 0;
  long long j=0;
  for(i=0;i<n-1;i++){
    
    if(m != 0){
    
    if(max > a[i] && m != 0 && i !=　0){
      a[j] = a[j] / 2;
      m = m - 1;
      max = a[i];
      j = i;
    }
    
    if(m != 0){
    do{
      
      a[i] = a[i] / 2;
      m = m - 1; 
    
    }while(a[i] > a[i+1] && m != 0 );
    }
    
    if(i==0){
    max = a[i];
    j = i;
    }
    
    
    
    }
    
    
  }

  //sum = sum + a[n-1];
  for(i=0;i<n;i++){
      sum = sum + a[i];

    
  }
  cout << sum << endl;
  
  
  return 0;

}

Compiler output:
a.cc:22:36: error: extended character 　 is not valid in an identifier
   22 |     if(max > a[i] && m != 0 && i !=　0){
      |                                    ^
a.cc: In function 'int main()':
a.cc:22:36: error: '\U000030000' was not declared in this scope
   22 |     if(max > a[i] && m != 0 && i !=　0){
      |                                    ^~~
Language: C

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int N, M, a, ans=0, ex=0;
    scanf("%d %d", &N, &M);
    vector<int> A(N);
    
    for (int i = 0; i < N; i++){
        scanf("%d", &a);
        A[i] = a;
    }
    sort(A.begin(), A.end(), greater<int>() );
    
    for (int i = 0; i < N-1; i++){
        while(A[i] - A[i]/2 > A[i+1] - A[i+1]/2 and M > 0){
            A[i] = A[i]/2;
            M--;
        }
    }
    for (int i = 0; i < N-1; i++){
        ans += A[i];
    }
    ex = A[N-1];
    for (int i = 0; i < M; i++){
        ex /= 2;
    }
    cout << ans + ex << endl;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	vector<double> a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i];

	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < M; i++) {
		a[0] /= 2;
    if (a[0] < a[1]){
      double tmp = a[0];
      for (int j = 0;; j++){
        if (tmp < a[j]) break;
        a[j] = a[j + 1];
      }
      a[j - 1] = tmp
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += (int)a[i];
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'j' was not declared in this scope
   23 |       a[j - 1] = tmp
      |         ^
a.cc:34:2: error: expected '}' at end of input
   34 | }
      |  ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C++

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

int main() {
  long long int N,M;
  cin >> N>>M;
  
  vector<long long int> vec(N);
for (long long int i = 0; i < N; i++) {
   cin >>vec.at(i) ;
}
  long long int max = max_element(vec.begin(), vec.end());
  long long int a=0;
  
  for (long long int i = 0; i < M; i++) {
    if(vec.at(N-1) ==0){
      break;
    }
   a  += max/2;
  long long int max = max_element(vec.begin(), vec.end());
  }
  
  long long int sum=0;
  
  for (long long int i = 0; i < N; i++) {
    sum += vec.at(i);
  }
    
cout << sum-a << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:34: error: cannot convert '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long long int' in initialization
   12 |   long long int max = max_element(vec.begin(), vec.end());
      |                       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >
a.cc:20:34: error: cannot convert '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long long int' in initialization
   20 |   long long int max = max_element(vec.begin(), vec.end());
      |                       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >
Language: C++

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

int main() {
  int N,M,s=0;
  vector<int> a(100100);
  cin >> N >> M;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<M;i++){
    sort(a.begin(), a.end());
    reverse(vec.begin(), vec.end());
    a.at(0) = a.at(0)/2;
  }
  for(int i=0;i<N;i++){
    s=s+a.at(i);
  }
  cout << s <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'vec' was not declared in this scope
   13 |     reverse(vec.begin(), vec.end());
      |             ^~~
Language: C++

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

int min(int m,int a,int b){
  int ans;
  int end;
  int w=2000000000;
  for(int ans=m;ans>=0;ans--){
    if(((a/pow(2,ans)+b/pow(2,m-ans))<=w){
      w=(a/pow(2,ans)+b/pow(2,m-ans);end=ans;}
}
  return end;}

int main(){
  int n,m;
  cin>>n>>m;
  
  vector<int> a(n); 
  for(int i=0;i<n;i++){
    cin>>a[i];}
  
  sort(a.begin(),a.end());
  
  
  int b[n];
  
  long long int answer=0;
  int z=m;
  for (int i=0;i<n-1;i++){
    b[i]=min(z,a[i],a[i+1]);
    z-=min(z,a[i],a[i+1]);
    answer+=a[i]/pow(2,b[i]);}
 
  
  
  cout <<answer;
}
  
 

Compiler output:
a.cc: In function 'int min(int, int, int)':
a.cc:13:42: error: expected ')' before '{' token
   13 |     if(((a/pow(2,ans)+b/pow(2,m-ans))<=w){
      |       ~                                  ^
      |                                          )
a.cc:15:1: error: expected primary-expression before '}' token
   15 | }
      | ^
Language: C++

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

int main(){
  int N,M,i,j=0,k,ans=0,tmp,tmp1;
  cin >> N >> M;
  vector<int> A(N);
  for(i = 0; i < N; i++)
    cin >> A.at(i);
  sort(A.begin(),A.end());
  
  while(j<M){
    k = N-1;
    q= N-1;
    while(k == 0){
      if(A.at(k) < A.at(k-1)){
        swap(A.at(k),A.at(k-1));
        k--;
      }
      else break;
    }
    A.at(q) /= 2;
    for(i=0;i<N;i++)
      cout << A.at(i) << " ";
    
    j++;
  }
  for(i=0;i<N;i++)
    ans += A.at(i);
  cout << ans;
  return 0;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'q' was not declared in this scope
   14 |     q= N-1;
      |     ^
Language: C++

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

int main(){
  int n,m,b,sum=0;
  cin>>n>>m;
  vector<int> a(n);
  0-indexed;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
  sort(a.begin(),a.end());
    b=a.back();
    a.pop_back();
    a.push_back(b/=2);
  }
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'indexed' was not declared in this scope; did you mean 'index'?
    8 |   0-indexed;
      |     ^~~~~~~
      |     index
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,m;
long sum;
cin>>n>>m;
vector<int> vec(n);
sum =0;
for(int i=0;i<n;i++){
	cin>>vec[i];
}
  
for(int i =0;i<m;i++){
  	sort(vec.begin(), vec.end());
	vec[n-1]/=2;
}
}
for(int i=0;i<n;i++){
	sum += vec[i];
}

cout<<sum<<endl;

}

Compiler output:
a.cc:19:1: error: expected unqualified-id before 'for'
   19 | for(int i=0;i<n;i++){
      | ^~~
a.cc:19:13: error: 'i' does not name a type
   19 | for(int i=0;i<n;i++){
      |             ^
a.cc:19:17: error: 'i' does not name a type
   19 | for(int i=0;i<n;i++){
      |                 ^
a.cc:23:1: error: 'cout' does not name a type
   23 | cout<<sum<<endl;
      | ^~~~
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
Language: C++

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

int main() {

    int N, M; cin >> N >> M;
    vector <int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);

    sort(A.begin(), A.end(), greater<int>());
    int num_max = 0;

    for (int i = 0; i < M; i++){
        A.at(num_max) /= 2;
        if (A.at(num_max+1) > A.at(num_max)) num_max++;

        if (num_max > 0) {
            if (A.at(num_max+1) > A.at(num_max)) num_max++;
            else if A.at(num_max-1) > A.at(num_max)) num_max--;
        }
    }
        
    float sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A.at(i);
    }

    cout << round(sum) << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:21: error: expected '(' before 'A'
   19 |             else if A.at(num_max-1) > A.at(num_max)) num_max--;
      |                     ^
      |                     (
Language: Java

import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
      	int discount = sc.nextInt();
      	Integer[] productPrice = new int[count];
      	int temp = 0;
      	double sum = 0;
      	for(int i = 0; i < count; i++){
        	productPrice[i] = sc.nextInt();
        }
      	Arrays.sort(productPrice, Collections.reverseOrder());
      	for(int l = 1; l <= discount; l++){
        	productPrice[0] = productPrice[0] / 2;
          	for(int m = 0; m < count-1; m++){
            	if(productPrice[m] < productPrice[m+1]){
                	temp = productPrice[m];
                  	productPrice[m] = productPrice[m+1];
                  	productPrice[m+1] = temp;
                }else{
                	break;
                }
            }
        }
      	for(int n = 0; n < count; n++){
        	sum = sum + productPrice[n];
        }
      	System.out.println(BigDecimal.valueOf(sum).toPlainString());
	}
}

Compiler output:
Main.java:9: error: incompatible types: int[] cannot be converted to Integer[]
      	Integer[] productPrice = new int[count];
      	                         ^
1 error
Language: C++

#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

vector<pair<int,int>> v;

void func(int id, int n){
  int cnt = 0;
  
  while(n != 0){
    int dec = n - n/2;
    
    n /= 2;
    v.push_back(make_pair(dec,id));
  }
  return;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  rep(i,n){
    func(i,a[i]);
  }
  
  sort(v.begin(),v.end());
  
  ll ans = 0;
  rep(i,n) ans += a[i];
  
  for(auto v1:v){
    tie(dec,id) = v1;
    ans -= dec;
    m--;
    if (m == 0) break;
  }
  
  
  cout << ans;
  
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:13: error: 'id' was not declared in this scope
   39 |     tie(dec,id) = v1;
      |             ^~
a.cc:40:9: error: invalid operands of types 'll' {aka 'long long int'} and 'std::ios_base& (*)(std::ios_base&)' to binary 'operator-'
   40 |     ans -= dec;
      |     ~~~~^~~~~~
a.cc:40:9: note:   in evaluation of 'operator-=(ll {aka long long int}, class std::ios_base& (*)(class std::ios_base&))'
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}


int main(){
  int n ,m;
  cin >>n >>m;
  ll vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  ll ans=0;
  for(int i=1; i<= m;i ++){
    sort(vec.begin(), vec.end());
    vec[n-1] /= 2;
  }
  for(int i =0 ; i<n ; i++){
    ans +=vec[i];
  }
  cout << ans <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:14: error: request for member 'begin' in 'vec', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   48 |     sort(vec.begin(), vec.end());
      |              ^~~~~
a.cc:48:27: error: request for member 'end' in 'vec', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   48 |     sort(vec.begin(), vec.end());
      |                           ^~~
a.cc: In function 'int ab(int, int)':
a.cc:36:1: warning: control reaches end of non-void function [-Wreturn-type]
   36 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
typedef vector<ll> vll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n,m; cin >>n>>m;
    vi a(n); rep(i,n) cin >> a[i];

    int res = m;
    while(res > 0){
        auto itr = max_element(a.begin(), a.end());
        *itr /= 2;
        res--;
    }

    int counting = 0;
    for(int i : a){
        counting += a;
    }
    cout << counting << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'vi' was not declared in this scope
   13 |     vi a(n); rep(i,n) cin >> a[i];
      |     ^~
a.cc:13:30: error: 'a' was not declared in this scope
   13 |     vi a(n); rep(i,n) cin >> a[i];
      |                              ^
a.cc:17:32: error: 'a' was not declared in this scope
   17 |         auto itr = max_element(a.begin(), a.end());
      |                                ^
a.cc:17:20: error: 'max_element' was not declared in this scope
   17 |         auto itr = max_element(a.begin(), a.end());
      |                    ^~~~~~~~~~~
a.cc:23:17: error: 'a' was not declared in this scope
   23 |     for(int i : a){
      |                 ^
Language: C++

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

int min(int m,a,b){
  int ans;
  int end;
  int w=2000000000;
  for(int ans=m;ans>=0;ans--){
    if(((a/pow(2,ans)+b/pow(2,m-ans))<=w){
      w=(a/pow(2,ans)+b/pow(2,m-ans);end=ans;}
}
  return end;}

int main(){
  int n,m;
  cin>>n>>m;
  
  vector<int> a(n); 
  for(int i=0;i<n;i++){
    cin>>a[i];}
  
  sort(a.begin(),a.end());
  
  
  int b[n];
  
  long long int answer=0;
  int z=m;
  for (int i=0;i<n-1;i++){
    b[i]=min(z,a[i],a[i+1]);
    z-=min(z,a[i],a[i+1]);
    answer+=a[i]/pow(2,b[i]);}
 
  
  
  cout <<answer;
}
  
 

Compiler output:
a.cc:8:15: error: 'a' has not been declared
    8 | int min(int m,a,b){
      |               ^
a.cc:8:17: error: 'b' has not been declared
    8 | int min(int m,a,b){
      |                 ^
a.cc: In function 'int min(int, int, int)':
a.cc:13:10: error: 'a' was not declared in this scope
   13 |     if(((a/pow(2,ans)+b/pow(2,m-ans))<=w){
      |          ^
a.cc:13:23: error: 'b' was not declared in this scope
   13 |     if(((a/pow(2,ans)+b/pow(2,m-ans))<=w){
      |                       ^
a.cc:13:42: error: expected ')' before '{' token
   13 |     if(((a/pow(2,ans)+b/pow(2,m-ans))<=w){
      |       ~                                  ^
      |                                          )
a.cc:15:1: error: expected primary-expression before '}' token
   15 | }
      | ^
Language: C++


#include <stdlib.h>//必須
#include <stdio.h>
int compare_int(const void *a, const void *b)//事前に入れる
{
    return *(int*)b - *(int*)a;
}

int main(void){
    int n,m,i,j=0;
    long ans=0;
    int bef;
    scanf("%d %d",&n,&m);
    int yen[n+1];
    for(i=0;i<n;i++){
        scanf("%d",&yen[i]);
       /// printf("%d\n",yen[i]);
    }
    yen[n]=0;
    
    for(i=0;i<m;i++){
        if(i==0){
    qsort(yen, n, sizeof(int), compare_int);//ソート関数（配列めい、総数、固定、比較方法）
        }
        if(n != 1){
            bef=yen[0];
            j=1;
            while(bef < yen[j]){
                yen[j-1]=yen[j];
                j++;
            }
            yen[j-1]=bef;
        }
    }
    yen[0]=(int)(yen[0]/2);
    }
    
    for(i=0;i<n;i++){
    //    printf("%d\n ",yen[i]);
        ans+=(long)yen[i];
    }
    printf("%ld\n",ans);
   return 0;
 
}

Compiler output:
a.cc:38:5: error: expected unqualified-id before 'for'
   38 |     for(i=0;i<n;i++){
      |     ^~~
a.cc:38:13: error: 'i' does not name a type
   38 |     for(i=0;i<n;i++){
      |             ^
a.cc:38:17: error: 'i' does not name a type
   38 |     for(i=0;i<n;i++){
      |                 ^
a.cc:42:11: error: expected constructor, destructor, or type conversion before '(' token
   42 |     printf("%ld\n",ans);
      |           ^
a.cc:43:4: error: expected unqualified-id before 'return'
   43 |    return 0;
      |    ^~~~~~
a.cc:45:1: error: expected declaration before '}' token
   45 | }
      | ^
Language: C++

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

int main(){
  int N,M;
  cin >> N >> M;
  int A[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  
  sort(A, A+N);
  for(int j=0; j<M; j++){
    A[N-1] = A[N-1]/2;
    if(A[N-1]>A[N-2]){
      continue;
    }else{
      sort(A, A+N);
  }
  
  long long sum = 0;
  for(int k=0; k<N; k++){
    sum += A[k];
  }

  cout << sum;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

 #include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int N,M;
  cin>>N>>M;
  vector<lomg> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<M;i++){
    sort(A.begin(),A.end());
    A.at(N-1)/=2;
    cout
  }
  int count=0;
  for(int i=0;i<N;i++){
    count+=A.at(i);
  }
  cout<<count<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: 'lomg' was not declared in this scope; did you mean 'long'?
    7 |   vector<lomg> A(N);
      |          ^~~~
      |          long
a.cc:7:14: error: template argument 1 is invalid
    7 |   vector<lomg> A(N);
      |              ^
a.cc:7:14: error: template argument 2 is invalid
a.cc:9:12: error: request for member 'at' in 'A', which is of non-class type 'int'
    9 |     cin>>A.at(i);
      |            ^~
a.cc:12:12: error: request for member 'begin' in 'A', which is of non-class type 'int'
   12 |     sort(A.begin(),A.end());
      |            ^~~~~
a.cc:12:22: error: request for member 'end' in 'A', which is of non-class type 'int'
   12 |     sort(A.begin(),A.end());
      |                      ^~~
a.cc:13:7: error: request for member 'at' in 'A', which is of non-class type 'int'
   13 |     A.at(N-1)/=2;
      |       ^~
a.cc:14:9: error: expected ';' before '}' token
   14 |     cout
      |         ^
      |         ;
   15 |   }
      |   ~      
a.cc:18:14: error: request for member 'at' in 'A', which is of non-class type 'int'
   18 |     count+=A.at(i);
      |              ^~
Language: C++

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int main (){
    int N,M;
    cin >> N >>M;
    vector<int> A(N);
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    
    for (int i=0;i<M;i++){
    int maxValue = *std::max_element(A.begin(), A.end());
    vector<int>::iterator maxIT = max_element(A.begin(), A.end());
        size_t maxIndex = distance(A.begin(), maxIT);
        A[maxIndex] = maxValue/2;
    }
    long int ans = accumulate(A.begin(), A.end(), 0LL);
    cout << ans;
    //cout << maxValue<<endl;
    //cout << maxIndex;
    
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: expected '}' at end of input
   30 |     cout << ans;
      |                 ^
a.cc:15:12: note: to match this '{'
   15 | int main (){
      |            ^
Language: C++

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

void SORTAND(vector<double> &a, int n, int m, int ave) {
  for(int i = 0; i < n; i++) {
    while(a.at(i) > ave) {
      a.at(i) /= 2;
      m--;
      if(m == 0) {
        break;
      }
      if(m != 0) {
        int s = 0;
        for(int j = 0; j < n; j++) {
          s += a.at(i);
        }
        int AVE = s / n;
        while(a.at(i) > AVE) {
          a.at(i) /= 2;
          m--;
        }
        if(m == 0) {
          break;
        }
      }
    }
  }
  
int main() {
  int N, M;
  cin >> N >> M;
  vector<double> A(N);
  int64_t Sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    Sum += A.at(i);
  }
  int64_t Ave = Sum / N;
  SORTAND(A, N, M, Ave);
  }
  int64_t S = 0;
  for(int i = 0; i < N; i++) {
    S += (int)A.at(i);
  }
  cout << S << endl;
}

Compiler output:
a.cc: In function 'void SORTAND(std::vector<double>&, int, int, int)':
a.cc:29:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   29 | int main() {
      |         ^~
a.cc:29:9: note: remove parentheses to default-initialize a variable
   29 | int main() {
      |         ^~
      |         --
a.cc:29:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:29:12: error: a function-definition is not allowed here before '{' token
   29 | int main() {
      |            ^
a.cc:42:22: error: 'N' was not declared in this scope
   42 |   for(int i = 0; i < N; i++) {
      |                      ^
a.cc:43:15: error: 'A' was not declared in this scope
   43 |     S += (int)A.at(i);
      |               ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int n, m;
  cin >> n;
  cin >> m;
  std::map<int, int> map;
  for(int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    map.insert(std::make_pair(a, a));
  }
  
  for (int i = 0; i < m; i++)
  {
    int max_n = 0;
    for (int j = 0; j < m; j++)
    {
      if (a[j] > a[max_n]) max_n = j;
    }
    a[max_n] /= 2;
  }
  
  long int sum = 0;
  for (int j = 0; j < n; j++)
  {
    sum += map.at(j);
  }
  
  cout << sum;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:11: error: 'a' was not declared in this scope
   25 |       if (a[j] > a[max_n]) max_n = j;
      |           ^
a.cc:27:5: error: 'a' was not declared in this scope
   27 |     a[max_n] /= 2;
      |     ^
Language: C++

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

vector<long long int> ans(100001,0);
int main(){
	long n;
	long m;
 
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> ans[i];
	}
  	vector<long long int>::iterator miter;
	for(int i=0;i<m;i++){
		miter = max_element(ans.begin(), ans.end());
        if(miter==ans.last()) break;
		*miter /= 2;
	}
	long long a = 0;
	for(int i=0;i<n;i++){
		a += ans[i];
	}
	cout << a << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:23: error: 'class std::vector<long long int>' has no member named 'last'; did you mean 'at'?
   19 |         if(miter==ans.last()) break;
      |                       ^~~~
      |                       at
Language: C++

#include <iostream>
#include <string>
#include <cstring>

using namespace std;
typedef long long LL;

const int MAXN = 1e5 + 7;
LL A[MAXN];

bool cmp(LL x, LL y) {
    return x > y;
}

int main() {
    int n, m;
    cin >> n >> m;
    LL tot = 0;
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
        tot += A[i];
    }

    while (m) {
        sort(A + 1, A + n + 1, cmp);
        LL currentMAX = A[1];
        for (int i = 1; i <= n; i++) {
            if (A[i] >= currentMAX) {
                LL NewP = A[i] / 2;
                tot -= A[i] - NewP;
                A[i] = NewP;
                m--;
                if (m == 0) break;
                currentMAX = max(A[i], currentMAX);
            } else {
                break;
            }
        }
    }

    cout << tot << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |         sort(A + 1, A + n + 1, cmp);
      |         ^~~~
      |         short
Language: C++

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
vector<int> A;
int P[100010]={};
int main(){
    int N,M;
    cin >> N >> M;
    int e;
    rep(i,N){
        cin >> e;
        A.push_back(e);
    }
    int max=0;
    sort(A.begin(), A.end());
    rep(i,M){
        A[N-1] /= 2;
        if(A[N-1] >= A[N-2]){
            continue
        }else{
            auto itr = lower_bound(A.begin(), A.end(), A[N-1]);
        //int tmp = A[N-1];
        //int tm;
        /*for(int j=A+N-1;itr<=A+j;j--){
            A[j]=A[j-1];
        }
        A[itr-1] = tmp;
        */
            A.insert(itr, A[N-1]);  
        }
    }
    long long sum=0;
    rep(i,N){
        sum += A[i];
    }
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:21: error: expected ';' before '}' token
   24 |             continue
      |                     ^
      |                     ;
   25 |         }else{
      |         ~
Language: C++

#include <iostream>
#include <numeric>
#include <vector> 
#include <algorithm>


using namespace std;
 
int main() {
  unsigned int N, M;
  cin >> N >> M;
  
  vector<unsigned int> A(N);
  for (int i=0; i < N; i++){
    cin >> A[i];
  }
  
  unsigned int maximum_val = 0;
  for (int i=0; i<M; i++){
  	maximum_val = *std::max_element(A.begin(), A.end());
    
    for (int j=0; j<N; j++){
      if (vec[j] == maximum_val){
        vec[j] = maximum_val / 2;
        break;
      }
    }
  }
 
  cout << accumulate(A.begin(), A.end(), 0);
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:11: error: 'vec' was not declared in this scope
   23 |       if (vec[j] == maximum_val){
      |           ^~~
Language: Java

import java.util.*;

public class test {
 public static void main(String... args) {
   Scanner scan = new Scanner(System.in);
   String[] line = scan.nextLine().split(" ");
   int N = Integer.parseInt(line[0]);
   int M = Integer.parseInt(line[1]);
   
   List<Integer> A = new ArrayList();
   for(int i=0; i<N; i++) {
     A.add(scan.nextInt());
   }
   
   for(int i=0; i<M; i++) {
     Collections.sort(A, Collections.reverseOrder());
     A.set(0,A.get(0)/2);
    }

   long sum=0;
   for(int elm : A) {
     sum += elm;
   }
   System.out.println(sum);
 }
}

Compiler output:
Main.java:3: error: class test is public, should be declared in a file named test.java
public class test {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    int N,M;
    
    cin >> N >>M;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    //auto tmp;
    int x;
    auto iter_lower;
    int idx_lower;
    rep(i,M){
        x = A[N-1]>>1;
        iter_lower = lower_bound(A.begin(), A.end(), x);
        idx_lower = distance(A.begin(), iter_lower);
        A.insert(A.begin() +idx_lower,x);
        
        //cout << idx_lower << endl;
        //cout << x << endl;
        
    }
    ll sum=0;
    rep(i,N){
        sum+=A[i];
    }
    
    cout << sum << endl;
    
    return 0;
    

}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: declaration of 'auto iter_lower' has no initializer
   35 |     auto iter_lower;
      |     ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main () {
	int N,M;
	long long sum = 0;
	vector <int> A;
	cin >> N >> M;
	for (int i=0; i<N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back (tmp);
		sum += (long long) tmp;
	}
	for (int i=0; i<M; i++) {
		vector<int>::iterator iter = max_element (A.begin (), A.end ());
		size_t index = std::distance (A.begin (), iter);
		sum -= A[index]/2+A[index]%2;
		A[index] = tmp;
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:28: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   21 |                 A[index] = tmp;
      |                            ^~~
      |                            tm
Language: C++

#include<iostream>
#include<vector>
#include<sort>
using namespace std;

int main(){
  int n,m,b,sum=0;
  cin>>n>>m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
  sort(a.begin(),a.end());
    b=a.back();
    b/=2;
    a.pop_back();
    a.push_back(b);
  }
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout<<sum<<endl;
}


Compiler output:
a.cc:3:9: fatal error: sort: No such file or directory
    3 | #include<sort>
      |         ^~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <numeric>

using namespace std;
 
int main() {
  unsigned int N, M;
  cin >> N >> M;
  
  vector<unsigned int> A(N);
  for (int i=0; i < N; i++){
    cin >> A[i];
  }
  
  unsigned int maximum_val = 0;
  for (int i=0; i<M; i++){
  	maximum_val = *std::max_element(A.begin(), A.end());
    
    for (int j=0; j<N; j++){
      if (vec[j] == maximum_val){
        vec[j] = maximum_val / 2;
        break;
      }
    }
  }
 
  cout << accumulate(A.begin(), A.end(), 0);
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<unsigned int> A(N);
      |   ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <numeric>
  +++ |+#include <vector>
    3 | 
a.cc:10:10: error: expected primary-expression before 'unsigned'
   10 |   vector<unsigned int> A(N);
      |          ^~~~~~~~
a.cc:12:12: error: 'A' was not declared in this scope
   12 |     cin >> A[i];
      |            ^
a.cc:17:29: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   17 |         maximum_val = *std::max_element(A.begin(), A.end());
      |                             ^~~~~~~~~~~
      |                             tuple_element
a.cc:17:41: error: 'A' was not declared in this scope
   17 |         maximum_val = *std::max_element(A.begin(), A.end());
      |                                         ^
a.cc:20:11: error: 'vec' was not declared in this scope
   20 |       if (vec[j] == maximum_val){
      |           ^~~
a.cc:27:22: error: 'A' was not declared in this scope
   27 |   cout << accumulate(A.begin(), A.end(), 0);
      |                      ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;

  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < M; i++){
    a[0] /= 2;
    if (a[0] < a[1]) swap(a[0], a[1]);
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++){
    ans += a[i];
  }

  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc:22:3: error: expected unqualified-id before 'for'
   22 |   for (int i = 0; i < N; i++){
      |   ^~~
a.cc:22:19: error: 'i' does not name a type
   22 |   for (int i = 0; i < N; i++){
      |                   ^
a.cc:22:26: error: 'i' does not name a type
   22 |   for (int i = 0; i < N; i++){
      |                          ^
a.cc:26:3: error: 'cout' does not name a type
   26 |   cout << ans << endl;
      |   ^~~~
a.cc:28:3: error: expected unqualified-id before 'return'
   28 |   return 0;
      |   ^~~~~~
a.cc:29:1: error: expected declaration before '}' token
   29 | }
      | ^
Language: C++

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


int main()
{
	long long N, M;

	cin >> N >> M;

	vector<long> A;
	static double log2[100010];

	for (long i = 0; i < N; i++) {
		long val;
		cin >> val;
		A.push_back(val);
	}

	std::sort(A.begin(), A.end(), std::greater<long>());

	for (long i = 0; i < N; i++) {
		log2[i] = std::log2((double)A[i]);
	}

	long count[100010];
	memset(count, 0, sizeof(count));

	//M���̕��z
	long search_max_index = 1;
	for (long iM = 0; iM < M; iM++) {
		long arg_max = -1;
		double max = -10000000.0;
		for (long i = 0; i <= search_max_index; i++) {
			if (max < log2[i]) {
				arg_max = i;
				max = log2[i];
			}
		}

		if (arg_max >= search_max_index && arg_max < N - 1) {
			search_max_index++;
		}

		log2[arg_max] -= 1.0;
		count[arg_max] += 1;
	}

	long long result = 0;

	for (long i = 0; i < N; i++) {
		result += (long long)A[i] / std::pow(2.0, (double)count[i]);
	}

	cout << result << endl;
}


//TLE
//int main()
//{
//	long long N, M;
//
//	cin >> N >> M;
//
//	vector<double> A;
//
//	for (long i = 0; i < N; i++) {
//		long val;
//		cin >> val;
//		A.push_back((double)val);
//	}
//
//	for (long i = 0; i < M; i++) {
//		std::sort(A.begin(), A.end(), std::greater<double>());
//		A[0] = A[0] / 2.0;
//	}
//
//	long long result = 0;
//
//	for (long i = 0; i < N; i++) {
//		result += (long long)A[i];
//	}
//
//	cout << result << endl;
//}

//int main()
//{
//	long long N, K, Q;
//
//	cin >> N >> K >> Q;
//
//	static long w[100010];
//	memset(w, 0, sizeof(w));
//
//	//! ���͂��Ȃ��琳�𐔂̐����グ
//	for (long i = 0; i < Q; i++) {
//		long win;
//
//		cin >> win;
//
//		w[win - 1] += 1;
//	}
//
//	for (long i = 0; i < N; i++) {
//		if (Q - w[i] >= K) {
//			cout << "No" << endl;
//		}
//		else {
//			cout << "Yes" << endl;
//		}
//	}
//}


//int main()
//{
//	string S;
//
//	cin >> S;
//
//	bool bad = false;
//	for (int i = 0; i < S.size(); i++) {
//		if ((i+1) % 2 == 0) {
//			//����
//			if (S[i] == 'R') {
//				bad = true;
//				break;
//			}
//		}
//		else {
//			//�
//			if (S[i] == 'L') {
//				bad = true;
//				break;
//			}
//		}
//	}
//
//	if (bad == true) {
//		cout << "No" << endl;
//	}
//	else {
//		cout << "Yes" << endl;
//	}
//}

//int main()
//{
//	string S;
//
//	cin >> S;
//
//	if (S == "Sunny")
//	{
//		cout << "Cloudy" << endl;
//	}
//	else if(S == "Cloudy")
//	{
//		cout << "Rainy" << endl;
//	}
//	else {
//		cout << "Sunny" << endl;
//	}
//}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:32: error: 'log2' is not a member of 'std'
   27 |                 log2[i] = std::log2((double)A[i]);
      |                                ^~~~
a.cc:56:50: error: 'pow' is not a member of 'std'
   56 |                 result += (long long)A[i] / std::pow(2.0, (double)count[i]);
      |                                                  ^~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;

int main(){
  int n,m,b,sum=0;
  cin>>n>>m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
  sort(a.begin(),a.end());
    b=a.back();
    b/=2;
    a.pop_back();
    a.push_back(b);
  }
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |   sort(a.begin(),a.end());
      |   ^~~~
      |   short
Language: C

n,m=map(int,input().split())
A=list(map(int,input().split()))

while m>0:
  A.sort(reverse=True)
  A[0]=A[0]//2
  m-=1
print(sum(A))

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | n,m=map(int,input().split())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:1:3: error: type defaults to 'int' in declaration of 'm' [-Wimplicit-int]
    1 | n,m=map(int,input().split())
      |   ^
main.c:1:5: error: implicit declaration of function 'map' [-Wimplicit-function-declaration]
    1 | n,m=map(int,input().split())
      |     ^~~
main.c:1:9: error: expected expression before 'int'
    1 | n,m=map(int,input().split())
      |         ^~~
main.c:2:1: error: expected ',' or ';' before 'A'
    2 | A=list(map(int,input().split()))
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using in = int64_t;

int main(){
in n,m;
  cin >>n>>m;
priority_queue<double> a;
  rep(i,n){ 
    double z;
    cin>>z;
    a.push(z);
  }//n
  //sort(a.begin(),a.end());
  
  rep(i,m){
    double x = a.top();
    a.pop();
    a.push(x/2);
    /*if(a.at(n-1)<a.at(n-3)){
      sort(a.begin(),a.end());
    }
    else if(a.at(n-1)<a.at(n-2)){
    double x,y;
      x= a.at(n-1);
      y = a.at(n-2);
      a.at(n-1) = y;
      a.at(n-2) = x;
    }*/
  }//mSORT
  
  in ans =0;
  rep(i,n){
  ans += (in)a.at(i);
  }
  
  cout <<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:16: error: 'class std::priority_queue<double>' has no member named 'at'
   36 |   ans += (in)a.at(i);
      |                ^~
Language: C++

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

int main() {
  int N,M;
  cin >> N >> M;
  
  if(N == 1){
    long long A;
    cin >> A;
    for(int i=0;i<M;i++){
      A /= 2;;
    }
    cout << A << endl;
  }else{
  
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  std::sort(A.begin(), A.end(), std::greater<long long>() );
  for(int i=0;i<M;i++){
    A.at(0) >>1;
    if(A.at(0) < A.at(1)){
      for(int j=1;j<N;j++){
        long long b = A.at(j-1);
        A.at(j-1) = A.at(j);
        A.at(j) = b;
        if(j < N - 1 && A.at(j) > A.at(j+1)){
          break;
        }
      }
    }
  }
  long long price = 0;
  for(int i=0;i<N;i++){
    price += A.at(i);
  }
  cout << price << endl;
  
  }
}


Compiler output:
a.cc:2:10: fatal error: math: No such file or directory
    2 | #include <math>
      |          ^~~~~~
compilation terminated.