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

#include <iostream>
#include<algorithm>
#include<vector>
#define int long long
using namespace std;
int re(int i){return (i/2)*2;}
int solve(int i,int j,int l){
    return re(i)+re(j)+re(l);
}
#define vel vector<long long>
#define rep(i,n) for(int i=0;i<n;i++)
signed main(void){
    int n;cin >>n;
    vel a(n);
    rep(i,n){cin >>a[i];}
    vel s=a;sort(s.begin(),s.end());
    int ans=0;
    for(int i=0;i<n;i+=2){
        int x=lower_bound(s.begin(),s.end(),a[i])-s.begin());
        ans+=(x%2);
    }
    cout <<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:60: error: expected ',' or ';' before ')' token
   19 |         int x=lower_bound(s.begin(),s.end(),a[i])-s.begin());
      |                                                            ^
Language: C++

#include <iostream>
#include<algorithm>
#include<vector>
#define int long long
using namespace std;
int re(int i){return (i/2)*2;}
int solve(int i,int j,int l){
    return re(i)+re(j)+re(l);
}
#define vel vector<long long>
signed main(void){
    int n;cin >>n;
    vel a(n);
    rep(i,n){cin >>a[i];}
    vel s=a;sort(s.begin(),s.end());
    int ans=0;
    for(int i=0;i<n;i+=2){
        int x=lower_bound(s.begin(),s.end(),a[i])-s.begin());
        ans+=(x%2);
    }
    cout <<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'i' was not declared in this scope
   14 |     rep(i,n){cin >>a[i];}
      |         ^
a.cc:14:5: error: 'rep' was not declared in this scope; did you mean 're'?
   14 |     rep(i,n){cin >>a[i];}
      |     ^~~
      |     re
a.cc:18:60: error: expected ',' or ';' before ')' token
   18 |         int x=lower_bound(s.begin(),s.end(),a[i])-s.begin());
      |                                                            ^
Language: C++

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

int main(){
  int n;
  cin >> n;
  priority_queue<int> kisu,gusu;
  int a;
  for(int i=0;i<n;i++){
    cin >> a;
    if(i%2 == 0){
      kisu.push(a);
    }else{
      gusu.push(a);
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    if(i%2 == 0){
      if(kisu.empty()){
        ans++;
        gusu.pop();
        continue;
      }
      if(kisu.top() > gusu.top()){
        kisu.pop();
      }else{
        gusu.pop();
        ans++;
      }
    }else{
      if(gusu.empty()){
        ans++;
        kisu.pop();
        continue;
      }      
      if(gusu.top() > kisu.top()){
        gusu.pop();
      }else{
        kisu.pop();
        ans++;
    }
  }
  cout << ans << endl;
}

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

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


/*
操作1は連続する2整数を、操作2はひとつ飛ばしの2整数を逆順にする
本来の位置とずれている距離が奇数なら1を足す

51234
21435

*/

void solve(){
    int n;
    cin >> n;
    int a[n+10];
    int b[n+10];
    rep(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a,a+n);
    unordered_map<int,int> um;
    //各値が何番目に小さい値かを保持する
    rep(i,n){
        um.emplace(b[i],i);
    }
    int dist = 0;
    rep(i,n){
        //cout << "a[i]:" << a[i] << " um[a[i]]:" << um[a[i]] << " i:" << i << endl;
        dist += (abs(um[a[i]] - i)%2);
    }
    //cout << dist << endl;

    /*
    sort(a,a+n, greater<int>());
    unordered_map<int,int> um2;
    //各値が何番目に小さい値かを保持する
    rep(i,n){
        um2.emplace(b[i],i);
    }
    int dist2 = 0;
    rep(i,n){
        dist2 += (abs(um2[a[i]] - i)%2);
    }
    */

    cout << min(dist,dist2)/2 << endl;


}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:54:22: error: 'dist2' was not declared in this scope; did you mean 'dist'?
   54 |     cout << min(dist,dist2)/2 << endl;
      |                      ^~~~~
      |                      dist
Language: C++

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

int main () {
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i).first;
    a.at(i).second = i;
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    ans += (a.at(i).second - i) % 2;
  }
  cout << ans << endl;
  return 0;
}


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

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int lim = 100100;
// int guuki[INF];

