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

#include <iostream>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main()
{
  int K, T;
  cin >> K >> T;
  int ma = -1;
  REP(i, N) {
    int a;
    cin >> a;
    ma = max(a, ma);
  }
  cout << ma(ma - 1 - (K - ma), 0) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'N' was not declared in this scope
    9 |   REP(i, N) {
      |          ^
a.cc:2:38: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(int i = 0; i < n; i++)
      |                                      ^
a.cc:14:13: error: 'ma' cannot be used as a function
   14 |   cout << ma(ma - 1 - (K - ma), 0) << endl;
      |           ~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
signed main(){
    int K,T;
    cin>>K>>T;
    vint C(T);
    rep(i,T)cin>>C[i];
 
    rep(i,T){
        if(C[i]*2-1<=K)continue;
        int t=C[i]-(K+1)/2;
        cout<<t*2-(K%2==0)<<endl;
        return 0;
    }
 
    cout<<0<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'vint' was not declared in this scope; did you mean 'uint'?
    6 |     vint C(T);
      |     ^~~~
      |     uint
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     rep(i,T)cin>>C[i];
      |         ^
a.cc:7:5: error: 'rep' was not declared in this scope
    7 |     rep(i,T)cin>>C[i];
      |     ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <stdio.h>
using namespace std;
using ll =long long;

int main (void) {
  int K,T;
  cin >> K >>T ;
  int a[T];
  int max=0;
  int sum=0;
  for (int i=0;i<T;i++){
    cin >> a[i];
    if(a[i]>max){
      max=a[i];
    }
  }
  int ans=0;
  ans=max(ans,K-max-1);
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:10: error: 'max' cannot be used as a function
   26 |   ans=max(ans,K-max-1);
      |       ~~~^~~~~~~~~~~~~
Language: C++

 
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__);


int main(){
    dcl(k,t);
    vi c(t);
    rep(i,t)cin>>c[i];
    sort(rall(c));
    cout<<max(c[0]*2-k-1,0)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: error: no matching function for call to 'max(ll, int)'
   34 |     cout<<max(c[0]*2-k-1,0)<<endl;
      |           ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:34:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   34 |     cout<<max(c[0]*2-k-1,0)<<endl;
      |           ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:34:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |     cout<<max(c[0]*2-k-1,0)<<endl;
      |           ~~~^~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> m >> n;
    vi v(n);
    REP(i,n) {
        cin >> v[i];
    }
    REP(i,n){
        ll a = 2 * v[i] - 1 - m;
        vv.push_back(a);
    }
    vv.push_back(sum);
    sort(ALL(vv));
    cout << vv.back() << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:9: error: 'vv' was not declared in this scope; did you mean 'v'?
   37 |         vv.push_back(a);
      |         ^~
      |         v
a.cc:39:5: error: 'vv' was not declared in this scope; did you mean 'v'?
   39 |     vv.push_back(sum);
      |     ^~
      |     v
Language: C++

use std::io;

fn next_vec() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn main(){
    let v = next_vec();
    let k = v[0];
    let t = v[1] as usize;
    let mut a = next_vec();

    a.sort();

    let mut left: usize = 0;
    let mut right: usize = t - 1;
    let mut cnt = 0;
    while left < right {
        a[left] -= 1;
        left = if a[left] == 0 {left + 1} else {left};
        a[right] -= 1;
        right = if a[right] == 0 {right - 1} else {right};
        cnt += 2;
    }
    cnt += if a[left] > 0 || a[right] > 0 {1} else {0};
    println!("{:?}", k - cnt);
}


Compiler output:
a.cc:1:1: error: 'use' does not name a type
    1 | use std::io;
      | ^~~
a.cc:3:1: error: 'fn' does not name a type
    3 | fn next_vec() -> Vec<i64> {
      | ^~
a.cc:9:1: error: 'fn' does not name a type
    9 | fn main(){
      | ^~
Language: C++

#include <algorithm>
#include <iostream>
#define lim 100
using namespace std;

int main (void){
    int K, T;
    int a[lim]={};
    int ans;
    
    cin >> K >> T;
    for(int i=0; i<T; i++){
        cin >> a[i];
    }

    sort(a, a + 100);
    /*
     for(int i=99; i>100-T-5; i--){
        cout << a[i];
    }
     */
    
    ans = a[lim-1]-1;
    for(int i = lim-2; i=>0; i--){
        if(ans != 0)
           ans -= a[i];
    }
    
    if(ans < 0){
        ans = 0;
    }
    printf("%d\n",ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:26: error: expected primary-expression before '>' token
   24 |     for(int i = lim-2; i=>0; i--){
      |                          ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
	int k,t,ans=0;
	cin >> k >> t;
	vector<int> a(t);
	for(int i=0;i<t;i++){
		cin >> a[i];
	}
	int prev = -1;
	while(1){
		int x = 0;
		for(int i=0;i<t;i++){
			if(i == prev) continue;
			if(a[x] < a[i]){
				x = i;
			}
		}
		if(a[x] <= 0) x = prev;
		if(x == prev){
			ans++;
		}
		a[x]--;
		prev = x
	}
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: expected ';' before '}' token
   26 |                 prev = x
      |                         ^
      |                         ;
   27 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
	int k,t;
	cin >> k >> t;
	vector<int> a(t);
	for(int i=0;i<t;i++){
		cin >> a[i];
	}
	int prev = -1;
	while(1){
		int x = 0;
		for(int i=0;i<t;i++){
			if(i == prev) continue;
			if(a[x] < a[i]){
				x = i;
			}
		}
		if(a[x] <= 0) x = prev;
		if(x == prev){
			ans++;
		}
		a[x]--;
		prev = x
	}
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |                         ans++;
      |                         ^~~
      |                         abs
a.cc:26:25: error: expected ';' before '}' token
   26 |                 prev = x
      |                         ^
      |                         ;
   27 |         }
      |         ~                
a.cc:28:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int k,t;
cin>>k>>t;
vector<int>vec;
for(int i=0;i<t;i++){
int x;cin>>x; vec.push_back(x);
}
int mini=1000000;
do{
int x=0;
for(int i=0;i+1<vec.size();i++){
if(vec[i]==vec[i+1])x++;
}
mini=min(mini,x);
}while(next_permutation(vec.begin(),vec.end());
cout<<mini<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:47: error: expected ')' before ';' token
   19 | }while(next_permutation(vec.begin(),vec.end());
      |       ~                                       ^
      |                                               )
Language: C++

#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main()
{
    int k,t;
    cin >> k >> t;
    int a[t];
    int max = 0;
    REP(i,t){cin >> a[i];if(a[i]>max){max = a[i];}}

    cout << max(0,max - (k-max) -1 ) << endl;

    return 0 ;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:16: error: 'max' cannot be used as a function
   31 |     cout << max(0,max - (k-max) -1 ) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int k,t,ans=INT_MAX,dp[10010][110];

void f(int type, int n, int a[]){
    if(n==k){
        ans=min(ans,0);
        return;
    }
    bool flag=false;
    for(int i=0;i<t;i++){
        if(type!=i&&a[i]>0){
            a[i]--;
            f(i,n+1,a);
            a[i]++;
            flag= true;
        }
    }
    if(!flag) ans=min(ans,a[type]);
}

int main(){
    //int t;
    //t=1;
    //cin>>t;

    //while(t--){
        cin>>k>>t;
        int a[110];
        for(int i=0;i<t;i++) cin>>a[i];
        memset(dp,-1,sizeof dp);
        for(int i=0;i<t;i++){
            a[i]--;
            f(i,1,a);
            a[i]++;
        }
        cout<<ans<<endl;
    //}

    return 0;
}

Compiler output:
a.cc:7:13: error: 'INT_MAX' was not declared in this scope
    7 | int k,t,ans=INT_MAX,dp[10010][110];
      |             ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <cstring>
  +++ |+#include <climits>
    5 | using namespace std;
a.cc: In function 'int main()':
a.cc:35:16: error: 'dp' was not declared in this scope
   35 |         memset(dp,-1,sizeof dp);
      |                ^~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int K,T;
int cake[101];
int main(){
  cin>>K>>T;

  for(int i = 0; i < T; i++){
    cin>>cake[i];
  }
  sort(cake,cake+T);
 

  if(T == 1){
    cout<<cake[0]-1<<endl;
   
  }

  else if(cake[T-1] - cake[T-2] > 1){
    int sum = 0;
    for(int i = 0; i < T-1; i++){
      sum += cake[i];
    }
    if(cake[T-1]-sum-1 > 0)cout<<cake[T-1]-sum-1<<endl;
    else cout<<'0'<<endl;
  }
  else cout<<'0'<<endl;
  

Compiler output:
a.cc: In function 'int main()':
a.cc:28:24: error: expected '}' at end of input
   28 |   else cout<<'0'<<endl;
      |                        ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C

#include <stdio.h>

int find_max(int n, b[]){
    int w,max=0,max_idx=0;
    for(w=0;w<n;w++){
        if(b[w]>max){
            max=b[w];
            max_idx=w;
        }
    }
    
    return max_idx;
    
}

int main(void){
    // Here your code !
    int K,T,i, idx, cnt = 0;
    scanf("%d%d",&K,&T);
    
    int a[T];
    for(i=0;i<T;i++){
        scanf("%d",&a[i]);
    }
    
    while(K>0){
        // aの中の最大の要素を見つける
        idx = find_max(T, a);
        
        // 最大要素をデクリメント
        a[idx]--;
        
        // 昨日食べたものと同じだったらカウントをインクリメント
        if( pre_idx == idx){
            cnt++;
        }
        
        pre_idx = idx;
        K--;
    }
    
    printf("%d",cnt);
    
    return 0;
}


Compiler output:
main.c:3:21: error: unknown type name 'b'
    3 | int find_max(int n, b[]){
      |                     ^
main.c: In function 'main':
main.c:28:15: error: implicit declaration of function 'find_max' [-Wimplicit-function-declaration]
   28 |         idx = find_max(T, a);
      |               ^~~~~~~~
main.c:34:13: error: 'pre_idx' undeclared (first use in this function)
   34 |         if( pre_idx == idx){
      |             ^~~~~~~
main.c:34:13: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main(){
    int K, T;
    cin >> K >> T;
    vector<int> v(T);
    for(auto i = 0; i < T; i++)
        cin >> v[i];
    
    sort(v.begin(), v.end());
    
    int p(0), q(T-1);
    while(true){
        // a b a b c a c
        // a b a c a a
        if(p >= q)
            break;

        if(v[p] > v[q]){
            v[p] -= v[q];
            q--;
        }
        else if(v[p] < v[q]){
            v[q] -= v[p];
            p++;
        }
        else{
            p++;
            q--;
        }
    }
    cout << v[p]  - 1 << endl;

    reutrn 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'reutrn' was not declared in this scope
   37 |     reutrn 0;
      |     ^~~~~~
Language: C++

int main() {
 
  int K, T; cin >> K >> T;
  vector<pair<int, int>> vs;
  rep(i, T) {
    int x; cin >> x;
    vs.push_back({x, i});
  }

  int last = -1;
  int N = vs.size();
  while(vs.size() > 1) { // T-1要素すべて消すまで回す。O(K)
    sort(all(vs));
 
    for(int i=N-1; i>=N-2; i--) {
      if(last != vs[i].second) {
        if(vs[i].first > 0) {
          last = vs[i].second;
          vs[i].first --; // 1個ずつ食べる
          if(vs[i].first == 0) {
            vs.erase(vs.begin() + i); // T-1回しか実行されない
            N = vs.size();
          }
          break;
        }
      }
    }
  }
 
  cout << vs[0].first - 1 << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:13: error: 'cin' was not declared in this scope
    3 |   int K, T; cin >> K >> T;
      |             ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<pair<int, int>> vs;
      |   ^~~~~~
a.cc:4:10: error: 'pair' was not declared in this scope
    4 |   vector<pair<int, int>> vs;
      |          ^~~~
a.cc:4:15: error: expected primary-expression before 'int'
    4 |   vector<pair<int, int>> vs;
      |               ^~~
a.cc:5:7: error: 'i' was not declared in this scope
    5 |   rep(i, T) {
      |       ^
a.cc:5:3: error: 'rep' was not declared in this scope
    5 |   rep(i, T) {
      |   ^~~
a.cc:11:11: error: 'vs' was not declared in this scope
   11 |   int N = vs.size();
      |           ^~
a.cc:13:10: error: 'all' was not declared in this scope
   13 |     sort(all(vs));
      |          ^~~
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |     sort(all(vs));
      |     ^~~~
      |     short
a.cc:30:3: error: 'cout' was not declared in this scope
   30 |   cout << vs[0].first - 1 << endl;
      |   ^~~~
a.cc:30:30: error: 'endl' was not declared in this scope
   30 |   cout << vs[0].first - 1 << endl;
      |                              ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int K,T;
  priority_queue<int,vector<int>,greater<int>> queue;
  int a[100];#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int K,T;
  priority_queue<int,vector<int>,greater<int>> queue;
  int a[100];
  int min=100000;
  int max=-1;
  int count = 0;
  cin >> K >> T;
  for(int i=0;i<T;i++){
    cin >> a[i];
    if(a[i]>max){
      max=a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  if(T==1){
    cout << K-1 << endl;
    return 0;
  }
  for(int i=0;i<T;i++){
    a[i]-=min;
    if(a[i]!=0){
      queue.push(a[i]);
    }
  }
  count=min*T+1;
  int count2=0;
  for(;queue.size()!=0;){
    if(count-min*2>=queue.top()&&count2<=queue.top()){
      count+=queue.top()*2-count2;
      if(count2>0){
        count2=0;
      }
      queue.pop();
    }else{
      count++;
      if(count2==0){
       count2=queue.top()-(count-min*2);
      }else{
        count2-queue.top();
      }
      queue.pop();
    }
  }
  cout << count2 << endl;
  return 0;
}
  int min=100000;
  int max=-1;
  int count = 0;
  cin >> K >> T;
  for(int i=0;i<T;i++){
    cin >> a[i];
    if(a[i]>max){
      max=a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  if(T==1){
    cout << K-1 << endl;
    return 0;
  }
  for(int i=0;i<T;i++){
    a[i]-=min;
    if(a[i]!=0){
      queue.push(a[i]);
    }
  }
  count=min*T+1;
  int count2=0;
  for(;queue.size()!=0;){
    if(count-min*2>=queue.top()&&count2<=queue.top()){
      count+=queue.top()*2;
      if(count2>0){
        count2=0;
      }
      queue.pop();
    }else{
      if(count2==0){
       count2=queue.top()-(count-min*2);
      }else{
        count2-queue.top();
      }
      queue.pop();
    }
  }
  cout << count2 << endl;
  return 0;
}

Compiler output:
a.cc:10:14: error: stray '#' in program
   10 |   int a[100];#include <iostream>
      |              ^
a.cc: In function 'int main()':
a.cc:10:15: error: 'include' was not declared in this scope
   10 |   int a[100];#include <iostream>
      |               ^~~~~~~
a.cc:10:32: error: expected primary-expression before '>' token
   10 |   int a[100];#include <iostream>
      |                                ^
a.cc:14:1: error: expected primary-expression before 'using'
   14 | using namespace std;
      | ^~~~~
a.cc:16:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   16 | int main(){
      |         ^~
a.cc:16:9: note: remove parentheses to default-initialize a variable
   16 | int main(){
      |         ^~
      |         --
a.cc:16:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:16:11: error: a function-definition is not allowed here before '{' token
   16 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int K,T;
  priority_queue<int,vector<int>,greater<int>> queue;
  int a[100];
  int min=100000;
  int max=-1;
  int count = 0;
  cin >> K >> T;
  for(int i=0;i<T;i++){
    cin >> a[i];
    if(a[i]>max){
      max=a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  if(T==1){
    cout << K-1 << endl;
    return 0;
  }
  for(int i=0;i<T;i++){
    a[i]-=min;
    if(a[i]!=0){
      queue.push(a[i]);
    }
  }
  count=min*T+1;
  int count2=0;
  for(;queue.size()!=0;){
    if(count-min*2>=queue.top()&&count2<=queue.top()){
      count+=queue.top()*2-count2;
      if(count2>0){
        count2=0;
      }
      queue.pop();
    }else{
      count+=queue,top()*2;
      if(count2==0){
       count2=queue.top()-(count-min*2);
      }else{
        count2-queue.top();
      }
      queue.pop();
    }
  }
  cout << count2 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:12: error: no match for 'operator+=' (operand types are 'int' and 'std::priority_queue<int, std::vector<int>, std::greater<int> >')
   44 |       count+=queue,top()*2;
      |       ~~~~~^~~~~~~
a.cc:44:20: error: 'top' was not declared in this scope
   44 |       count+=queue,top()*2;
      |                    ^~~
Language: C++

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

int k,t;
int a[111];
int b[111];

int solve() {
    for (int i=0; i<t; i++) {
        b[i] = a[i];
    }
    if(t == 1) return b[0];
    
    while (true) {
        sort(b, b+t);
        reverse(b, b+t);
        if(b[1] == 0) return b[0];
        b[0] -= b[1];
        b[1] = 0;
    }
    return 0;
}

int main() {
    
    while (cin >> k >> t) {
        int mm = -1;
        for (int i=0; i<t; i++) {
            cin >> a[i];
            mm = max(mm, a[i]);
        }
        
        cout << solve()-1 << endl;
        
    }
    
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:17:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |         sort(b, b+t);
      |         ^~~~
      |         short
a.cc:18:9: error: 'reverse' was not declared in this scope
   18 |         reverse(b, b+t);
      |         ^~~~~~~
Language: C++

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

int main(){
	int k,t;
	cin >> k >> t;
	int a[105] ={},b[10005]={};;

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

	if(t != 1){

	int c = 0,nold = -1;
	
	while(c < k){
	//	for(int i =0; i < t;i++)cout << a[i];
	//	cout <<endl;

		int n = 0;
		for(int i =0; i < t;i++){
         if(a[i] != 0){
         	n = i;
         	break;
         }
		}
		if(c%2 == 0){
			for(int i =0; i < t;i++){
				if(a[i] != 0 && a[i] >= a[n] && (nold  != i))n = i;
			}
		}else{
		 	for(int i =0; i < t;i++){
				if(a[i] != 0 && a[i] <= a[n] && (nold  != i7 ))n = i;
			}
		}
	//	cout << n<<endl;
		
		b[c] = n;
		a[n]--;
        nold = n;
		c++;
	}
//	for(int i =0; i < k;i++)cout << b[i] ;
//	cout <<endl;
	
	
	int cnt = 0;
	for(int i =1; i < k;i++)if(b[i-1] == b[i])cnt++;
     cout << cnt <<endl;
	
	}else cout << k-1 <<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:75: error: 'i7' was not declared in this scope; did you mean 'i'?
   37 |                                 if(a[i] != 0 && a[i] <= a[n] && (nold  != i7 ))n = i;
      |                                                                           ^~
      |                                                                           i
Language: C

#include <stdio.h>
int main(void){
   
    int K=6,T=3,i,max=0,maxi=0,k,count=0;
    
    scanf("%d %d",&K,&T);
    
    int a[T];
    int a[3]={1,4,1};
    
    i=0;
     while(i<T){
     scanf("%d",&a[i]);
     i++;
     }
    
    while(count!=K){
        k=0;
    for(k=0;k<T;k++){
        if(k==a[maxi]){
            k++;
            break; 
        }
        if(max<=a[i]){
            max=a[i];
            maxi=i;
        }
        
    }
    printf("%d ",a[i]);
    a[i]=a[i]-1;
    count++;
    
    }
    
    
    
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:9:9: error: redeclaration of 'a' with no linkage
    9 |     int a[3]={1,4,1};
      |         ^
main.c:8:9: note: previous declaration of 'a' with type 'int[T]'
    8 |     int a[T];
      |         ^
Language: C

#include <stdio.h>
#include<string.h>


int main(void) {
	int t,k;
	scanf("%d %d", &k,&t);
	int a[t + 5];
	for( int i= 0; i < t; i++){
		scanf("%d", &a[i]);
	}

	
	int maxIndex = 0;
	int minIndex = 0;
	int max = 0;
	int min = 0;
	
	for(int i = 0; i< t; i++){
		if(a[i] > max){
			maxIndex = i;
			max = a[i];
		}
		else if(a[i] =< min){
			minIndex = i;
			min = a[i];
		}
		
	}
	
	for(int i =0; i < k; i++){
		if(maxIndex == minIndex){
			break;
		}
		a[maxIndex]--;
		a[minIndex]--;
		if(a[minIndex] ==0){
			minIndex = maxIndex;
		}
		for(int i = 0; i< t; i++){
			if(a[i] > a[maxIndex] && a[i] > 0){
				maxIndex = i;
				max = a[i];
			}
			else if(a[i] < a[minIndex] && a[i] > 0){
				minIndex = i;
				min = a[i];
			}
		
		}

		
	}
	
		printf("%d\n", a[maxIndex] -1);
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:24:31: error: expected expression before '<' token
   24 |                 else if(a[i] =< min){
      |                               ^
Language: C++

use std::io::prelude::*;
use std::io;
 
fn read_to_string() -> String {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_to_string(&mut buf);
    buf
}
 
fn solve(p: Vec<u64>, q: Vec<u64>) -> u64 {
    let w = p.len();
    let h = q.len();
    let mut pq: Vec<_> = p.iter()
        .map(|c| (*c, 'p'))
        .chain(q.iter()
            .map(|c| (*c, 'q')))
        .collect();
    pq.sort();
    let mut a = w as u64 + 1;
    let mut b = h as u64 + 1;
    pq.iter()
        .map({
            |e| match *e {
                (c, 'p') => {
                    a -= 1;
                    b * c
                }
                (c, 'q') => {
                    b -= 1;
                    a * c
                }
                _ => 0
            }
        })
        .fold(0, std::ops::Add::add)
}
 
fn main() {
    let input = read_to_string();
    let mut words = input.split_whitespace();
    let w: usize = words.next().unwrap().parse().unwrap();
    let h: usize = words.next().unwrap().parse().unwrap();
    let p: Vec<u64> = words.by_ref().take(w).map(|i| i.parse().unwrap()).collect();
    let q: Vec<u64> = words.by_ref().take(h).map(|i| i.parse().unwrap()).collect();
    println!("{}", solve(p, q));
}

Compiler output:
a.cc:1:1: error: 'use' does not name a type
    1 | use std::io::prelude::*;
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::io;
      | ^~~
a.cc:4:1: error: 'fn' does not name a type
    4 | fn read_to_string() -> String {
      | ^~
a.cc:11:1: error: 'fn' does not name a type
   11 | fn solve(p: Vec<u64>, q: Vec<u64>) -> u64 {
      | ^~
a.cc:39:1: error: 'fn' does not name a type
   39 | fn main() {
      | ^~
Language: C++

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

int main(int argc, const char * argv[]) {
    int K,T;
    cin >> K >> T;
    vector<int> a(T);
    for(int i=0;i<T;i++){
        cin >> a[i];
    }
    int tempIndex = 0;
    int count =0;
    sort(a.rbegin(),a.rend());
    a[0]--;
    
    for(int i=1;i<K;i++){
        
        int max = 0;
        int yesterIndex = tempIndex;
        for(int j=0;j<T;j++){
            if(max < a[j] && j!=tempIndex){
                max = a[j];
                tempIndex = j;
            }
        }
        a[tempIndex]--;
        if(tempIndex == yesterIndex) count++;
    }
    cout << count;
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |     sort(a.rbegin(),a.rend());
      |     ^~~~
      |     short
Language: C++

#include<iostream>
#include<vector>
#include<math.h>
#include <stdlib.h>
using namespace std;

int main() {
  int a, c, ans = 0;
  double b;
  cin >> a >> b;
  for(int i = 0; i < b; i++) {
    cin >> c;
    if(a / 2 < c) {
      if((c - a / 2 <= 1) && (a % 2 == 1)) {
        ans += (c - a / 2) * 2 - 1;
    }
  }


  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:2: error: expected '}' at end of input
   21 | }
      |  ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: Java

import java.util.Arrays;
import java.util.Scanner;


public class KCakes {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k, t;
		int[] numberOfEach;
		k = sc.nextInt();
		t = sc.nextInt();
		numberOfEach = new int [t];
		for (int i=0; i<t ;++i) {
			numberOfEach[i] = sc.nextInt();
		}
		Arrays.sort(numberOfEach);
			int type = t-2;
			int max = t-1;
			eatThroughDay(max, type, numberOfEach);
			System.out.println(numberOfEach[t-1]);
	}
	
	private static int eatUp(int type, int[] numberOfEach, int max) {
		if (type < 0) {
			return 1;
		}
		if (numberOfEach[max] == 0){
			return 0;
		}
		if (numberOfEach[type] == 0) {
			return 1;
		}
		--numberOfEach[max];
		--numberOfEach[type];
		return -1;
	}
	
	private static void eatThroughDay(int max, int type, int[] numberOfEach) {
		int result = -1;
		while ((result = eatUp(type, numberOfEach, max) )== -1) {
			--type;
			if (type < 0) {
				++type;
			}
			if (type == max) {
				return;
			}
		}
		if (result==0) {
			--max;
			if (max < 0) {
				return;
			}
			eatThroughDay(max, type, numberOfEach);
		}
		if (result==1) {
			--type;
			boolean isAllZero = true;
			if (type < 0) {
				++type;
				for (int i=type; i<numberOfEach.length-1; ++i){
					if (i < 0) {
						--numberOfEach[max];
						return;
					}
					if (numberOfEach[i] != 0) {
						isAllZero = false;
						type = i;
						break;
					}
				}
				if (isAllZero) {
					--numberOfEach[max];
					return;
				}
			}
			if (type == max) {
				return;
			}
			eatThroughDay(max, type, numberOfEach);
		}
	}

}


Compiler output:
Main.java:5: error: class KCakes is public, should be declared in a file named KCakes.java
public class KCakes {
       ^
1 error
Language: C++

#include<iostream>
#include<vector>
#include<math.h>
#include <stdlib.h>
using namespace std;

int main() {
  int a, c, ans = 0;
  double b;
  cin >> a >> b;
  if(b != 1) {
    for(int i = 0; i < b; i++) {
      cin >> c;
      if(a / 2 + 1 < c) {zzzz
        ans += (c - a / 2) * 2 - 1;
      }
    }
  }else {
    ans = a;
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:26: error: 'zzzz' was not declared in this scope
   14 |       if(a / 2 + 1 < c) {zzzz
      |                          ^~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
  return *(int *)b-*(int *)a;
}
int main(void){
  int k,t,a[100],i,j,n,c=0,f[10000];
  scanf("%d %d",&k,&t);
  n=k;
  for(i=0;i<t;i++)
    scanf("%d",&a[i]);
  qsort(a,t,sizeof(int),cmp);
  while(n){
    for(i=0;i<t;i++){
      for(j=0;f[j]!=0;j++
	;
      for(;j<k&&a[i];j+=2){
	f[j]=i+1;
	a[i]--;
	n--;
      }
    }
  }
  for(i=1;i<k;i++){
    if(f[i-1]==f[i]){
      if(i>1&&f[i-1]!=f[i-2]){
	int tmp=f[i-1];
	f[i-1]=f[i-2];
	f[i-2]=tmp;
      }
      else if(i<t-1&&f[i]!=f[i+1]){
	int tmp=f[i];
	f[i]=f[i+1];
	f[i+1]=tmp;
      }
    }
  }
  for(i=1;i<k;i++)
    if(f[i-1]==f[i])
      c++;
  printf("%d\n",c);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:15:26: error: expected ')' before ';' token
   15 |       for(j=0;f[j]!=0;j++
      |          ~               ^
      |                          )
   16 |         ;
      |         ~                 
main.c:22:5: error: expected expression before '}' token
   22 |     }
      |     ^
Language: C++

#include <iostream>
#include<string>
#include<vector>

using namespace std;

int main() {

	int K, T;
	cin >> K >> T;
	if (K == 1) {
		cout << 0 << endl;
		return;
	}
	if (T == 1) {
		cout << K - 1 << endl;
		return;
	}
	vector<int>a(T);

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

	int fIndex = 0;
	int sIndex = 1;
	if (a[0] < a[1]) {
		fIndex = 1;
		sIndex = 0;
	}

	for (int i = 0; i < K / 2; i++) {

		for (int j = 0; j < a.size(); j++) {
			if (a[j] > a[fIndex]) {
				sIndex = fIndex;
				fIndex = j;
			}
			else if (a[j] > a[sIndex] && j != fIndex) {
				sIndex = j;
			}
		}

		if (a[sIndex] == 0) {
			cout<<a[fIndex] - 1;
			return;
		}

		a[fIndex]--;
		a[sIndex]--;
	}
	cout << 0 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   13 |                 return;
      |                 ^~~~~~
a.cc:17:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   17 |                 return;
      |                 ^~~~~~
a.cc:46:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
   46 |                         return;
      |                         ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int main(){
       int K;
       cin >> K;
       int T;
       cin >> T;
       int tmp = T;
       vector<int>  nums;
	      while(tmp--){
	         int element;
	         cin >> element;
	         nums.push_back(element);
	      }
       priority_queue<int> q;
       for(auto b : nums){
       	q.push(b);
       }
       while(q.size() > 1){
       		vector<int> tmp;
       		for(int i = 0; i < 2; i++){
       			auto t = q.top();
       			q.pop();
       			if(--t > 0)
       				tmp.push(t);
       		}
       		for(auto a : tmp)
       			q.push(a);
       }
       if(q.empty())
       		cout << 0 << endl;
       else if(q.size() == 1)
       		cout << q.top() - 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:37: error: 'class std::vector<int>' has no member named 'push'
   28 |                                 tmp.push(t);
      |                                     ^~~~
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int t = sc.nextInt();
        int a[];
        int maxa = 0;
        int maxi = 0;
        a = new int[t];
        for(int i = 0; i<t; i++){
		a[i] = sc.nextInt();
        if(maxa < a[i]){
            maxa = a[i];
            maxi = i;
        }
        }
        int toai = k - a[maxi];
        int answer = 0;
        if(maxa =< toai){
            System.out.println(answer);
        }
        else{
            answer = k - toai + 1;
            System.out.println(answer);
        }
	}
}

Compiler output:
Main.java:20: error: > or ',' expected
        if(maxa =< toai){
                       ^
1 error
Language: Java

import java.util.Scanner;
 
public class Solution {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
 
        if (K == 1) {
            System.out.println(0);
        }
 
        int T = sc.nextInt();
        int[] a = new int[T];
 
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
 
        int fIndex = 0;
        int sIndex = 1;
        if (a[0] < a[1]) {
            fIndex = 1;
            sIndex = 0;
        }
 
        for (int i = 0; i < K / 2; i++) {
 
            for (int j = 0; j < a.length; j++) {
                if (a[j] > a[fIndex]) {
                    sIndex = fIndex;
                    fIndex = j;
                } else if (a[j] > a[sIndex] && j != fIndex) {
                    sIndex = j;
                }
            }
 
            if (a[sIndex] == 0) {
                System.out.println(a[fIndex] - 1);
                return;
            }
 
            a[fIndex]--;
            a[sIndex]--;
        }
        System.out.println(0);
    }
}

Compiler output:
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: C++

import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
 
        if (K == 1) {
            System.out.println(0);
        }
 
        int T = sc.nextInt();
        int[] a = new int[T];
 
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
 
        int fIndex = 0;
        int sIndex = 1;
        if (a[0] < a[1]) {
            fIndex = 1;
            sIndex = 0;
        }
 
        for (int i = 0; i < K / 2; i++) {
 
            for (int j = 0; j < a.length; j++) {
                if (a[j] > a[fIndex]) {
                    sIndex = fIndex;
                    fIndex = j;
                } else if (a[j] > a[sIndex] && j != fIndex) {
                    sIndex = j;
                }
            }
 
            if (a[sIndex] == 0) {
                System.out.println(a[fIndex] - 1);
                return;
            }
 
            a[fIndex]--;
            a[sIndex]--;
        }
        System.out.println(0);
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int t = sc.nextInt();
        int a[];
        int maxa = 0;
        int maxi = 0;
        a = new int[t]
        for(int i = 0; i<t; i++){
		a[i] = sc.nextInt();
        if(maxa < a[i]){
            maxa = a[i];
            maxi = i;
        }
        }
        int toai = k - a[maxi];
        int answer = 0;
        if(maxa < toai){
            System.out.println(answer);
        }
        else{
            answer = k - toai + 1;
            System.out.println(answer);
        }
	}
}

Compiler output:
Main.java:10: error: ';' expected
        a = new int[t]
                      ^
1 error
Language: C++

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

int main(){
  int k,t;
  cin >> k >> t;
  vector<int> a(t);
  max = -1;
  for(int i = 0; i < t; i++){
    cin >> a[i];
    if(max < a[i])
      max = a[i];
  }
  int ans;
  ans = k - ((k - max) * 2 + 1);
  if(ans < 0)
    ans = 0;
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:10: error: overloaded function with no contextual type information
   10 |   max = -1;
      |          ^
a.cc:13:17: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
   13 |     if(max < a[i])
      |                 ^
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]' declared here
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
a.cc:13:8: error: parse error in template argument list
   13 |     if(max < a[i])
      |        ^~~~~~~~~~
a.cc:13:18: error: cannot resolve overloaded function 'max' based on conversion to type 'bool'
   13 |     if(max < a[i])
      |                  ^
a.cc:14:16: error: overloaded function with no contextual type information
   14 |       max = a[i];
      |                ^
a.cc:17:17: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator-'
   17 |   ans = k - ((k - max) * 2 + 1);
      |               ~~^~~~~
Language: C++

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

int main()
{
  int K, T;

  cin >> K;
  cin >> T;
  vector<int> A(T);
  int temp;
  int temp_Index;
  for(int i=0; i < T; i++)
    cin >> A[i];
   
  int cont = 0;
  vector<int>::iterator maxIt;
  size_t max_Index;
  for(int t=K; t > 0; t--){
    maxIt = max_element(A.begin(), A.end());
    max_Index = distance(A.begin(), maxIt);
    if(A[max_Index] == 0){
      cont = temp;
      break;
    }
    A[max_Index]--;
    if(t != K ) A[temp_Index] = temp;
    temp = A[max_Index];
    temp_Index = max_Index;
    A[max_Index] = 0;
  }

  cout << temp << endl;
  return 0;
}

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

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

int main(){
	int K,T;
	vector<int> a;
	cin >> K >> T;
	int input;
	while(cin >> input){
		a.push_back(input);
	}
	std::sort(a.begin(),a.end(),std::greater<int>());
	if(T == 1){
		cout << K - a[0];
	}else{
		int sum = 0;
		for(int i = 1;i < a.size();i++){
			sum += a[i];
		}
		if(sum > a[0]){
			cout << '0';
		}else{
			cout << a[0] - sum - 1;
		}
	}
	cout << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:14: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   13 |         std::sort(a.begin(),a.end(),std::greater<int>());
      |              ^~~~
      |              qsort
Language: C++

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

int main()
{
	int k, t; cin >> k >> t;
	vector<int>A(t);
	for (int i = 0; i < t; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end(),greater<int>());

	while(A.size()>1){
		if (A.front() > A.back()) {
			A.front() -= A.back();
			A.erase(--A.end());
		}
		else if (A.front()!=1 && A.front() == A.back()) {
			A.front()=1;
			A.back() = 1;
		}else break;

		sort(A.begin(), A.end(), greater<int>());
	}

	cout<<A.front() - 1 << endl;

   

Compiler output:
a.cc: In function 'int main()':
a.cc:30:37: error: expected '}' at end of input
   30 |         cout<<A.front() - 1 << endl;
      |                                     ^
a.cc:9:1: note: to match this '{'
    9 | {
      | ^
Language: C++

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

int main(){
	int K,T;
	vector<int> a;
	cin >> K >> T;
	int input;
	while(cin >> input){
		a.push_back(input);
	}
	sort(a.begin(),a.end(),std::greater<int>());
	if(T == 1){
		cout << K - a[0];
	}else{
		int sum = 0;
		for(int i = 1;i < a.size();i++){
			sum += a[i];
		}
		if(sum > a[0]){
			cout << '0';
		}else{
			cout << a[0] - sum - 1;
		}
	}
	cout << endl;
	return 0;
}


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

#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <set>
#include <map>
#include <conio.h>
#define INT long long
#define MOD 1000000007
#define oo 1987654321

using namespace std;
bool cmp(int a, int b){ return a>b; }
int k, t, p[100], ans;

int main()
{
    cin>>k>>t;
    for(int i = 0, x ; i < t ; i++ )
        cin>>p[i];
    while( k )
    {
       sort(p, p+t, cmp);
       p[0]--, k--;
       if( t-1 == 0 and ans ) ans++;
       if( k > 0 )
       {
           p[t-1]--, k--;
           if( t-1 == 0 ) ans++;
       }
       if( p[t-1] == 0 ) t--;
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:10:10: fatal error: conio.h: No such file or directory
   10 | #include <conio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: Java

mport java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        List<Integer> list = new LinkedList<>();
        for(int i=0;i<t;i++) {
            list.add(sc.nextInt());
        }
        int days =0;
        Collections.sort(list);
        if(list.get(t-1)>n-list.get(t-1)){
            days = n - list.get(t-1) -1;
        }
        if(t==1){
            days = n-t;
        }

        System.out.println(days);

    }

 }


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Collections;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.LinkedList;
^
Main.java:3: error: class, interface, enum, or record expected
import java.util.List;
^
Main.java:4: error: class, interface, enum, or record expected
import java.util.Scanner;
^
4 errors
Language: C++

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

int main(){
	int K,T;
	cin>>K>>T;
	vector<int> v(T);
	int i,j,k;
	for(i=0;i<T;i++) cin>>v[i];
	priority_queue<pair<int,int>> qu;
	for(i=0;i<T;i++) qu.push(make_pair(v[i],i));
	int pre=-1;
	int res=0;
	while(!qu.empty()){
		pair<int,int> p=qu.top();
		qu.pop();
		if(p.second!=pre){
			pre=p.second;
			p.first--;
			if(p.first) qu.push(p);
		}
		else if(qu.empty()){
			res=p.first;
		}
		else{
			pre=qu.top().second;
			qu.top().first--;
			if(qu.top().first==0) qu.pop();
			qu.push(p);
		}
	}
	cout<<res<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:34: error: decrement of member 'std::pair<int, int>::first' in read-only object
   30 |                         qu.top().first--;
      |                         ~~~~~~~~~^~~~~
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 999999999

int main() {
	int k, t;
	cin >> k >> t;
	vector<P>cake(t);

	REP(i, t) {
		cin >> cake[i].first;
		cake[i].second = i;
	}
	int ans = 0, pre = -1;
	while (1) {
		sort(cake.begin(), cake.end(),greater<int>();
		if (cake[0].first == 0)break;
		if (pre == cake[0].second) {
			if (cake[1].first)cake[1].first--;
			else {
				ans += cake[0].first;
			}
		}
	}
	cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:48:61: error: expected ')' before ';' token
   48 |                 sort(cake.begin(), cake.end(),greater<int>();
      |                     ~                                       ^
      |                                                             )
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <fstream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(int argc, const char * argv[]) {
   int K,T;
   int tt;
   cin>>K>>T;
   int max=INT_MIN;
   for (int i=0;i<T;i++) {
    cin>>tt;
    if (tt>max) max=tt;
   }
   int other=max-(K-max)-1;
   if (other<0) other=0;
   cout<<other<<endl;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:20:12: error: 'INT_MIN' was not declared in this scope
   20 |    int max=INT_MIN;
      |            ^~~~~~~
a.cc:13:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <math.h>
  +++ |+#include <climits>
   13 |