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

/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

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

const int mx=2e5+5;
char str[mx];
deque <int> index[26];
int ara[mx],temp[mx];
ll ans;

void inversion_count(int lo,int hi)
{
    if (lo==hi) return;
    int mid=(lo+hi)/2;

    inversion_count(lo,mid);
    inversion_count(mid+1,hi);

    int i,j,k;
    for (i=lo,j=mid+1,k=lo;k<=hi;k++) {
        if (i==mid+1) temp[k]=ara[j++];
        else if (j==hi+1) temp[k]=ara[i++];
        else if (ara[i]<=ara[j]) temp[k]=ara[i++];
        else {
            ans+=mid-i+1;
            temp[k]=ara[j++];
        }
    }
    for (i=lo;i<=hi;i++) ara[i]=temp[i];
}

int main ()
{
    int i,n;

    scanf ("%s",str);
    n=strlen(str);
    for (i=0;i<n;i++) {
        index[str[i]-'a'].push_back(i);
    }
    int cnt=0;
    for (i=0;i<26;i++) cnt+=index[i].size()%2;
    if (cnt>1) {
        printf("-1\n");
        return 0;
    }

    cnt=0;
    for (i=0;i<n;i++) {
        if (ara[i]) continue;
        if (index[str[i]-'a'].size()%2) {
            ara[i]=n/2+1;
            continue;
        }
        ara[index[str[i]-'a'].back()]=n-cnt;
        ara[i]=++cnt;
        index[str[i]-'a'].pop_front();
        index[str[i]-'a'].pop_back();
    }
  //  for (i=0;i<n;i++) printf ("%d ",ara[i]);cout<<endl<<ans<<endl;
    inversion_count(0,n-1);
    printf ("%lld\n",ans);

    return 0;
}


Compiler output:
a.cc:9:21: error: 'std::deque<int> index [26]' redeclared as different kind of entity
    9 | deque <int> index[26];
      |                     ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:3:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:41:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   41 |         index[str[i]-'a'].push_back(i);
      |              ^
a.cc:44:34: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   44 |     for (i=0;i<26;i++) cnt+=index[i].size()%2;
      |                                  ^