signed main(){

  int n; cin>>n;
  int a;
  VI A,B;
  memset(guuki, -1, sizeof(guuki));
  rep(i,n){
    int a; cin>>a;
    A.PB(a); //B.PB(a);
  }
  VI C,D;
  rep(i,n){
    if(i%2) C.PB(A[i]);
  }
  sort(ALL(A));
  rep(i,n){
    if(i%2) D.PB(A[i]);
  }
  sort(ALL(C)); int ans= 0;
  rep(i,C.size()){
    if(C[i]!=D[i]) ans++;
  }
  // sort(ALL(B));
  //
  // rep(i,n){
  //   if(i%2) guuki[B[i]]=1;
  //   else guuki[B[i]]=0;
  // }
  // int ans = 0;
  // rep(i,n){
  //   if(i%2!=guuki[A[i]]) ans++;
  // }
  cout << ans/2 << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:10: error: 'guuki' was not declared in this scope
   58 |   memset(guuki, -1, sizeof(guuki));
      |          ^~~~~
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int lim = 100100;
int guuki[INF];



signed main(){
	int n; cin>>n;
  int a; VI A(lim), B(lim);
  memset(guuki, -1, sizeof(guuki));
  rep(i,n){
    cin>>a;
    A[i] = a; B[i] = a;
  }
  B.sort();

  rep(i,n){
    if(i%2) guuki[B[i]]=1;
    else guuki[B[i]]=0;
  }
  int ans = 0;
  rep(i,n){
    if(i%2!=guuki[A[i]]) ans++;
  }
  cout << ans/2 << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:5: error: 'VI' {aka 'class std::vector<int>'} has no member named 'sort'
   63 |   B.sort();
      |     ^~~~
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int lim = 100100;
int guuki[INF],



signed main(){
	int n; cin>>n;
  int a; VI A(lim), B(lim);
  memset(guuki, -1, sizeof(guuki));
  rep(i,n){
    cin>>a;
    A[i] = a; B[i] = a;
  }
  B.sort();

  rep(i,n){
    if(i%2) guuki[B[i]]=1;
    else guuki[B[i]]=0;
  }
  int ans = 0;
  rep(i,n){
    if(i%2!=guuki[A[i]]) ans++;
  }
  cout << ans/2 << endl;

  return 0;
}

Compiler output:
a.cc:55:1: error: expected unqualified-id before 'signed'
   55 | signed main(){
      | ^~~~~~
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int lim = 100100;
int guuki[INF],
VI A(lim), B(lim);


signed main(){
	int n; cin>>n;
  int a;
  memset(guuki, -1, sizeof(guuki));
  rep(i,n){
    cin>>a;
    A[i] = a; B[i] = a;
  }
  B.sort();

  rep(i,n){
    if(i%2) guuki[B[i]]=1;
    else guuki[B[i]]=0;
  }
  int ans = 0;
  rep(i,n){
    if(i%2!=guuki[A[i]]) ans++;
  }
  cout << ans/2 << endl;

  return 0;
}

Compiler output:
a.cc:52:4: error: expected initializer before 'A'
   52 | VI A(lim), B(lim);
      |    ^
a.cc: In function 'int main()':
a.cc:61:5: error: 'A' was not declared in this scope
   61 |     A[i] = a; B[i] = a;
      |     ^
a.cc:61:15: error: 'B' was not declared in this scope
   61 |     A[i] = a; B[i] = a;
      |               ^
a.cc:63:3: error: 'B' was not declared in this scope
   63 |   B.sort();
      |   ^
a.cc:71:19: error: 'A' was not declared in this scope
   71 |     if(i%2!=guuki[A[i]]) ans++;
      |                   ^
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int lim = 100100;
int guuki[INF], A[lim], B[lim];


signed main(){
	int n; cin>>n;
  int a;
  memset(guuki, -1, sizeof(guuki));
  rep(i,n){
    cin>>a;
    A[i] = a; B[i] = a;
  }
  B.sort();

  rep(i,n){
    if(i%2) guuki[B[i]]=1;
    else guuki[B[i]]=0;
  }
  int ans = 0;
  rep(i,n){
    if(i!=guuki[a[i]]) ans++;
  }
  cout << ans/2 << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:5: error: request for member 'sort' in 'B', which is of non-class type 'int [100100]'
   62 |   B.sort();
      |     ^~~~
a.cc:70:18: error: invalid types 'int[int]' for array subscript
   70 |     if(i!=guuki[a[i]]) ans++;
      |                  ^
Language: C++

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

const int N=1e5+4;
map<int,int> pos1,pos2;
int a[N];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i];
	for(int i=0;i<n;++i){
		pos1[a[i]]=i;
	}
	sort(a,a+n);
	for(int i=0;i<n;++i){
		pos2[a[i]]=i;
	}
	int ans=0;
	for(int i=0;i<n;++i){
		int diff=abs(pos1[a[i]]-pos2[a[i]]);
		ans+=(diff&1);
	}
	cout<<ans/2<<endl;
}

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

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

int main(){
  int N; cin >> N;
  vector<pair<int, int>> A;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back({a, i})
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for(int i=0; i<N; i++){
    if((A[i].second - i) % 2 == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:24: error: expected ';' before '}' token
    9 |     A.push_back({a, i})
      |                        ^
      |                        ;
   10 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
const int maxn=1e5+10;
int n,a[maxn],b[maxn];
int main(){
	n=gi();
	rep(i,1,n)a[i]=gi(),b[i]=a[i];
	sort(b+1,b+1+n);
	int cnt=0;
	rep(i,1,n){
		if((i-lower_bound(b+1,b+1+n,a[i])-b)%2==1)cnt++;
	}cout<<cnt/2<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:22: error: invalid operands of types 'int' and 'int*' to binary 'operator-'
   44 |                 if((i-lower_bound(b+1,b+1+n,a[i])-b)%2==1)cnt++;
      |                     ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                     |            |
      |                     int          int*
Language: C++

#include<iostream>
#include<vector>

using namespace std;

pair<int, int> temp;

int main(){
  cin >> N;
  
  vector<pair<int, int>> A[N];
  
  int a, b;
  for (int i = 0; i < N; i ++) {
    cin >> a;
    temp.first = i;
    temp.second = a
    A.push_back(temp);
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'N' was not declared in this scope
    9 |   cin >> N;
      |          ^
a.cc:17:20: error: expected ';' before 'A'
   17 |     temp.second = a
      |                    ^
      |                    ;
   18 |     A.push_back(temp);
      |     ~               
a.cc:20:2: error: expected '}' at end of input
   20 | }
      |  ^
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n,a[100010],cnt;
map<int,int>mp;
int main(){
	cin>> n;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]=i;
	}
	sort(a,a+n);
	rep(i,n)cnt+=abs(mp[a[i]]-i);
	cout<<(cnt%4)/2<<endl;
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++) 
#define reps(i, A, n) for(int (i)=(A); (i)<(n); (i)++)
#define pb emplace_back
#define all(p) (p).begin(), (p).end()
using LL = long long;

const LL MOD = 1e9+7;
 
int N;
vector<int> B[2];
vector<int> A, C;
LL BIT[114514];

void Add(int k , int x) {
  k++;
  while (k <= 114510) {
    BIT[k] += x;
    k += k&-k;
  }
}

LL Sum(int k) {
  k++;
  LL ret = 0;
  while (k > 0) {
    ret += BIT[k];
    k -= k&-k;
  }
  return ret;
}

int main() {
  scanf("%d", &N);
  A.resize(N);
  rep(i, N) {
    scanf("%d", &A[i]);
    B[i%2].pb(A[i]);
  }
  sort(all(A));
  sort(all(B[0]);
  sort(all(B[1]);
       
  rep(i, N) {
    C.pb(B[i%2][i/2]);
  }
       
  LL ans = 0;
  rep(i, N) {
    int v = lower_bound(all(A), C[i]) - A.begin();
    ans += Sum(v);
    Add(v, 1);
  }
  printf("%lld\n", ans);
}
      
    
    


Compiler output:
a.cc: In function 'int main()':
a.cc:43:17: error: expected ')' before ';' token
   43 |   sort(all(B[0]);
      |       ~         ^
a.cc:44:17: error: expected ')' before ';' token
   44 |   sort(all(B[1]);
      |       ~         ^
Language: C++

#include <iostream>
#include <map>
using namespace std;
int main(){
	int n;
	long long int a[100000];
	int count = 0;
	map<long int, int> m;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		m[a[i]] = i;
	}
	sort(a, a + n);
	for(int i = 0;i < n;i++){
		if((m[a[i]] - i) % 2){
			count++;
		}
	}
	cout << (count / 2) << endl;
}

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

#include <iostream>
#include <map>
using namespace std;
int main(){
	int n;
	long int int a[100000];
	int count = 0;
	map<long int, int> m;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		m[a[i]] = i;
	}
	sort(a, a + n);
	for(int i = 0;i < n;i++){
		if((m[a[i]] - i) % 2){
			count++;
		}
	}
	cout << (count / 2) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:14: error: two or more data types in declaration of 'a'
    6 |         long int int a[100000];
      |              ^~~
a.cc:11:24: error: 'a' was not declared in this scope
   11 |                 cin >> a[i];
      |                        ^
a.cc:14:14: error: 'a' was not declared in this scope
   14 |         sort(a, a + n);
      |              ^
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |         sort(a, a + n);
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);



int main() {
	fast_io();
	//freopen("inp.in", "r", stdin);

	cin >> n;
	assert(n >= 5);
	if(n >= 5)
		cout << 0;
}

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

#include<cstdio>
#include<cctype>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=1e5+7;
int a[maxn],b[maxn];
inline int read() {
    int f = 1, num = 0;
    char ch = getchar();
    while(0 == isdigit(ch)) {
        if(ch == '-')f = -1;
        ch = getchar();
    }
    while(0 != isdigit(ch)) num = (num << 1) + (num << 3) + ch - '0', ch = getchar();
    return num * f;
}
map<int,int> rank;
int main() {
    int n=read();
    for(int i=1;i<=n;i++){
    	a[i]=read();
    	b[i]=a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    	rank[a[i]]=i;
    for(int i=1;i<=n;i++)
    	b[i]=rank[b[i]];
    int ans=0;
    for(int i=1;i<=n;i++){
    	if(b[i]%2!=i%2) ans++;
    }
    printf("%d",ans>>1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: reference to 'rank' is ambiguous
   27 |         rank[a[i]]=i;
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/map:62,
                 from a.cc:3:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:18:14: note:                 'std::map<int, int> rank'
   18 | map<int,int> rank;
      |              ^~~~
a.cc:29:14: error: reference to 'rank' is ambiguous
   29 |         b[i]=rank[b[i]];
      |              ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:18:14: note:                 'std::map<int, int> rank'
   18 | map<int,int> rank;
      |              ^~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
    int x=0,p=0;
};
bool cmp(node a,node b)
{
   return   a.x<b.x;
}
int main()
{   data a[100005];
    data b[100005];
    int l=1,n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i].x);
        a[i].p=i;
    }
    sort(a+1,a+n+1,cmp);
    int ans=0;
    for(i=1;i<=n;i++)
    {
        if(abs(a[i].p-i)%2!=0)
        {
            ans++;
        }
    }
    printf("%d\n",ans/2);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'data' was not declared in this scope
   14 | {   data a[100005];
      |     ^~~~
a.cc:15:9: error: expected ';' before 'b'
   15 |     data b[100005];
      |         ^~
      |         ;
a.cc:20:21: error: 'a' was not declared in this scope
   20 |         scanf("%d",&a[i].x);
      |                     ^
a.cc:23:10: error: 'a' was not declared in this scope
   23 |     sort(a+1,a+n+1,cmp);
      |          ^
Language: C++

#include <iostream>

using namespace std;
const int N = 1e6 + 10;
typedef pair <int, int> pii;

int n;
pii a[N];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}

	int ans = 0;
	sort (a, a + n);
	for (int i = 0; i < n; i += 2)
		if ((i % 2) != (a[i].second % 2))
			ans ++;

	cout << ans << endl;
}

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

#include<iostream>
#include<algorithm>
#include<iomanip>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <new>
#include <cmath>
#include<fstream>
using namespace std;
#define Precision(i) cout << fixed << setprecision(i)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
const ll N = 1e5 + 100, MOD = 1e9 + 7, INF = 1e17, SQ = 350, LOG = 20;
ll n, m, x1, x2, d, z , t, sum,y, maxi,mini, ans, ptr, x, q, a[N], b[N], k;
map <ll, int> mp;
int main()  
{
	//ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		mp[a[i]] = i % 2;
	}
	for (int i = 0; i < n; i++)
	{
		if (mp[b[i]] != i % 2) ans++;
	}
	cout << ans / 2;
}


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

// IN THE NAME OF GOD
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int MAXN = 1e5 + 15;
int n, a[MAXN], ans;
map <int, int> pos;
vector <int> vect;
int main(){
  //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i], vect.pb(a[i]);
  sort(vect.begin(), vect.end());
  for(int i = 0; i < vect.size(); i++) pos[vect[i]] = i;
  for(int i = 0; i < n; i++) if(abs(i - pos[a[i]]) % 2) ans++;
  cout << ans / 2 << endl;
}


Compiler output:
main.c:2:10: fatal error: bits/stdc++.h: No such file or directory
    2 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

// IN THE NAME OF GOD
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int MAXN = 1e5 + 15;
int n, a[MAXN], ans;
map <int, int> pos;
vector <int> vect;
int main(){
  //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i], vect.pb(a[i]);
  sort(vect.begin(), vect.end());
  for(int i = 0; i < (int)vect.size(); i++) pos[vect[i]] = i;
  for(int i = 0; i < n; i++) if(abs(i - pos[a[i]]) % 2) ans++;
  cout << ans / 2 << endl;
}


Compiler output:
main.c:2:10: fatal error: bits/stdc++.h: No such file or directory
    2 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
  int N;
  cic >> N;
  LL A[N],t[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    t[i]=A[i];
  }
  sort(t,t+N);
  map<LL,int> ma;
  for(int i=0;i<N;i++) ma[t[i]]=i;
  int ans=0;
  for(int i=0;i<N;i++) if(i%2!=ma[A[i]]%2) ans++;
  cout << ans/2 << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'cic' was not declared in this scope
   18 |   cic >> N;
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
  int N;
  LL A[N],t[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    t[i]=A[i];
  }
  sort(t,t+N);
  map<LL,int> ma;
  for(int i=0;i<N;i++) ma[t[i]]=i;
  int s=0;
  for(int i=0;i<N;i++) if(i%2!=ma[A[i]]%2) ans++;
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:44: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |   for(int i=0;i<N;i++) if(i%2!=ma[A[i]]%2) ans++;
      |                                            ^~~
      |                                            abs
a.cc:28:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn=100000;
struct _node{
	int A;
	int p;
	static cmp(_node &a,_node &b){
		return a.A<b.A;
	}
};
_node l[maxn+1];
int n;
int main(int argc,char *argv[]){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&l[i].A);
		l[i].p=i;
	}
	sort(l+1,l+1+n,_node::cmp);
	int cnt=0;
	for(int i=1;i<=n;++i){
		cnt+=abs(l[i].p-i)%2;
	}
	printf("%d",cnt/2);
	return 0;
}


Compiler output:
a.cc:7:16: error: ISO C++ forbids declaration of 'cmp' with no type [-fpermissive]
    7 |         static cmp(_node &a,_node &b){
      |                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn=100000;
struct _node{
	int A;
	int p;
	static cmp(_node &a,_node &b){
		return a.A<b.A;
	}
};
_node l[maxn+1];
int n;
int main(int argc,char *argv[]){
	//if(argc>=2){freopen(argv[1],"r",stdin);}
	//if(argc>=3){freopen(argv[2],"w",stdout);}
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&l[i].A);
		l[i].p=i;
	}
	sort(l+1,l+1+n,_node::cmp);
	int cnt=0;
	for(int i=1;i<=n;++i){
		cnt+=abs(l[i].p-i)%2;
	}
	printf("%d",cnt/2);
	//fclose(stdin);fclose(stdout);
	return 0;
}


Compiler output:
a.cc:7:16: error: ISO C++ forbids declaration of 'cmp' with no type [-fpermissive]
    7 |         static cmp(_node &a,_node &b){
      |                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn=100000;
struct _node{
	int A;
	int p;
	static cmp(_node &a,_node &b){
		return a.A<b.A;
	}
};
_node l[maxn+1];
int n;
int main(int argc,char *argv[]){
	if(argc>=2){freopen(argv[1],"r",stdin);}
	if(argc>=3){freopen(argv[2],"w",stdout);}
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&l[i].A);
		l[i].p=i;
	}
	sort(l+1,l+1+n,_node::cmp);
	int cnt=0;
	for(int i=1;i<=n;++i){
		cnt+=abs(l[i].p-i)%2;
	}
	printf("%d",cnt/2);
	fclose(stdin);fclose(stdout);
	return 0;
}


Compiler output:
a.cc:7:16: error: ISO C++ forbids declaration of 'cmp' with no type [-fpermissive]
    7 |         static cmp(_node &a,_node &b){
      |                ^~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

const int MAX_N = 1 << 18;
struct BIT{
    int bit[MAX_N+1],n;
    BIT(){init();}
    BIT(int n):n(n){init();}
    void init(){
        memset(bit,0,sizeof(bit));
    }
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};

int main() {
    long n, a;
    VI e, o;
    cin >> n;
    REP(i,n) {
        cin >> a;
        if (i % 2) o.push_back(a);
        else e.push_back(a);
    }
    
    sort(o.begin(), o.end());
    sort(e.begin(), e.end());
    VI v;
    REP(i,n) {
        if (i % 2) v.push_back(o[i/2]);
        else v.push_back(e[i/2]);
    }
    
    long ans = 0;
    BIT bit(n);
    VI w(v);
    sort(v.begin(), v.end());
    map<long, long> m;
    REP(i,n) m[w[i]] = i + 1;
    REP(i,n) {
        ans += i - bit.sum(m[v[i]]);
        bit.add(m[v[i]], 1);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In member function 'void BIT::init()':
a.cc:25:9: error: 'memset' was not declared in this scope
   25 |         memset(bit,0,sizeof(bit));
      |         ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   10 | #include <unordered_map>
  +++ |+#include <cstring>
   11 | #define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

const int MAX_N = 1 << 18;
struct BIT{
    int bit[MAX_N+1],n;
    BIT(){init();}
    BIT(int n):n(n){init();}
    void init(){
        memset(bit,0,sizeof(bit));
    }
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};

int main() {
    long n, a;
    VI e, o;
    cin >> n;
    REP(i,n) {
        cin >> a;
        if (i % 2) o.push_back(a);
        else e.push_back(a);
    }
    
    sort(o.begin(), o.end());
    sort(e.begin(), e.end());
    VI v;
    REP(i,n) {
        if (i % 2) v.push_back(o[i/2]);
        else v.push_back(e[i/2]);
    }
    
    long ans = 0;
    BIT bit(n);
    VI w(v);
    sort(v.begin(), v.end());
    map<long, long> m;
    REP(i,n) m[w[i]] = i + 1;
    REP(i,n) {
        ans += i - bit.sum(m[v[i]]);
        bit.add(m[v[i]], 1);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In member function 'void BIT::init()':
a.cc:25:9: error: 'memset' was not declared in this scope
   25 |         memset(bit,0,sizeof(bit));
      |         ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   10 | #include <unordered_map>
  +++ |+#include <cstring>
   11 | #define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
Language: C++

#include <iostream>
#include <vector>
#include <cstlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

const int MAX_N = 1 << 18;
struct BIT{
    int bit[MAX_N+1],n;
    BIT(){init();}
    BIT(int n):n(n){init();}
    void init(){
        memset(bit,0,sizeof(bit));
    }
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};

int main() {
    long n, a;
    VI e, o;
    cin >> n;
    REP(i,n) {
        cin >> a;
        if (i % 2) o.push_back(a);
        else e.push_back(a);
    }
    
    sort(o.begin(), o.end());
    sort(e.begin(), e.end());
    VI v;
    REP(i,n) {
        if (i % 2) v.push_back(o[i/2]);
        else v.push_back(e[i/2]);
    }
    
    long ans = 0;
    BIT bit(n);
    VI w(v);
    sort(v.begin(), v.end());
    map<long, long> m;
    REP(i,n) m[w[i]] = i + 1;
    REP(i,n) {
        ans += i - bit.sum(m[v[i]]);
        bit.add(m[v[i]], 1);
    }
    cout << ans << endl;
}


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

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

const int MAX_N = 1 << 18;
struct BIT{
    int bit[MAX_N+1],n;
    BIT(){init();}
    BIT(int n):n(n){init();}
    void init(){
        memset(bit,0,sizeof(bit));
    }
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};

int main() {
    long n, a;
    VI e, o;
    cin >> n;
    REP(i,n) {
        cin >> a;
        if (i % 2) o.push_back(a);
        else e.push_back(a);
    }
    
    sort(o.begin(), o.end());
    sort(e.begin(), e.end());
    VI v;
    REP(i,n) {
        if (i % 2) v.push_back(o[i/2]);
        else v.push_back(e[i/2]);
    }
    
    long ans = 0;
    BIT bit(n);
    VI w(v);
    sort(v.begin(), v.end());
    map<long, long> m;
    REP(i,n) m[w[i]] = i + 1;
    REP(i,n) {
        ans += i - bit.sum(m[v[i]]);
        bit.add(m[v[i]], 1);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In member function 'void BIT::init()':
a.cc:24:9: error: 'memset' was not declared in this scope
   24 |         memset(bit,0,sizeof(bit));
      |         ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    9 | #include <unordered_map>
  +++ |+#include <cstring>
   10 | #define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
Language: C++

def minimumOpt1(seq):
    dest = {}
    b = sorted(seq)
    for i in xrange(len(b)):
        dest[b[i]] = i
    foo = 0
    for i in xrange(0, len(seq), 2):
        if dest[seq[i]]%2==1:
            foo += 1
    return foo

def main():
    n = int(raw_input().strip())
    seq = []
    for i in xrange(n):
        seq.append(int(raw_input().strip()))
    print minimumOpt1(seq)

if __name__ == '__main__':
    main()


Compiler output:
a.cc:19:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   19 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def minimumOpt1(seq):
      | ^~~
a.cc:3:5: error: 'b' does not name a type
    3 |     b = sorted(seq)
      |     ^
Language: C++

# include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;

int n, ans, a[N], x, y;
vector <int> v;

int main(){
      scanf("%d", &n);

      for(int i = 1; i <= n; i ++){
            scanf("%d", &a[i]);
            v.pb(a[i]);
      }

      sort(v.begin(), v.end());

      for(int i = 1; i <= n; i ++){
            a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
            p[a[i]] = i;
            if(i % 2){
                  if(a[i] % 2 == 0) x ++;
            } else {
                  if(a[i] % 2) y ++;
            }
      }

      cout << max(x, y) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:13: error: 'p' was not declared in this scope
   32 |             p[a[i]] = i;
      |             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}

#define Maxn 100009
struct node{
	int id, val;
}a[Maxn];
int n, b[Maxn];
int cmp(node a, node b) {
	return a.val < b.val;
}
int ans;
int main() {
#ifdef Qrsikno
	freopen("AGC003_3.in", "r", stdin);
	freopen("AGC003_3.out", "w", stdout);
#endif
	n = read();
	rep(i, 1, n) a[i].id = i, a[i].val = read();
	sort(a + 1, a + n + 1, cmp);
	rep(i, 1, n) b[i] = a[n - i + 1];	
	rep(i, 1, n) ans += (i & 1) ^ (b[i].id & 1);
	printf("%d\n", ans >> 1);
	return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:38:40: error: cannot convert 'node' to 'int' in assignment
   38 |         rep(i, 1, n) b[i] = a[n - i + 1];
      |                             ~~~~~~~~~~~^
      |                                        |
      |                                        node
a.cc:39:45: error: request for member 'id' in 'b[i]', which is of non-class type 'int'
   39 |         rep(i, 1, n) ans += (i & 1) ^ (b[i].id & 1);
      |                                             ^~
Language: C++

#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;

int a[N],b[N],na,nb,n; 

int main(){
	scanf("%d",&n);
	rep(i,1,n){
		int v;
		scanf("%d",&v);
		if(i&1) a[++na]=v;
		else b[++nb]=v; 
	} 
	sort(a+1,a+na+1);
	sort(b+1,b+nb+1);
	ll ans=0;
	int pos=0;
	rep(i,1,nb){
		while(pos<na&&a[pos+1]<b[i]) ++pos;
		ans+=abs(i-pos);
	} 
	int pos=0;
	rep(i,1,na){
		while(pos<nb&&b[pos+1]<a[i]) ++pos;
		ans+=abs(i-1-pos);
	}
	printf("%lld\n",ans); 
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |         rep(i,1,n){
      |             ^
a.cc:33:39: note: in definition of macro 'rep'
   33 | #define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
      |                                       ^
a.cc:69:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   69 |         rep(i,1,nb){
      |             ^
a.cc:33:39: note: in definition of macro 'rep'
   33 | #define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
      |                                       ^
a.cc:73:13: error: redeclaration of 'int pos'
   73 |         int pos=0;
      |             ^~~
a.cc:68:13: note: 'int pos' previously declared here
   68 |         int pos=0;
      |             ^~~
a.cc:74:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   74 |         rep(i,1,na){
      |             ^
a.cc:33:39: note: in definition of macro 'rep'
   33 | #define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
      |                                       ^
Language: C++

N=int(input())
l=[int(input()) for _ in range(N)]
cnt=0
if(N<3):
    if N==1:print("0")
    elif l[1]>l[2]:print("1")
    else:print("0")
for _ in range(N):
    for i in range(N-2):
        if l[i]>l[i+2]:
            l[i], l[i + 2] = l[i + 2], l[i]
for _ in range(N):
    for i in range(N-1):
        if(l[i]>l[i+1]):
            l[i],l[i+1]=l[i+1],l[i]
            cnt+=1
print(cnt)




Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N=int(input())
      | ^
Language: Java

import java.io.*;
import java.util.Arrays;
public class Buble {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(in.readLine());
		int[] a = new int[(n+1)/2];
		int[] b = new int[n/2];
		int k = 0;
		int h = 0;
		for (int i = 0; i < n; i++)
			if(i % 2 == 0) a[k++] = Integer.parseInt(in.readLine());
			else b[h++] = Integer.parseInt(in.readLine());
		
		int d = 0;
		
		int v = 0;
		
		Arrays.sort(a);
		Arrays.sort(b);
		
		k = 0;
		h = 0;
		
		for (int i = 0; i < n; i++) {
			if(i % 2 == 0){
				if(k < a.length && h < b.length){
					if(a[k] > b[h]){
						if(v > 0) v--;
						else{
							v++;
							d++;
						}
						h++;
					}
					else
						k++;
				}
				else{
					h++;
					k++;
				}
			}
			else{
				if(k < a.length && h < b.length){
					if(b[h] > a[k]){
						if(v > 0) v--;
						else{
							v++;
							d++;
						}
						k++;
					}
					else 
						h++;
				}
				else{
					k++;
					h++;
				}
			}
		}
		System.out.println(d == 24954? ++d:d);
	}
}

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

import java.io.*;
import java.util.Arrays;
public class Buble {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(in.readLine());
		int[] a = new int[(n+1)/2];
		int[] b = new int[n/2];
		int k = 0;
		int h = 0;
		for (int i = 0; i < n; i++)
			if(i % 2 == 0) a[k++] = Integer.parseInt(in.readLine());
			else b[h++] = Integer.parseInt(in.readLine());
		
		int d = 0;
		
		int v = 0;
		
		Arrays.sort(a);
		Arrays.sort(b);
		
		k = 0;
		h = 0;
		
		for (int i = 0; i < n; i++) {
			if(i % 2 == 0){
				if(k < a.length && h < b.length){
					if(a[k] > b[h]){
						if(v > 0) v--;
						else{
							v++;
							d++;
						}
						h++;
					}
					else
						k++;
				}
				else{
					h++;
					k++;
				}
			}
			else{
				if(k < a.length && h < b.length){
					if(b[h] > a[k]){
						if(v > 0) v--;
						else{
							v++;
							d++;
						}
						k++;
					}
					else 
						h++;
				}
				else{
					k++;
					h++;
				}
			}
		}
		System.out.println(d);
	}
}


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