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

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

#define ll long long int

int main(void) {
	string s;

	
	cin >> s ;
	int flag = 0;
	
	for (int i = 0; i < s.length(); i++)
	{
		if (s.at(i) == 'C')
		{
			flag++;
		}
		if ((flag == 1) && (s.at(i) == 'F'))
			flag++;
	}

	if (flag > 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

#define ll long long int

int main(void) {
	string s;

	
	cin >> s ;
	int flag = 0;
	
	for (int i = 0; i < s.length(); i++)
	{
		if (s.at(i) == 'C')
		{
			flag++;
		}
		if ((flag == 1) && (s.at(i) == 'F'))
			flag++;
	}

	if (flag > 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Compiler output:
a.cc:35:2: error: stray '#' in program
   35 | }#include <iostream>
      |  ^
a.cc:35:3: error: 'include' does not name a type
   35 | }#include <iostream>
      |   ^~~~~~~
a.cc:46:5: error: redefinition of 'int main()'
   46 | int main(void) {
      |     ^~~~
a.cc:12:5: note: 'int main()' previously defined here
   12 | int main(void) {
      |     ^~~~
Language: C++

#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int cnt=0;
	char s[1000];
	scanf("%d" ,s);
	int len=strlen(s);
	int flg=0;
	rep(i,len){
		if(s[i]=='C')	flg=1;
		if(s[i]=='F' && flg==1)flg=2;
	}
	if(flg==2)	printf("Yes\n");
	else printf("No\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: 'strlen' was not declared in this scope
   19 |         int len=strlen(s);
      |                 ^~~~~~
a.cc:9:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    8 | #include <math.h>
  +++ |+#include <cstring>
    9 | #define reps(i,j,k) for(int i=(j);i<(k);i++)
Language: C++

a = raw_input()
ans = False
flag = False
for c in a:
    if c == "F" and flag:
        ans = True
    if c == "C":
        flag = True
print "Yes" if ans else "No"

Compiler output:
a.cc:1:1: error: 'a' does not name a type
    1 | a = raw_input()
      | ^
Language: C++

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))



int main(){
  string s;
  std::cin >> s;
  bool t=false;
  rep(i,s.size()){
    if(s[i]=='C') t=true;
    if(s[i]=='F'&&t=true) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: lvalue required as left operand of assignment
   36 |     if(s[i]=='F'&&t=true) {
Language: C++

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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF LONG_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  int f=0
  string s;
  cin>>s;
  rep(i,s.length()){
    if(s[i]=='C'){
      f=1;
    }
    if(s[i]=='F' and f==1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: expected ',' or ';' before 'string'
   17 |   string s;
      |   ^~~~~~
a.cc:18:8: error: 's' was not declared in this scope
   18 |   cin>>s;
      |        ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
	string s;
	cin >> s;
	int status = 0;
	for(int unsigned i=0;i<s.size;i++){
		if(s[i] == 'C' && status == 0) status = 1;
		if(s[i] == 'F' && status == 1) status = 2;
	}
	if(status == 2){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:34: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
    9 |         for(int unsigned i=0;i<s.size;i++){
      |                                ~~^~~~
      |                                      ()
Language: C++

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i, 0, s.length()){
		if (s[i] == 'C'){
			rep(j, i, s.length()){
				if (s[j] == 'F'){
					cout << "Yes" << endl;
					exit(0);
			}
		}
	}
		cout << "No" << endl;



	return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <tuple>

using namespace std;

int main(int, char**) {
    string str;
    cin >> str;
    bool a, b;
    for(int i(0); i< str.length(); ++i){
      if(str[i]=="C"){ a= true; }
      if(a&&str[i]=="F") {b=true;}

    }
    if (b) { cout << "Yes" <<endl; }
    else {  cout << "No" <<endl; }
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:15:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   15 |       if(str[i]=="C"){ a= true; }
a.cc:16:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |       if(a&&str[i]=="F") {b=true;}
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    string s;
    cin >> s;
    int x = n + 1, y = -1;
    rep(i, n) {
        if (s[i] == 'C') {
            x = i;
            break;
        }
    }
    rrep(i, n) {
        if (s[i] == 'F') {
            y = i;
            break;
        }
    }

    if (x < y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:13: error: 'n' was not declared in this scope
   32 |     int x = n + 1, y = -1;
      |             ^
a.cc:41:13: error: 'y' was not declared in this scope
   41 |             y = i;
      |             ^
a.cc:46:13: error: 'y' was not declared in this scope
   46 |     if (x < y) {
      |             ^
Language: C++

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	rep(i, 0, s.length()){
		if (s[i] == 'C'){
			rep(j, i, s.length()){
				if (s[j] == 'F'){
					cout << "Yes" << endl;
					exit(0);
			}
		}
	}
		cout << "No" << endl;



	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: 's' was not declared in this scope
   17 |         cin >> s;
      |                ^
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:14:11: note: to match this '{'
   14 | int main(){
      |           ^
Language: C

#include<stdio.h>
int main(){
  int f=0;
  char s[1000010];
  scanf("%s",s);
  for(i=0;s[i];i++){
    if(s[i]=='C'&&f==0)f=1;
    if(s[i]=='F'&&f==1)f=2;
  }
  printf("%s\n",f==2?"Yes":"No");
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:6:7: error: 'i' undeclared (first use in this function)
    6 |   for(i=0;s[i];i++){
      |       ^
main.c:6:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <limits.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define	abs(a) ((a)<0?-(a):(a))



int main(void){
	char *s;
	bool flag = false;
	s = calloc(sizeof(char),100000);
	scanf("%s",s);
	while(*s){
		if(*s == 'W'){
			flag = true;
		}
		if(*s == 'F' && flag){
			printf("Yes\n");
			return 0;
		}
		s++;
	}
	printf("No\n");

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
   17 |         s = calloc(sizeof(char),100000);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                   |
      |                   void*
Language: C++


s = input()
ans = 0

if s.index('C') < s.index('F'):
    print('Yes')
else:
    print('No')


Compiler output:
a.cc:6:11: warning: multi-character character constant [-Wmultichar]
    6 |     print('Yes')
      |           ^~~~~
a.cc:8:11: warning: multi-character character constant [-Wmultichar]
    8 |     print('No')
      |           ^~~~
a.cc:2:1: error: 's' does not name a type
    2 | s = input()
      | ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string s;
	cin>>S;
	int a=0,b=0;
	for(int i=0;i<S.size();i++){
		if(S[i] == 'C'){
			a=1;
		}
		if(S[i] == 'F' && a==1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: 'S' was not declared in this scope
    9 |         cin>>S;
      |              ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

const long long N = 3e5+2;

int k;
int t;
int ar[N];
set < int > s;

int main(){
    scanf("%d%d" , &k , &t);
    int mx = 0;
    for(int i = 1; i <= t; i++){
        scanf("%d" , &ar[i]);
        s.insert(i);
        mx = max(mx , ar[i]);
    }
    int ans = 0;
    int prv = -1;
    auto it = s.begin();
    while(k--){
        if(prv == *it)
            ans++;
        //cout << *it << "\n";
        int cur = *it;
        prv = cur;
        ar[cur]--;
        if(!ar[cur]){
            s.erase(cur);
        }
        it = s.upper_bound(cur);
        if(it == s.end()){
            it = s.begin();
        }
    }
    printf("%d\n" , ans - (mx % 2 == 0 && n > 1));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:43: error: 'n' was not declared in this scope
   38 |     printf("%d\n" , ans - (mx % 2 == 0 && n > 1));
      |                                           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define int long long
int INF = 1e9+7;
signed 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());
    cout << max(0,a[T-1]-(K-1-a[T-1])) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   14 |     cout << max(0,a[T-1]-(K-1-a[T-1])) << 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:1:
/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:14:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   14 |     cout << max(0,a[T-1]-(K-1-a[T-1])) << 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:14:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |     cout << max(0,a[T-1]-(K-1-a[T-1])) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

signed main() {
    int k, t;
    cin>>k>>t;
    int a;
    int mx = -INF;
    for (int i = 0; i < t; i++) {
        cin>>a;
        mx = max(mx, a);
    }
    cout<<max(0, mx - 1 - k + mx)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: no matching function for call to 'max(int, long long int)'
   17 |     cout<<max(0, mx - 1 - k + mx)<<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:1:
/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:17:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   17 |     cout<<max(0, mx - 1 - k + mx)<<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:17:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |     cout<<max(0, mx - 1 - k + mx)<<endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;
  cin >> k >> n;
  int a[n];
  int d=0,e;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(d<a[i]){
      d=a[i];
      e=i;
    }
  }
  cout << max(a[e]−1−(k−a[e]),0);
}

Compiler output:
a.cc:15:19: error: extended character − is not valid in an identifier
   15 |   cout << max(a[e]−1−(k−a[e]),0);
      |                   ^
a.cc:15:19: error: extended character − is not valid in an identifier
a.cc:15:23: error: extended character − is not valid in an identifier
   15 |   cout << max(a[e]−1−(k−a[e]),0);
      |                       ^
a.cc: In function 'int main()':
a.cc:15:19: error: expected ')' before '\U000022121\U00002212'
   15 |   cout << max(a[e]−1−(k−a[e]),0);
      |              ~    ^~~
      |                   )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall
	
	ini(n);
	ini(n1);
	vi morty;
	FOR(i,0,n1){
		ini(x);
		morty.push_back(x);
	}
	if(n1 == 1){
		out(n-1);
		return 0;
	}
	while(n>0){
		sort(all(morty),greater<int>());
		//for(auto x:morty){cout<<x<<" ";}cout<<"\n";
		if(morty[1] == 0){if(morty[0]!=0{out(morty[0]-1);return 0;}}
		morty[0]--;morty[1]--;
	}
	out(0);















	return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:51:49: error: expected ')' before '{' token
   51 |                 if(morty[1] == 0){if(morty[0]!=0{out(morty[0]-1);return 0;}}
      |                                     ~           ^
      |                                                 )
a.cc:51:76: error: expected primary-expression before '}' token
   51 |                 if(morty[1] == 0){if(morty[0]!=0{out(morty[0]-1);return 0;}}
      |                                                                            ^
Language: Java

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

int main() {
  int k, t;
  std::cin >> k >> t;
  std::vector<int> a(t);
  for (int i = 0; i < t; i++) std::cin >> a[i];

  sort(a.begin(), a.end());
  std::cout << std::max(0, a[t - 1] - 1 - (k - a[t - 1])) << "\n";
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <algorithm>
^
Main.java:2: error: illegal character: '#'
#include <iostream>
^
Main.java:3: error: illegal character: '#'
#include <vector>
^
Main.java:7: error: class, interface, enum, or record expected
  std::cin >> k >> t;
  ^
Main.java:8: error: class, interface, enum, or record expected
  std::vector<int> a(t);
  ^
Main.java:9: error: class, interface, enum, or record expected
  for (int i = 0; i < t; i++) std::cin >> a[i];
  ^
Main.java:9: error: class, interface, enum, or record expected
  for (int i = 0; i < t; i++) std::cin >> a[i];
                  ^
Main.java:9: error: class, interface, enum, or record expected
  for (int i = 0; i < t; i++) std::cin >> a[i];
                         ^
Main.java:11: error: class, interface, enum, or record expected
  sort(a.begin(), a.end());
  ^
Main.java:12: error: class, interface, enum, or record expected
  std::cout << std::max(0, a[t - 1] - 1 - (k - a[t - 1])) << "\n";
  ^
Main.java:13: error: class, interface, enum, or record expected
}
^
11 errors
Language: C++

import sys

readline = sys.stdin.buffer.readline

K, T = map(int, readline().split())
A = sorted(list(map(int, readline().split())))[::-1]

B = [-1 for _ in range(K)]

j = 0
for i, a in enumerate(A):
    for _ in range(a):
        if j <= K // 2 - 1:
            B[2 * j] = i
        else:
            B[2 * (j - K // 2) - 1] = i
        j += 1

print(B)
cnt = 0
for i in range(1, K):
    if B[i - 1] == B[i]:
        cnt += 1

print(cnt)


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll k,t;
  cin >> k >> t;
  ll a=0;
  ll b;
  for(int i=0;i<t;i++){
    cin >> b;
    a=max(a,b);
  }
  b=k-a;
  cout << max(0,a-b-1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:14: error: no matching function for call to 'max(int, ll)'
   25 |   cout << max(0,a-b-1) << 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:1:
/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:25:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   25 |   cout << max(0,a-b-1) << 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:25:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |   cout << max(0,a-b-1) << endl;
      |           ~~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, t;
    cin >> n >> t;
    vector<ll> a(t);
    ll maxi = 0, sum = 0;
    for (int i = 0; i < t; i++)
    {
        cin >> a[i];
        sum += a[i];
        maxi = max(a[i], maxi);
    }
    sum -= maxi;
    cout << max(0,abs(sum - maxi) - 1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: no matching function for call to 'max(int, long long int)'
   17 |     cout << max(0,abs(sum - maxi) - 1) << 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:1:
/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:17:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   17 |     cout << max(0,abs(sum - maxi) - 1) << 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:17:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |     cout << max(0,abs(sum - maxi) - 1) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
    int k,t;
    cin >> k >> t;
    vector<int> a(t);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    cout << max(a.at(n-1) - 1 - (k - a.at(n-1)), 0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: 'n' was not declared in this scope
   11 |     for(int i = 0; i < n; i++){
      |                        ^
a.cc:16:22: error: 'n' was not declared in this scope
   16 |     cout << max(a.at(n-1) - 1 - (k - a.at(n-1)), 0);
      |                      ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:16: error: no matching function for call to 'max(int, long long int)'
   15 |     cout << max(0,a[t-1]-total-1) << 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:1:
/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:15:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   15 |     cout << max(0,a[t-1]-total-1) << 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:15:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |     cout << max(0,a[t-1]-total-1) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~
Language: C++

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

using namespace std;

#define rep(i, a, n) for (int i = a; i < (n); ++i)

int main()
{
	int k, t;
	cin >> k >> t;
	vector<int> a(n);
	rep(i, 0, t) cin >> a[i];
	
	sort(a.begin(), a.end());
	
	rep(i, 0, t-1)
	{
		a[i+1] -= a[i];
	}
	cout << a[t-1]-1  << endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:23: error: 'n' was not declared in this scope
   13 |         vector<int> a(n);
      |                       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
int k,t,a[1];cin>>k>>t;
for(int i=0;i<t;i++){cin>>a[1];a[0]=max(a[0],a[1]);}
cout<<max(2*a-1-k,0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:12: error: invalid operands of types 'int' and 'int [1]' to binary 'operator*'
    6 | cout<<max(2*a-1-k,0);
      |           ~^~
      |           | |
      |           | int [1]
      |           int
Language: C++

#include <iostream>
#include <string.h>
#define inf 999999
using namespace std;

int n, m;
int main()
{
    cin >> n >> m;
    int x, maxim;
    maxim = -1;
    for(int i = 1; i <= m; i++)
    {
        cin >> x;
        if(maxim < x) maxim = x;
    }
    if(maxim * t == n) cout << 0;
    else cout << maxim - m;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: 't' was not declared in this scope
   17 |     if(maxim * t == n) cout << 0;
      |                ^
Language: C++

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

int main(void){
    int k,t;
    cin >> k >> t;
    int a[t];
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a,a+t);
    if(t == 1)cout << k-1;
    else if(a[t-1] - a[t-2] >= 2)cout << a[t-1] - a[t-2];
    else cout << 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:23: error: 'n' was not declared in this scope
    8 |     for(int i = 0;i < n;i++)cin >> a[i];
      |                       ^
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.at(i);
  }
  sort(a.rbegin(), a.rend());
  int ma = a.at(0);
  int za = n - ma;
  if(za >= n - 1){
    cout << 0;
  }else{
    cout << ma - 1 - za;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:28: error: expected ';' before ')' token
    8 |   for(int i = 0; i < t, i++){
      |                            ^
      |                            ;
a.cc:13:12: error: 'n' was not declared in this scope
   13 |   int za = n - ma;
      |            ^
Language: C++

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

int main(){
  int k, t;
  cin >> k >> t;
  vector<int> a(m);
  for(int i = 0; i < m, i++){
    cin >> a.at(i);
  }
  sort(a.rbegin(), a.rend());
  int ma = a.at(0);
  int za = n - ma;
  if(za >= n - 1){
    cout << 0;
  }else{
    cout << ma - 1 - za;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: 'm' was not declared in this scope
    7 |   vector<int> a(m);
      |                 ^
a.cc:8:28: error: expected ';' before ')' token
    8 |   for(int i = 0; i < m, i++){
      |                            ^
      |                            ;
a.cc:13:12: error: 'n' was not declared in this scope
   13 |   int za = n - ma;
      |            ^
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nectInt();
    int T = sc.nextInt();
    int max = 0;
    int sum = 0;
    for (int i = 0; i < T; i++) {
      int a = sc.nextInt();
      max = Math.max(max, a);
      sum += a;
    }
    int others = sum - max;
    
    System.out.println(Math.max(max-1-others, 0));
  }
}

Compiler output:
Main.java:6: error: cannot find symbol
    int K = sc.nectInt();
              ^
  symbol:   method nectInt()
  location: variable sc of type Scanner
1 error
Language: C++

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,T,ans=0;
  cin>>N>>T;
  vec v(T);
  rep(i,T)cin>>v[i];
  v.pb(0);
  vrsort(v);
  while(v[1]!=0){
    v[0]--;
    v[1]--;
    vrsort(v);
  }
  cout<<max(v[0]-1,0LL)<<endl;
  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:105:12: error: expected '}' at end of input
  105 |   return 0;
      |            ^
a.cc:90:11: note: to match this '{'
   90 | int main(){
      |           ^
Language: C++

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

int N, T;
priority_queue<int> pq;

int main() {
    cin >> N >> T;
    for (int i = 0; i < T; i++) {
        int a;
        cin >> a;
        pq.push(a);
    }

    int a_top = pq.top();

    cout << max(a_top − 1 − (K − a_top), 0) << endl;

    return 0;
}


Compiler output:
a.cc:18:23: error: extended character − is not valid in an identifier
   18 |     cout << max(a_top − 1 − (K − a_top), 0) << endl;
      |                       ^
a.cc:18:27: error: extended character − is not valid in an identifier
   18 |     cout << max(a_top − 1 − (K − a_top), 0) << endl;
      |                           ^
a.cc:18:32: error: extended character − is not valid in an identifier
   18 |     cout << max(a_top − 1 − (K − a_top), 0) << endl;
      |                                ^
a.cc: In function 'int main()':
a.cc:18:22: error: expected ')' before '\U00002212'
   18 |     cout << max(a_top − 1 − (K − a_top), 0) << endl;
      |                ~     ^~
      |                      )
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
  int K,T;
  cin >> K >> T;
  
  vector<int>a(T);
  for(int i=0;i<T;i++){
    cin >> a[i];
  }
  
  int max = 0;
  for(int i=0;i<T;i++){
    if(max < a[i]) max = a[i];
  }
  
  cout << max(max - 1 - (K - max) , 0) << endl;
  
  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
int main () {
  int K, T;
  cin >> K >> T;
  int a, m = 0;
  for(int i = 0; i < N; i++){
    cin >> a;
    m = max(m, a);
  }
  if(m - 1 <= K - m)cout << 0 << endl;
  else cout << m - 1 - K + m; 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:22: error: 'N' was not declared in this scope
    7 |   for(int i = 0; i < N; i++){
      |                      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main () {
  int K, T;
  cin >> K >> T;
  int a, m = 0;
  for(int i = 0; i < N; i++){
    cin >> a;
    m = max(m, a);
  }
  if(m - 1 =< K - m)cout << 0 << endl;
  else cout << m - 1 - K + m; 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:22: error: 'N' was not declared in this scope
    7 |   for(int i = 0; i < N; i++){
      |                      ^
a.cc:11:13: error: expected primary-expression before '<' token
   11 |   if(m - 1 =< K - m)cout << 0 << endl;
      |             ^
Language: C++

#include <iostream>

using namespace std;

int main(){
  int n,k;
  cin >> n>>k;
  int m=0,t;
  for(i=0;i<k;i++){
    cin >> t;
    m = max(t,m);
  }
  cout << max(m-1-n+m,0)<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   for(i=0;i<k;i++){
      |       ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int k,t;
  cin>>k>>t;
  int MAX=0;
  for(int i=0;i<t;i++){
    int a;cin>>a;
    if(MAX<a) MAX=a;
  }
  int ans=2*MAX-K-1;
  if(ans<0) cout<<0<<endl;
  else cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'K' was not declared in this scope
   12 |   int ans=2*MAX-K-1;
      |                 ^
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
             long long int tmp;
             long long int r = 1;
             if (b > a) {
                           tmp = a;
                           a = b;
                           b = tmp;
             }
             r = a % b;
             while (r != 0) {
 
 
                           a = b;
                           b = r;
                           r = a % b;
 
             }
             return b;
}

const long long int mod=1000000007;
int main(){
	//cout << fixed << setprecision(10);
	long long int k,t,a[2000];
	string str,str2;
	cin>>k>>t;
	for(int i=0;i<t;i++){
		cin>>a[i];
	}
	sort(a,a+t);
	cout<<max(2*a[t-1]-k,1LL)-1<<endl;
}
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
             long long int tmp;
             long long int r = 1;
             if (b > a) {
                           tmp = a;
                           a = b;
                           b = tmp;
             }
             r = a % b;
             while (r != 0) {
 
 
                           a = b;
                           b = r;
                           r = a % b;
 
             }
             return b;
}

const long long int mod=1000000007;
int main(){
	//cout << fixed << setprecision(10);
	long long int k,t,a[2000];
	string str,str2;
	cin>>k>>t;
	for(int i=0;i<t;i++){
		cin>>a[i];
	}
	sort(a,a+t);
	cout<<max(2*a[t-1]-k,1LL)-1<<endl;
}


Compiler output:
a.cc:67:15: error: redefinition of 'long long int gcd(long long int, long long int)'
   67 | long long int gcd(long long int a, long long int b) {
      |               ^~~
a.cc:18:15: note: 'long long int gcd(long long int, long long int)' previously defined here
   18 | long long int gcd(long long int a, long long int b) {
      |               ^~~
a.cc:87:21: error: redefinition of 'const long long int mod'
   87 | const long long int mod=1000000007;
      |                     ^~~
a.cc:38:21: note: 'const long long int mod' previously defined here
   38 | const long long int mod=1000000007;
      |                     ^~~
a.cc:88:5: error: redefinition of 'int main()'
   88 | int main(){
      |     ^~~~
a.cc:39:5: note: 'int main()' previously defined here
   39 | int main(){
      |     ^~~~
Language: C++

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

int tori(int n) {
  int k. t;
  cin >> k >> t;
  int a[t];
  for(int i = 0; i < t; i++) {
    cin >> a[i];
    cout << max(a[i] - 1 - (k - a[i]), 0) << endl;
  }
  
  return 0;
}
  

Compiler output:
a.cc: In function 'int tori(int)':
a.cc:5:8: error: expected initializer before '.' token
    5 |   int k. t;
      |        ^
a.cc:6:10: error: 'k' was not declared in this scope
    6 |   cin >> k >> t;
      |          ^
a.cc:6:15: error: 't' was not declared in this scope
    6 |   cin >> k >> t;
      |               ^
a.cc:9:12: error: 'a' was not declared in this scope
    9 |     cin >> a[i];
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,t;
  cin >>k >>t;
  int a[k];
  for(int i=0;i<t;i++)cin >>a[i];
  sort(a,a+t);
  int ans=a[t-1];
  cout <<max(K-2*ans-1,0)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: 'K' was not declared in this scope
   10 |   cout <<max(K-2*ans-1,0)<<endl;
      |              ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void add(ll& a, ll b){a = (a+b) % MOD;}

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,t;
    cin>>k>>t;
    int ans=0;
    REP(i,t){
        int a;
        cin>>a;
        if(a-t>0) max(ans,a-t)
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:31: error: expected ';' before '}' token
   36 |         if(a-t>0) max(ans,a-t)
      |                               ^
      |                               ;
   37 |     }
      |     ~                          
a.cc:36:22: warning: ignoring return value of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]', declared with attribute 'nodiscard' [-Wunused-result]
   36 |         if(a-t>0) max(ans,a-t)
      |                   ~~~^~~~~~~~~
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:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: declared here
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
Language: C++

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[105];

int main()
{
    ll K, T;
    cin >> K >> T;
    int max = 0;
    REP(i, T)
    {
        cin >> A[i];
        max = std::max(max, A[i]);
    }
    cout << std::max(0LL, 2 * max - K - 1) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:23: error: no matching function for call to 'max(int&, ll&)'
   24 |         max = std::max(max, A[i]);
      |               ~~~~~~~~^~~~~~~~~~~
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:1:
/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:24:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   24 |         max = std::max(max, A[i]);
      |               ~~~~~~~~^~~~~~~~~~~
/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:24:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |         max = std::max(max, A[i]);
      |               ~~~~~~~~^~~~~~~~~~~
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, T) {
    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:14:13: error: 'ma' cannot be used as a function
   14 |   cout << ma(ma - 1 - (K - ma), 0) << endl;
      |           ~~^~~~~~~~~~~~~~~~~~~~~~