a.cc:53:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   53 |         if (index[str[i]-'a'].size()%2) {
      |                  ^
a.cc:57:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   57 |         ara[index[str[i]-'a'].back()]=n-cnt;
      |                  ^
a.cc:59:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   59 |         index[str[i]-'a'].pop_front();
      |              ^
a.cc:60:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   60 |         index[str[i]-'a'].pop_back();
      |              ^
Language: C++

#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
using namespace std;
char s[200010];
int n, c[200010], a[200010];
long long ans;
vector < int > p[26];
bool check() {
	int cnt = 0;
	for (int i = 0; i < 26; ++i)
		cnt += p[i].size() & 1;
	return cnt < 2;
}
void add(int p, int x) {
	for (; p <= n; p += lowbit(p)) c[p] += x;
}
int sum(int p) {
	int res = 0;
	for (; p; p -= lowbit(p)) res += c[p];
	return res;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; ++i) p[s[i]-'a'].pb(i);
	if (!check()) return puts("-1"), 0;
	for (int i, sz, x = 0; x < 26; ++x) {
		for (i = 0; i < (sz = p[x].size()); ++i)
			a[p[x][i]] = p[x][sz-1-i];
	}
	for (int i = 1; i <= n; ++i)
		ans += sum(a[i]), add(a[i]);
	printf("%lld\n", ans / 2);
	return 0;	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:38: error: too few arguments to function 'void add(int, int)'
   37 |                 ans += sum(a[i]), add(a[i]);
      |                                   ~~~^~~~~~
a.cc:19:6: note: declared here
   19 | void add(int p, int x) {
      |      ^~~
Language: C++

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

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
/////////////////////

int const N = 2e5 + 41;

int n;
char s[N];
deque<int> p[N];
int q[N];
ll ans;
vector<pii> a;
int b[N];

int F[N];

void upd(int x, int v){
	while(x < N){
		F[x] += v;
		x |= (x + 1);
	}
}

int get(int x){
	int res = 0;
	while(x >= 0){
		res += F[x];
		x = (x&(x+1))-1;
	}
	return res;
}

void solve(){
	n = strlen(s);
	fi(0, n) p[s[i]-'a'].pb(i);
	int m = 0;
	fi(0, N) m += (sz(p[i]) & 1);
	if(m > 1){
		ans = -1;
		return;
	}
	int k = -1;
	fi(0, N){
		while(sz(p[i]) > 1){
			int x = p[i].front();
			int y = p[i].back();
			p[i].pop_front();
			p[i].pop_back();
			a.pb(mp(x, y));
		}
		if(sz(p[i])) k = p[i].back();
	}
	sort(a.begin(), a.end());
	if(k != -1) b[k] = n / 2;
	fi(0, sz(a)) b[a[i].first] = i, b[a[i].second] = n-1-i;
	fi(0, n){
		ans += get(n-1) - get(b[i]);
		upd(b[i], 1);
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%s",s);

	solve();

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


	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:46:13: error: 'strlen' was not declared in this scope
   46 |         n = strlen(s);
      |             ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<deque>
  +++ |+#include <cstring>
    5 |
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <utility>
using namespace std;

typedef long long ll;

const int maxn = 200010;
const int Alphabet = 26;

vector<int> loc[Alphabet];
vector<pair<int,int>> p;
char str[maxn];
int dest[maxn];
int len;
int bit[maxn * 2];

bool cmp(pair<int,int> a, pair<int,int> b)
{
	return a.first < b.first;
}

void add(int k, int x)
{
	k++;
	while (k <= len + 10)
	{
		bit[k] += x;
		k += k & -k;
	}
}

int getsum(int k)
{
	k++;
	int ret = 0;
	while (k)
	{
		ret += bit[k];
		k -= k & -k;
	}
	return ret;
}

int main()
{
	//freopen("E.in","r",stdin);
	scanf("%s",str);
	len = strlen(str);

	for (int i=0;i<len;i++) loc[str[i]-'a'].push_back(i);

	int oddNum = 0, odd;
	for (int i=0;i<Alphabet;i++)
	{
		if (loc[i].size() % 2 == 1) oddNum++, odd = i;
	}
	if ((len % 2 == 0 && oddNum != 0)||(len % 2 == 1 && oddNum != 1)) { puts("-1"); return 0; }

	for (int i=0;i<Alphabet;i++)
	{
		for (int j=0;j<loc[i].size()/2;j++) p.push_back(make_pair(loc[i][j],loc[i][loc[i].size()-1-j]));
	}
	sort(p.begin(), p.end(), cmp);
	for (int i=0;i<p.size();i++)
	{
		dest[p[i].first] = i;
		dest[p[i].second] = len-1-i;
	}
	if (oddNum == 1) dest[loc[odd][(loc[odd].size()-1)/2]] = len/2;

	ll ans = 0;
	for (int i=0;i<len;i++)
	{
		ans += (ll)getsum(len) - (ll)getsum(dest[i]);
		//cout<<len<<" "<<dest[i]<<" "<<getsum(len)<<" "<<getsum(dest[i])<<endl;
		add(dest[i],1);
	}
	printf("%lld\n",ans);
	return 0;
}


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

//
//  main.cpp
//  E
//
//  Created by Charles on 2017/12/24.
//  Copyright © 2017年 Charles. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int c[maxn],len,cnt[26],p[maxn],last[26],vis[maxn];
char s[maxn];
int lowbit(int x){
    return x&-x;
}
void update(int pos){
    while(pos<len){
        c[pos]++;
        pos+=lowbit(pos);
    }
}
int query(int pos){
    int ans=0;
    while(pos){
        ans+=c[pos];
        pos-=lowbit(pos);
    }
    return ans;
}
int main(int argc, const char * argv[]) {
    while(~scanf("%s",s+1)){
        len=(int)strlen(s+1);
        for(int i=1;i<=len;++i){
            int t=s[i]-'a';
            cnt[t]++;
            p[i]=last[t];
            last[t]=i;
        }
        int count=0;
        for(int i=0;i<26;++i) count+=(cnt[i]&1);
        if(count>len%2) {
            puts("-1");
            continue;
        }
        ll ans=0,n=len,prenum=0;
        for(int i=1;i<=len;++i){
            if(!vis[i]){
                int t=s[i]-'a';
                int la=last[t];
                if(i>=la){
                    n--;
                    ans+=n/2;
                }
                else{
                    vis[la]=1;
                    ans+=n-(la-prenum-query(la));
                    update(la);
                    n-=2;
                    last[t]=p[la];
                }
                prenum++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:35:18: error: 'strlen' was not declared in this scope
   35 |         len=(int)strlen(s+1);
      |                  ^~~~~~
a.cc:11:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   10 | #include <algorithm>
  +++ |+#include <cstring>
   11 | using namespace std;
Language: C++

#include <bits/stdc++.h>
#define rep(i,  x,  y) for(int i = x; i <= y; i ++)
#define ll unsigned long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define ls rt << 1
#define rs rt << 1 | 1
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 2e5 + 10;
inline int lowbit(int x){return x&-x;}
char s[N];
int n;
bool sc[N];
int seg[N << 2], lt[N << 2], cx[27];
stack<int> sta[27];
inline void push_down(int rt)
{
	seg[rt] += lt[rt];
	lt[ls] += lt[rt];
	lt[rs] += lt[rt];
	lt[rt]=0;
}
inline int query(int x,int l,int r,int rt)
{
	push_down(rt);
	if(x == l && x == r) return seg[rt];
	int mid = l + r >> 1;
	if(mid >= x) return query(x, l, mid, ls);
	else return query(x, mid + 1, r, rs);
}
inline void xg(int v, int x, int y, int l, int r, int rt)
{
	push_down(rt);
	if(x == l && y == r)
	{
		lt[rt] += v;
		return;
	}
	int mid = l + r >> 1;
	if(mid < x) xg(v, x, y, mid + 1, r, rs);
	else if(mid >= y) xg(v, x, y, l, mid, ls);
	else
	{
		xg(v, x, mid, l, mid, ls);
		xg(v, mid + 1, y, mid + 1, r, rs);
	}
}
int main()
{
	scanf("%s", s);
	n = strlen(s);
	int f = 0;
	rep(i, 0, n - 1) cx[s[i] - 'a'] ++;
	rep(i, 0, 26) if(cx[i] & 1) f ++;
	if(n % 2 != f)
	{
		puts("-1");
		exit(0);
	}
	f=0;
	rep(i, 0, n/2) if(cx[s[i] - 'a'] & 1) f=1;
	if(f) strrev(s);
	rep(i, 0, n - 1) sta[s[i] - 'a'].push(i);
	ll ans = 0;
	int use = n / 2;
	for(int i = 0; use; i ++)
	{
		if(sc[i]) continue;
		int pla = sta[s[i] - 'a'].top();
		sc[pla] = 1;
		sta[s[i] - 'a'].pop();
		xg(-1, pla + 1, n - 1, 0, n - 1, 1);
		ans += n - (n / 2 - use) - 1 - pla - query(pla, 0, n - 1, 1);
		use --;
	}
	cout << ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:15: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   74 |         if(f) strrev(s);
      |               ^~~~~~
      |               strsep
Language: C++

#include <bits/stdc++.h>
#define rep(i,  x,  y) for(int i = x; i <= y; i ++)
#define ll unsigned long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define ls rt << 1
#define rs rt << 1 | 1
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 2e5 + 10;
inline int lowbit(int x){return x&-x;}
char s[N];
int n;
bool sc[N];
int seg[N << 2], lt[N << 2], cx[27];
stack<int> sta[27];
inline void push_down(int rt)
{
	seg[rt] += lt[rt];
	lt[ls] += lt[rt];
	lt[rs] += lt[rt];
	lt[rt]=0;
}
inline int query(int x,int l,int r,int rt)
{
	push_down(rt);
	if(x == l && x == r) return seg[rt];
	int mid = l + r >> 1;
	if(mid >= x) return query(x, l, mid, ls);
	else return query(x, mid + 1, r, rs);
}
inline void xg(int v, int x, int y, int l, int r, int rt)
{
	push_down(rt);
	if(x == l && y == r)
	{
		lt[rt] += v;
		return;
	}
	int mid = l + r >> 1;
	if(mid < x) xg(v, x, y, mid + 1, r, rs);
	else if(mid >= y) xg(v, x, y, l, mid, ls);
	else
	{
		xg(v, x, mid, l, mid, ls);
		xg(v, mid + 1, y, mid + 1, r, rs);
	}
}
int main()
{
	scanf("%s", s);
	n = strlen(s);
	int f = 0;
	rep(i, 0, n - 1) cx[s[i] - 'a'] ++;
	rep(i, 0, 26) if(cx[i] & 1) f ++;
	if(n % 2 != f)
	{
		puts("-1");
		exit(0);
	}
	f=0;
	rep(i, 0, n/2) if(cx[s[i] - 'a'] & 1) f=1;
	if(f) strrev(s);
	rep(i, 0, n - 1) sta[s[i] - 'a'].push(i);
	ll ans = 0;
	int use = n / 2;
	for(int i = 0; use; i ++)
	{
		if(sc[i]) continue;
		int pla = sta[s[i] - 'a'].top();
		sc[pla] = 1;
		sta[s[i] - 'a'].pop();
		xg(-1, pla + 1, n - 1, 0, n - 1, 1);
		ans += n - (n / 2 - use) - 1 - pla - query(pla, 0, n - 1, 1);
		use --;
	}
	cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:15: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   74 |         if(f) strrev(s);
      |               ^~~~~~
      |               strsep
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

using namespace std;

int main(void){
	string s;

	cin >> s;

	int al[30];
	for (int i = 0; i < n; i++){
		a[s[i] - 'a']++;
	}

	int even = 0, odd = 0;

	for (int i = 0; i < 26; i++){
		if (a[i] % 2 == 0){
			even++;
		}
		else
			odd++;
	}

	if (odd <= 1){
		cout << "f" << endl;
	}
	else {
		cout << - 1<< endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:29: error: 'n' was not declared in this scope
   17 |         for (int i = 0; i < n; i++){
      |                             ^
a.cc:18:17: error: 'a' was not declared in this scope
   18 |                 a[s[i] - 'a']++;
      |                 ^
a.cc:24:21: error: 'a' was not declared in this scope
   24 |                 if (a[i] % 2 == 0){
      |                     ^
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define L 26
vector<int> a[L], b[L];

int main(){
	string s;
	cin>>s;
	int n = s.size();
	rep(i, n) a[s[i]-'a'].push_back(i);
	int odd = n%2, c = -1;
	rep(i, L){
		if(a[i].size()%2){
			odd--;
			c = i;
		}
	}
	if(odd){
		cout<<-1<<endl;
		return 0;
	}
	vector<P> v[5];
	rep(i, L){
		int m = a[i].size();
		rep(j, m){
			P p = P(a[i][j], i);
			if(j<m/2){
				if(a[i][j]<n/2) v[0].pb(p);
				else v[1].pb(p);
			} else if(j>=(m+1)/2){
				if(a[i][j]>=(n+1)/2) v[4].pb(p);
				else v[3].pb(p);
			} else v[2].pb(p);
		}
	}
	rep(i, 5) sort(all(v[i]));
	ll res = 0;
	{
		int t = 0;
		rep(i, 5){
			rep(j, v[i].size()){
				res += abs(t-v[i][j].fst);
				//cerr<<(char)(v[i][j].snd+'a')<<endl;
				//cerr<<t-v[i][j].fst<<endl;
				if(i!=2) b[v[i][j].snd].pb(t);
				t++;
			}
		}
	}
	cerr<<"current "<<res/2<<endl;
	rep(i, L){
		int m = b[i].size();
		rep(j, m/2){
			res += abs(b[i][j]-(n-1-b[i][m-1-j]));
			//cerr<<(char)(i+'a')<<" "<<j<<" "<<b[i][j]-(n-1-b[i][m-1-j])<<endl;
			//cerr<<b[i][j]<<" "<<b[i][m-1-j]<<endl;
		}
	}
	res /= 2;
	if(!v2[i].empty()){
		rep(i, v[1].size()) if(v[1][i].fst<v[2][i].fst) res++;
		rep(i, v[3].size()) if(v[3][i].fst>v[2][i].fst) res++;

	}
	cout<<res<<endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:97:13: error: 'v2' was not declared in this scope; did you mean 'v'?
   97 |         if(!v2[i].empty()){
      |             ^~
      |             v
a.cc:97:16: error: 'i' was not declared in this scope
   97 |         if(!v2[i].empty()){
      |                ^
Language: C++

#define _USE_MATH_DEFINES

#include <iostream>
#include <iterator>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <climits>
#include <ctime>

using namespace std;
using ll = long long;
using ull = unsigned long long;

vector<ll> fen;

ll fen_get(int pos) {
	ll sum = 0;
	for (; pos >= 0; pos = (pos & (pos+1)) - 1)
		sum += fen[pos];
	return sum;
}

void fen_add(int pos, int val) {
	for (; pos < fen.size(); pos = pos | (pos+1))
		fen[pos] += val;
}

void fen_init(int sz) {
	fen.assign(sz, 0);
	for (int i = 0; i < sz; ++i)
		fen_add(i, 1);
}

void solve() {
	string s;
	getline(cin, s);
	ll n = s.size();
	if (n == 1) {
		cout << 0;
		return;
	}
	unordered_map<char,vector<ll>> ind;
	ll cnt = 0;
	for (int i = 0; i < n; ++i)
		ind[s[i]].push_back(i), cnt ^= (1 << (s[i]-'a'));
	//if (__builtin_popcount(cnt) > 1)
	if (__popcnt(cnt) > 1)
		cout << -1;
	else {
		ll k = n / 2;
		ll sum = 0;
		vector<ll> left_part;
		vector<ll> right_part;
		for (auto & x : ind) {
			vector<ll> & v = x.second;
			for (int i = 0; i < v.size() / 2; ++i) {
				sum += v[i];
				left_part.push_back(v[i]);
			}
			for (int i = v.size() / 2; i < v.size(); ++i) {
				right_part.push_back(v[i]);
			}
		}
		sum -= k*(k-1)/2;
		sort(left_part.begin(), left_part.end());
		sort(right_part.begin(), right_part.end());
		reverse(right_part.begin(), right_part.end());
		vector<ll> p(n - k);
		for (int i = 0; i < right_part.size(); ++i) {
			int pos = right_part[i];
			char c = s[pos];
			int t1 = lower_bound(ind[c].begin(), ind[c].end(), pos) - ind[c].begin();
			int t2 = ind[c].size() - t1 - 1;
			if (t1 == t2)
				p[i] = k;
			else
				p[i] = lower_bound(left_part.begin(), left_part.end(), ind[c][t2]) - left_part.begin();
		}
		fen_init(n - k);
		for (int i = 0; i < n - k; ++i) {
			fen_add(p[i], -1);
			sum += fen_get(p[i]);
		}
		cout << sum;
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

#ifdef LOCAL
	cerr << double(clock()) / CLOCKS_PER_SEC << " sec" << endl;
#endif
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:56:13: error: '__popcnt' was not declared in this scope
   56 |         if (__popcnt(cnt) > 1)
      |             ^~~~~~~~
Language: C++

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

typedef long long li;

typedef vector<vector<li>> mat;
const int ALPHABET = 26;

mat calc_swap_matrix(const string s) {
    mat ret(ALPHABET, vector<li>(ALPHABET, 0));
    vector<li> cnt(ALPHABET, 0);
    for (auto &&c : s) {
        const int ci = c - 'a';
        for (int i = 0; i < ALPHABET; ++i) {
            ret[ci][i] += cnt[i];
        }
        cnt[ci] += 1;
    }
    return ret;
}

int main() {
    string s;
    cin >> s;
    const int n = s.size();

    map<char, int> cnt;
    for (auto &&c : s) {
        cnt[c] += 1;
    }

    int odd_cnt = 0;
    for (auto &&item : cnt) {
        if (item.second & 1) {
            odd_cnt += 1;
        }
    }
    if (odd_cnt > 1) {
        cout << -1 << endl;
        return 0;
    }

    string front, back;
    map<char, int> front_cnt;
    li prep_cost = 0;
    for (int i = 0; i < n; ++i) {
        const char c = s[i];
        if ((front_cnt[c] + 1) * 2 <= cnt[c]) {
            prep_cost += i - front.size();
            front.push_back(c);
            front_cnt[c] += 1;
        } else if (front_cnt[c] * 2 + 1 == cnt[c]) {
            prep_cost += i - (n / 2);
        } else {
            back.push_back(c);
        }
    }
    reverse(back.begin(), back.end());
//    cerr << prep_cost << endl;
//    cerr << front << endl;
//    cerr << back << endl;

    mat fm = calc_swap_matrix(front);
    mat bm = calc_swap_matrix(back);

    li ans = prep_cost;
    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < i; ++j) {
            ans += abs(fm[i][j] - bm[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}

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

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	int cnt[26] = {};
	for(char c : s) {
		cnt[c-'a'] ++;
		it++;
	}
	int odd = 0;
	int sp = -1;
	for(int i = 0; i < 26; ++i) {
		odd += cnt[i]%2;
		if(cnt[i]&1) sp = i;
		cnt[i] >>= 1;
	}
	if(odd > 1) return cout << -1 << endl, 0;

	vector<int> t(n);
	vector<int> ord[3];
	for(int i = 0; i < (int)n; ++i) {
		int p = s[i] -'a';
		if(p == sp) {
			if(cnt[p]) {
				t[i] = 0;
				--cnt[p];
				ord[0].push_back(i);
			}
			else if(cnt[p] == 0) {
				t[i] = 1;
				--cnt[p];
				ord[1].push_back(i);

			}
			else if(cnt[p] < 0) {
				t[i] = 2;
				ord[2].push_back(i);
			}
		}
		else {
			if(cnt[p]) {
				t[i] = 0;
				--cnt[p];
				ord[0].push_back(i);
			}
			else {
				t[i] = 2;
				ord[2].push_back(i);
			}

		}
	}

	int pref[3][n];
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < 3; ++j) {
			pref[j][i] = (i ? pref[j][i-1] : 0);
		}
		pref[t[i]][i]++;
	}
	int inv = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 2; j > t[i]; --j) {
			inv += pref[j][i];
		}
	}
	queue<int> q[26];
	for(int i = 1; i <= ord[2].size(); ++i) {
		q[s[ord[2][ord[2].size() - i]] - 'a'].push(i);
	}
	for(int i = 0; i < ord[0].size(); ++i) {
		int p = q[s[ord[0][i]] - 'a'].front();
		q[s[ord[0][i]] - 'a'].pop();
		inv += max(0, p - (i + 1));
	}
	cout << inv << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'it' was not declared in this scope; did you mean 'int'?
   13 |                 it++;
      |                 ^~
      |                 int
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
string s;
int n;
int INF = 1e9;
 
class BIT
{
public:
	vector<int> bit;
	int M;
 
	BIT(int M):
		bit(vector<int>(M + 1, 0)), M(M) {}
 
	int sum(int i) {
		int s = 0;
		i++;
		while(i) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i, int x) {
		i++;
		while(i < bit.size()) {
			bit[i] += x;
			i += i & -i;
		}
	}
};
 
BIT bit(200010);
 
int foo(set<int> &vse) {
	if(vse.size() <= 1) return -1;
	int a = *vse.begin();
	int b = *(vse.rbegin());
	int ret = 0;
	ret += bit.sum(a) - 1;
	ret += bit.sum(n - 1) - bit.sum(b);
	return ret;
}
 
int solve() {
	cin >> s;
	n = s.size();
       assert(n > 10);
	vectoe<int> cnt(26);
	for(int i = 0; i < n; i++) {
		s[i] -= 'a';
		cnt[s[i]]++;
	}
	int c = 0;
	for(int i = 0; i < 26; i++) {
		c += cnt[i] & 1;
	}
	if(c > 1) {
		return -1;
	}
	vector<set<int>> vse(26);
	for(int i = 0; i < n; i++) {
		vse[s[i]].insert(i);
	}
	int m = n;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		bit.add(i, 1);
	}
	while(m > 1) {
		pair<int, int> tmp(INF, -1);
		for(int i = 0; i < 26; i++) {
			pair<int, int> t(0, i);
			t.first = foo(vse[i]);
			if(t.first == -1) continue;
			tmp = min(tmp, t);
		}
		int a = *vse[tmp.second].begin();
		int b = *vse[tmp.second].rbegin();
		vse[tmp.second].erase(a);
		vse[tmp.second].erase(b);
		bit.add(a, -1);
		bit.add(b, -1);
		ans += tmp.first;
		m -= 2;
	}
	return ans;
}
 
 
int main() {
	cout << solve() << endl;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:52:9: error: 'vectoe' was not declared in this scope
   52 |         vectoe<int> cnt(26);
      |         ^~~~~~
a.cc:52:16: error: expected primary-expression before 'int'
   52 |         vectoe<int> cnt(26);
      |                ^~~
a.cc:55:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   55 |                 cnt[s[i]]++;
      |                 ^~~
      |                 int
a.cc:59:22: error: 'cnt' was not declared in this scope; did you mean 'int'?
   59 |                 c += cnt[i] & 1;
      |                      ^~~
      |                      int
Language: C++

#include <iostream>
 
using namespace std;
char s[200010 + 1];
 
int main()
{
    
        scanf("%s", s);
        int len = strlen(s);
        int count[26] = {0}, odd = 0;
        for (int i = 0; i < len; i++)
            count[s[i] - 'a']++;
        for (int i = 0; i < 26; i++)
            if (count[i] & 1)
                odd++;
        if (odd > 1)
            puts("-1");
        else
        {
            int step = 0;
            for (int i = 0, j = len - 1; i < j; i++, j--)
            {
                int l, r;
                for (r = j; r > i; r--)
                    if (s[i] == s[r])
                        break;
                for (l = i; l < j; l++)
                    if (s[j] == s[l])
                        break;
                if (j - r > l - i)
                {
                    step += l - i;
                    for (int k = l - 1; k >= i; k--)
                        swap(s[k], s[k + 1]);
                }
                else
                {
                    step += j - r;
                    for (int k = r + 1; k <= j; k++)
                        swap(s[k], s[k - 1]);
                }
            }
            printf("%d\n", step);
        }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'strlen' was not declared in this scope
   10 |         int len = strlen(s);
      |                   ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
int c[30],n;
vector<int> v[30];
char s[N];
bool pd[N];
int f[N];
inline int sum(int x){
	int ret = 0;
	while(x){
		ret += f[x];
		x -= x&-x;
	}
	return ret;
}
inline add(int x,int d){
	while(x<N){
		f[x]+=d;
		x+= x&-x;
	}
}
int main(){
	scanf("%s",s+1);
	n = strlen(s+1);
	for(int i =1;i<=n;i++) c[s[i]-'a']++;
	int cnt = 0;
	for(int i=0;i<26;i++) if(c[i]&1) cnt++;
	if(cnt>1){
		puts("-1");
		return 0;
	}
	ll ans = 0;
	for(int i = 1;i<=n;i++) v[s[i]-'a'].push_back(i);
	int delta = 0;
	//puts("UUU");
	for(int i =1;i<=n;i++){
		if(pd[i]){
			delta++;
			continue;
		}
		int t = v[s[i]-'a'].back();
		//cout<<i<<' '<<t<<endl;
		v[s[i]-'a'].pop_back();
		int now = i-delta;
		int des = n-now+1;
		ans += des-(t-sum(t));
		add(t,1);
		pd[t] = true;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:18:8: error: ISO C++ forbids declaration of 'add' with no type [-fpermissive]
   18 | inline add(int x,int d){
      |        ^~~
a.cc: In function 'int add(int, int)':
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1100005, INF = 1<<25;

int in[N], n, cc[129];
bool used[N];
char str[N];
vector<int>g[129];

int lowbit(int t)
{
    return t&(t^(t-1));
}

int sum(int end)
{
    int ans=0;
    while(end>0)
    {
        ans+=in[end];
        end-=lowbit(end);
    }
    return ans;
}

void add(int pos ,int num)
{
    while(pos<=n)
    {
        in[pos]+=num;
        pos+=lowbit(pos);
    }
}

void solve()
{
    memset(in, 0, sizeof(in));
    for(int i=1; i<=n+1; i++)
    {
        add(i,1);
    }
    LL ans = 0;
    int v, u, size;
    char s;
    memset(used, 0, sizeof(used));
    for(int i=1; i<=n; i++)
    {
        if(!used[i])
        {
            s = str[i];
            size = g[s].size();
            u = g[s][size-1];
            if(i == u)
            {
                ans += (sum(n) - sum(i))/2;
            }
            else
            {
                ans += sum(n) - sum(u);
            }
            add(u, -1);
            add(i, -1);
            used[i] = used[u] = 1;
            g[s].erase(g[s].end()-1);
        }
    }
    printf("%lld", ans);
    puts("");
}

int main()
{
    scanf("%s", str+1);
        n = strlen(str+1);
        memset(cc, 0, sizeof(cc));

        for(int i=1; i<129; i++)
            g[i].clear();

        for(int i=1; i<=n; i++)
        {
            cc[str[i]]++;
            g[str[i]].push_back(i);
        }

        int flag = 0;
        for(int i=0; i<26; i++)
        {
            if(cc['a'+i]%2) flag++;
            if(cc['A'+i]%2) flag++;
        }
        if(flag > 1)
        {
            printf("-1");
            puts("");
            continue;
        }
        else
        {
            solve();
        }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:103:13: error: continue statement not within a loop
  103 |             continue;
      |             ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  {
    Int A=0;
    for(Int i=0;i<n;i++)
      A+=G[i].size()&1;
    cout<<A/2<<" ";
  }

  auto check=
    [&](Int x)->Int{
      Int ng=0;
      function<Int(Int, Int)> dfs=
        [&](Int v,Int p){
          vector<Int> vs;
          for(Int u:G[v]){
            if(u==p) continue;            
            vs.emplace_back(dfs(u,v)+1);
          }
          
          if(G[v].size()&1)
            vs.emplace_back(0);
          sort(vs.begin(),vs.end());
          
          Int k=vs.size();
          if(p<0){
            assert(~k&1);
            for(Int i=0;i<k/2;i++)
              if(vs[i]+vs[k-(i+1)]>x) return ng=1;
            return 0;
          }
          
          assert(k&1);
          
          auto check2=
            [&](Int y)->Int{
              vector<Int> us;
              for(Int i=0;i<k;i++)
                if(i!=y) us.emplace_back(vs[i]);
              Int l=us.size();
              assert(~l&1);
              for(Int i=0;i<l/2;i++)
                if(us[i]+us[l-(i+1)]>x) return 0;
              return 1;
            };
          
          Int l=-1,r=k;
          while(l+1<r){
            Int m=(l+r)>>1;
            if(check2(m)) r=m;
            else l=m;
          }
          if(r==k) return ng=1;
          return vs[r];
        };
      
      dfs(0,-1);
      return !ng;
    };
    
  Int l=0,r=n;
  while(l+1<r){
    Int m=(l+r)>>1;
    if(check(m)) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:46:20: error: inconsistent types 'long long int' and 'int' deduced for lambda return type
   46 |             return 0;
      |                    ^
Language: C++

#include<bits/stdc++.h>
 
using namespace std;
 
#define For(i,a,b) for(int i = a; i <= b; ++ i)
#define pb push_back
#define fi first
#define se second
 
const int N = 1e5 + 5;
typedef pair < int, int > ii;
int t, n, h[N];
bool kt;
vector < int > adj[N];
 
bool check1(vector < ii > data, int pos, int lim){
	if(pos > 0) data.erase(data.begin() + pos);
	int l = 0, r = data.size() - 1; 
	while (l < r) if (data[l++].fi + data[r--].fi > lim) return false; 
	return true;
}
int cal(vector < ii > data, int lim){
	int len = data.size();
	int l = 0, r = len - 1, res = len;
	while(l <= r){
		int mid = (l + r) / 2;
		if(check1(data, mid, lim)) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	if(res < len) return data[res].se;
	return -1;
}
bool dfs(int u, int pa, int lim){ 
	vector < ii > data;
	For(i, 0, (int)adj[u].size() - 1){
		int v = adj[u][i]; if( v == pa) continue; 
		if(! dfs(v, u, lim)) return false;
		if( ++ h[v] > lim) return false;
		data.pb(ii(h[v], v));
	}
	if(data.size() == 0) return true;
	sort(data.begin(), data.end());
	int len = data.size(), Max = 0; 
	if(len % 2 == 0){
		kt = check1(data, -1, lim);
		if(!kt) return false;
	}
	else{
		int res = cal(data, lim);
		if(res == -1) return false;
		h[u] = h[res];
		if(u == 1 && h[u] > lim) return false; 
	}
	return true;
}
int findA(int u, int p) {
    int rem = 0;
    for (int v : G[u]) if (v != p) {
        rem += findA(v, u);
    }
    A += rem / 2; rem %= 2;
    if (rem == 1) return rem;
    return (u == 1) ? 0 : 1;
}
signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	For(i, 1, n - 1){
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);  adj[v].pb(u);
	}
	int dem = 0;
	dem = findA(1, -1);
	int l = 0, r = n, ans;
	while(l <= r){
		memset(h, 0, sizeof h);
		int mid = (l + r)/2;
		if(dfs(1, 1, mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << dem + 1 << ' ' << ans;
}

Compiler output:
a.cc: In function 'int findA(int, int)':
a.cc:58:18: error: 'G' was not declared in this scope
   58 |     for (int v : G[u]) if (v != p) {
      |                  ^
a.cc:61:5: error: 'A' was not declared in this scope
   61 |     A += rem / 2; rem %= 2;
      |     ^
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
vector<int> g[N];
int n, x;
bool ok;
int r = 0;
bool used[N];

int dfs(int u){
	used[u] = true;
	multiset<int> d;
	for(auto v: g[u]){
		if(used[v]) continue;
		int t = dfs(v)+1;
		d.insert(t);
		if(!ok) return INF;
	}
	if(d.size()%2==0) d.insert(0);
	while(d.size()>1){
		auto it = d.end(); --it;
		int k = *it;
		d.erase(it);
		auto it2 = d.upper_bound(x-k);
		if(it2==d.begin()){
			ok = false;
			return INF;
		}
		--it2;
		d.erase(it2);
	}
	if(*d.begin()>x) ok = false;
	used[u] = false;
	return *d.begin();
}

int main(){
	cin>>n;
	rep(i, n-1){
		int u, v;
		cin>>u>>v; u--; v--;
		g[u].push_back(v); g[v].push_back(u);
	}
	int resa = 0, resb = 0
	rep(i, n){
		resa += (g[i].size()-1)/2;
		resb += g[i].size()%2;
		if(g[i].size()==1) r = i;
	}
	resa--; resb /= 2;
	if(resa!=resb) return -1;
	int lb = -1, ub = n;
	while(ub-lb>1){
		x = (lb+ub+1)/2;
		ok = true;
		mset(used, 0);
		dfs(r);
		(ok?ub:lb)=x;
	}
	cout<<resb<<" "<<ub<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:18: error: expected ',' or ';' before 'for'
   28 | #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
      |                  ^~~
a.cc:83:9: note: in expansion of macro 'rep'
   83 |         rep(i, n){
      |         ^~~
a.cc:83:13: error: 'i' was not declared in this scope
   83 |         rep(i, n){
      |             ^
a.cc:28:33: note: in definition of macro 'rep'
   28 | #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
      |                                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b:
  cin>>a>>b;
  cout<<(a+b)/2<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: error: found ':' in nested-name-specifier, expected '::'
    5 |   int a,b:
      |          ^
      |          ::
a.cc:5:9: error: 'b' has not been declared
    5 |   int a,b:
      |         ^
a.cc:6:6: error: qualified-id in declaration before '>>' token
    6 |   cin>>a>>b;
      |      ^~
a.cc:7:12: error: 'b' was not declared in this scope
    7 |   cout<<(a+b)/2<<endl;
      |            ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {

  int a,b;

  cin >> a >> b;

  double avg = (a+b)/2
   int avg2 = avg 
  cout <<avg2<< endl;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:4: error: expected ',' or ';' before 'int'
   12 |    int avg2 = avg
      |    ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if ((a+b)%2 == 0):
  	cout << (a+b)/2 << endl;
  else:
    cout << (a+b)/2+1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:20: error: expected primary-expression before ':' token
    7 |   if ((a+b)%2 == 0):
      |                    ^
a.cc:9:7: error: expected primary-expression before ':' token
    9 |   else:
      |       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int a, b;
  double avg;
  
  cin >> a >> b;
  
  avg = (a + b) / 2;
  
  count << a << endl;
  count << b << endl;
  count << (int) ceil(avg) << endl;
  
  cout << (int) ceil(avg) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<<'
   13 |   count << a << endl;
      |   ~~~~~~^~~~
a.cc:14:9: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<<'
   14 |   count << b << endl;
      |   ~~~~~~^~~~
a.cc:15:9: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<<'
   15 |   count << (int) ceil(avg) << endl;
      |   ~~~~~~^~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int a, b;
  double avg:
  
  cin >> a >> b;
  
  avg = (a + b) / 2;
  
  cout << ceil(avg) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: found ':' in nested-name-specifier, expected '::'
    7 |   double avg:
      |             ^
      |             ::
a.cc:7:10: error: 'avg' has not been declared
    7 |   double avg:
      |          ^~~
a.cc:9:7: error: qualified-id in declaration before '>>' token
    9 |   cin >> a >> b;
      |       ^~
a.cc:11:3: error: 'avg' was not declared in this scope
   11 |   avg = (a + b) / 2;
      |   ^~~
Language: C++

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

int main() {
  // ここにプログラムを追記
  int a, b;
  cin >> a >> b;
  cout << ((a+b)/2)%+1
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:23: error: expected ';' before '}' token
    8 |   cout << ((a+b)/2)%+1
      |                       ^
      |                       ;
    9 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  x = a + b / 2;
  if ((a + b) % 2 == 0){
    cout << x << endl;
  }
  else{
    cout << x + 1 << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'x' was not declared in this scope
    7 |   x = a + b / 2;
      |   ^
Language: C++

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

int main() {

  int a, b;
  cin >> a >> b;
  
  if ( (a + b) / 2 * 2 <= a + b) {
    cout << (a + b) / 2 + 1 <<endl;
  }
  else if { 
    cout << (a + b) / 2 <<endl;
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: expected '(' before '{' token
   12 |   else if {
      |           ^
      |           (
Language: C++

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

int main() {

  int a, b;
  cin >> a >> b;
  
  if ( (a + b) / 2 * 2 <= a + b) {
    cout << (a + b) / 2 + 1 <<endl;
  }
  else if { 
    cout << (a + b) / 2 <<endl;
  
}


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

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

int main() {

  int A ,B
  cin >> A >> B
  cout << (A + B) / 2 + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected initializer before 'cin'
    7 |   cin >> A >> B
      |   ^~~
Language: C++

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

int main() {
  int A ,B;
  cin >> A >> B
  cout << A + B / 2 + 1 << endl;
}

Compiler output:
a.cc:1:10: fatal error: bits/sudc++.h: No such file or directory
    1 | #include <bits/sudc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	xout << (a + b + 1) / 2 << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'xout' was not declared in this scope
   10 |         xout << (a + b + 1) / 2 << "\n";
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,x;
  cin >>a>>b;
  double y=1/2+(a+b)/2;
  cout << x=y <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: invalid operands of types 'double' and '<unresolved overloaded function type>' to binary 'operator<<'
    8 |   cout << x=y <<endl;
      |             ~~^~~~~~
Language: C++

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

int () main{
  int a,b;
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
}


Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'nameplace'
    2 | using nameplace std;
      |       ^~~~~~~~~
a.cc:4:6: error: expected unqualified-id before ')' token
    4 | int () main{
      |      ^
Language: C++

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

int()main{
  int a,b;
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
}


Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'nameplace'
    2 | using nameplace std;
      |       ^~~~~~~~~
a.cc:4:5: error: expected unqualified-id before ')' token
    4 | int()main{
      |     ^
Language: C++

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

int()main{
  int a,b;
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc:4:5: error: expected unqualified-id before ')' token
    4 | int()main{
      |     ^
Language: C++

includ<bits/stdc++.h>
using nameplace std;

int()main{
  int a,b;
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
}

Compiler output:
a.cc:1:1: error: 'includ' does not name a type
    1 | includ<bits/stdc++.h>
      | ^~~~~~
a.cc:4:5: error: expected unqualified-id before ')' token
    4 | int()main{
      |     ^
Language: C++

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

int main() {
  int a,b,x;
  cin >> a >> b >> x end;
  x == ((a+b)/2);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:21: error: expected ';' before 'end'
    6 |   cin >> a >> b >> x end;
      |                     ^~~~
      |                     ;
Language: C++

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

int main() {
  int a,b,x;
  cin >> a >> b >> x end;
  x == ((a+b)/2)
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:21: error: expected ';' before 'end'
    6 |   cin >> a >> b >> x end;
      |                     ^~~~
      |                     ;
a.cc:7:17: error: expected ';' before '}' token
    7 |   x == ((a+b)/2)
      |                 ^
      |                 ;
    8 | }
      | ~
Language: C++

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

int main() {
  int a,b,x;
  cin >> a >> b >> x end;
  int (a+B)/2
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:21: error: expected ';' before 'end'
    6 |   cin >> a >> b >> x end;
      |                     ^~~~
      |                     ;
a.cc:7:10: error: 'B' was not declared in this scope
    7 |   int (a+B)/2
      |          ^
Language: C++

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

int main() {
  double a, b;
  int x;
  cin >> a >> b >> x;
  cout << x = (a + b) / 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:27: error: invalid operands of types 'double' and '<unresolved overloaded function type>' to binary 'operator<<'
    8 |   cout << x = (a + b) / 2 << endl;
      |               ~~~~~~~~~~~~^~~~~~~
Language: C++

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

int main() {
  itn a,b;
  cin >> a >> b;
  cout << (a+b)-(a+b)/2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'itn' was not declared in this scope; did you mean 'int'?
    5 |   itn a,b;
      |   ^~~
      |   int
a.cc:6:10: error: 'a' was not declared in this scope
    6 |   cin >> a >> b;
      |          ^
a.cc:6:15: error: 'b' was not declared in this scope
    6 |   cin >> a >> b;
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    double a,b;
    cin >> a >> b;
    cout << (a+b)/2+(a+b)%2 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:26: error: invalid operands of types 'double' and 'int' to binary 'operator%'
    6 |     cout << (a+b)/2+(a+b)%2 << endl;
      |                     ~~~~~^~
      |                       |   |
      |                       |   int
      |                       double
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int a;
  int b;
  cin >> A; //7
  cin >> B; //4
  cout << (a + (b-1)) / b ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'A' was not declared in this scope
    8 |   cin >> A; //7
      |          ^
a.cc:9:10: error: 'B' was not declared in this scope
    9 |   cin >> B; //4
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int A;
  int B;
  cin >> A; //2002
  cin >> B; //2032
  cout << (a + (b-1)) / b << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: 'a' was not declared in this scope
   10 |   cout << (a + (b-1)) / b << endl;
      |            ^
a.cc:10:17: error: 'b' was not declared in this scope
   10 |   cout << (a + (b-1)) / b << endl;
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int A;
  int B;
  int C;
  cin >> A; //1
  cin >> B; //3
  C = A+B)/2 + 0.9
  cout << C << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: expected ';' before ')' token
   11 |   C = A+B)/2 + 0.9
      |          ^
      |          ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int main(void){
  double a = 0, b = 0;
  int dst = 0;
  cin >> a >> b;
  dst = ((a+b)/2)+ 0.9;
  cout << dst << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:17: error: a function-definition is not allowed here before '{' token
    4 |   int main(void){
      |                 ^
a.cc:10:2: error: expected '}' at end of input
   10 | }
      |  ^
a.cc:3:12: note: to match this '{'
    3 | int main() {
      |            ^