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

#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    ll a[n], x, ans = 0, sum = 0;
    for (ll i = 0; i < n; i++) {
        cin >> x;
        a[i] = x - i - 1;
    }
    sort(a.begin(), a.end());
    ll mid = (n % 2 ? a[n / 2] : a[n / 2 - 1]);
    for (ll i = 0; i < n; i++) {
        ans += abs(a[i] - mid);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:12: error: request for member 'begin' in 'a', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   29 |     sort(a.begin(), a.end());
      |            ^~~~~
a.cc:29:23: error: request for member 'end' in 'a', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   29 |     sort(a.begin(), a.end());
      |                       ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= (i+1);
    }

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

    if(n % 2 == 1) {
        ll res = 0;
        ll b = a[n/2];
        REP(i,n) {
            res += abs(a[i] - b);
        }
    } else {
        ll res  = 0;
        ll b1 = a[n/2];
        REP(i,n) {
            res  += abs(a[i] - b1);
        }
        ll res2 = 0;
        ll b2 = a[n/2 - 1];
        REP(i,n) {
            res2 += abs(a[i] - b2);
        }
        ll res = min(res1, res2);
    }

    cout << res << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:12: error: redeclaration of 'll res'
   43 |         ll res = min(res1, res2);
      |            ^~~
a.cc:33:12: note: 'll res' previously declared here
   33 |         ll res  = 0;
      |            ^~~
a.cc:43:22: error: 'res1' was not declared in this scope; did you mean 'res2'?
   43 |         ll res = min(res1, res2);
      |                      ^~~~
      |                      res2
a.cc:46:13: error: 'res' was not declared in this scope
   46 |     cout << res << endl;
      |             ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int n;
int main(){
    cin >> n;
    vector<long> A(n);
    rep(i,n) cin >> A[i];
    rep(i,n) A[i] -= i+1;
    sort(ALL(A));
    int mid = A[n/2];
    
    long sum = 0;
    rep(i,n) sum += abs(A[i]-mid);
    cout << min(sum,sum2) << endl;
    
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: 'sum2' was not declared in this scope; did you mean 'sum'?
   20 |     cout << min(sum,sum2) << endl;
      |                     ^~~~
      |                     sum
Language: C

#include <stdio.h>
#include <stdlib.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int cmp(const void *x, const void *y);

int a[2 * 100005];

int main()
{
	int n;
	int ans = 0;

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

		a[i] -= i;
	}

	qsort(a + 1, n, sizeof(int), cmp);

	for (int i = 1; i <= n; i++) {
		ans += min(abs(a[i] - a[n / 2 + 1], abs(a[i] - a[n / 2]));
	}

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

	return 0;
}

int cmp(const void *x, const void *y)
{
	if (*(int *)x > *(int *)y) {
		return 1;
	} else if (*(int *)x == *(int *)y) {
		return 0;
	} else {
		return -1;
	}
}


Compiler output:
main.c: In function 'main':
main.c:41:2: error: unterminated argument list invoking macro "min"
   41 | }
      |  ^
main.c:24:24: error: 'min' undeclared (first use in this function); did you mean 'main'?
   24 |                 ans += min(abs(a[i] - a[n / 2 + 1], abs(a[i] - a[n / 2]));
      |                        ^~~
      |                        main
main.c:24:24: note: each undeclared identifier is reported only once for each function it appears in
main.c:24:27: error: expected ';' at end of input
   24 |                 ans += min(abs(a[i] - a[n / 2 + 1], abs(a[i] - a[n / 2]));
      |                           ^
      |                           ;
......
main.c:24:17: error: expected declaration or statement at end of input
   24 |                 ans += min(abs(a[i] - a[n / 2 + 1], abs(a[i] - a[n / 2]));
      |                 ^~~
main.c:24:17: error: expected declaration or statement at end of input
Language: C++

import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int [] s = new int[n];
        long d = 0;
        for(int i = 0;i < n;i ++) {
            s[i] = in.nextInt();
            s[i] -= i + 1;
        }
        Arrays.sort(s);
        for(int i = 0;i < n;i ++) {
            d += Math.abs(s[i] - s[n / 2]);
        }
        System.out.println(d);
    }
}

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

#include <iostream>

#define int long long

using namespace std;

signed main()
{
	int n;
	int a[200000];
	int sum[200001] = { 0 };

	cin >> n;

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

	sort(a, a + n);

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

	/*
	for(int i = 0; i < n; ++i)
	{
		cout << a[i] << " ";
	}
	cout << endl;

	for(int i = 0; i <= n; ++i)
	{
		cout << sum[i] << " ";
	}
	cout << endl;
	*/
	
	//cout << sum[n] - sum[3] << endl;
	//cout << sum[n] - sum[4] << endl;

	//cout << "ans" << endl;

	int d = 1LL << 60LL;

	//cout << d << endl;

	for(int i = 0; i < n; ++i)
	{
		int b = a[i];
		int leftD = (i * b) - (sum[i]);
		int rightD = (sum[n] - sum[i + 1]) - (n - 1 - i) * b;
		/*
		if(d > leftD + rightD)
		{
			cout << i << " : " << leftD << " " << rightD << endl;
		}
		*/
		d = min(d, leftD + rightD);
	}

	cout << d << endl;
}

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

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

int get_sum(int b, vector<int> A, int N);

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; ++i){
    cin >> A[i];
  }

  int b;
  int min_b;
  int sum_b;
  int min_sum_b = INT_MAX;

  for(b=-N; b <= N; ++b){
    sum_b = get_sum(b, A, N);
    //cout << sum_b << endl;
    if(min_sum_b > sum_b){
      min_sum_b = sum_b;
      min_b = b;
    }
  }

  cout << min_sum_b << endl;
  return 0;
}

int get_sum(int b, vector<int> A, int N){
  int sum = 0;
  for(int i=0; i < N; i++){
    sum += abs(A[i]-(b+i+1));
  }
  return sum;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: 'INT_MAX' was not declared in this scope
   22 |   int min_sum_b = INT_MAX;
      |                   ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<cmath>
  +++ |+#include <climits>
    6 | using namespace std;
Language: C++

#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <functional>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
 int n,sum=0; cin >> n;
  int a[n],b[n]; 
  rep(i,n){
    cin >> a[i];
    b[i] = a[i] - i + 1;
    sum += b[i];
  }
  int ans1=0,ans2=0,ans2=0;
  rep(j,n){
    ans1 += abs(b[j] - sum/n);
  }
  rep(k,n){
    ans2 += abs(b[k] - sum/n + 1);
  }
  rep(m,n){
    ans3 += abs(b[m] - sum/n - 1);
  }
  int ans;
  ans = min(ans1,ans2);
  ans = min(ans,ans3);
  cout << ans;
      
   
  
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:21: error: redeclaration of 'int ans2'
   25 |   int ans1=0,ans2=0,ans2=0;
      |                     ^~~~
a.cc:25:14: note: 'int ans2' previously declared here
   25 |   int ans1=0,ans2=0,ans2=0;
      |              ^~~~
a.cc:33:5: error: 'ans3' was not declared in this scope; did you mean 'ans2'?
   33 |     ans3 += abs(b[m] - sum/n - 1);
      |     ^~~~
      |     ans2
a.cc:37:17: error: 'ans3' was not declared in this scope; did you mean 'ans'?
   37 |   ans = min(ans,ans3);
      |                 ^~~~
      |                 ans
Language: C++

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

int main() {
 ll n; cin>>n;
  ll v[n];
  rep(i, n){
    cin>>v[i];
    v[i]-=i+1;
  }
    ll sum=0;
  rep(i, n){
    sum+=v[i];}
  if(sum-(sum/n)*n>=abs(sum-(sum/n)*n-n)){
    cout<<abs(sum-(sum/n)*n-n)<<endl;
    else cout<<sum-(sum/n)*n<<endl;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: expected '}' before 'else'
   19 |     else cout<<sum-(sum/n)*n<<endl;
      |     ^~~~
a.cc:17:42: note: to match this '{'
   17 |   if(sum-(sum/n)*n>=abs(sum-(sum/n)*n-n)){
      |                                          ^
Language: C++

#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long 
using namespace std;

int main(){
  int N;
  cin>>N;
  int64 A[N],a[N];
  rep(i,N){
    cin>>A[i];
    a[i]=A[i]-i;
  }
  sort(a,a+N);
  int64 center=floor((N-1)/2);
  int64 min=0;
  rep(i,N){
    min+=abs(a[center]-a[i])
  }
  cout<<min<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:29: error: expected ';' before '}' token
   24 |     min+=abs(a[center]-a[i])
      |                             ^
      |                             ;
   25 |   }
      |   ~
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  cioacc();
  int n;
  cin >> n;
  vl a(n);
  REP(i,n){
    int in;
    cin >> in;
    a.at(i) = in -i-1;
  }
  sort(ALL(a));
  int md = a.at((n-1)/2);
  REP(i,n) a.at(i) -= md;
  cout << accumulate(ALL(a),0LL,[](int left,int right){return left+abs(right-md);}) << endl;
}

Compiler output:
a.cc: In lambda function:
a.cc:35:78: error: 'md' is not captured
   35 |   cout << accumulate(ALL(a),0LL,[](int left,int right){return left+abs(right-md);}) << endl;
      |                                                                              ^~
a.cc:35:34: note: the lambda has no capture-default
   35 |   cout << accumulate(ALL(a),0LL,[](int left,int right){return left+abs(right-md);}) << endl;
      |                                  ^
a.cc:33:7: note: 'll md' declared here
   33 |   int md = a.at((n-1)/2);
      |       ^~
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  cioacc();
  int n;
  cin >> n;
  vl a(n);
  REP(i,n){
    int in;
    cin >> in;
    a.at(i) = in -i-1;
  }
  sort(ALL(a));
  int md = a.at((n-1)/2);
  cout << accumulate(ALL(a),0LL,[](int left,int right){return left+abs(right-md);}) << endl;
}

Compiler output:
a.cc: In lambda function:
a.cc:34:78: error: 'md' is not captured
   34 |   cout << accumulate(ALL(a),0LL,[](int left,int right){return left+abs(right-md);}) << endl;
      |                                                                              ^~
a.cc:34:34: note: the lambda has no capture-default
   34 |   cout << accumulate(ALL(a),0LL,[](int left,int right){return left+abs(right-md);}) << endl;
      |                                  ^
a.cc:33:7: note: 'll md' declared here
   33 |   int md = a.at((n-1)/2);
      |       ^~
Language: C++

#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll a[200000];
int main() {
  ll n, sum=0;
  cin >> n;
  int sum = 0;
  rep(i, n) {
    cin >> a[i];
    b[i] = a[i] - (i + 1);
    sum += b[i];
  }
  sort(b, b+n);
  int m;
  if(n%2)
    m = b[n/2];
  else
    m =  (b[n/2-1] + b[n/2])/2;
  ll ans = sum + m*n;
  cout << ans << endl;
  

}



Compiler output:
a.cc: In function 'int main()':
a.cc:34:7: error: conflicting declaration 'int sum'
   34 |   int sum = 0;
      |       ^~~
a.cc:32:9: note: previous declaration as 'll sum'
   32 |   ll n, sum=0;
      |         ^~~
a.cc:37:5: error: 'b' was not declared in this scope
   37 |     b[i] = a[i] - (i + 1);
      |     ^
a.cc:40:8: error: 'b' was not declared in this scope
   40 |   sort(b, b+n);
      |        ^
Language: C++

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

ll n;
vector<ll> a;

ll solve() {
  ll i;
  ll b, ans = 0;

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

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

  if (n % 2 == 0) {
    b = (a[n / 2 - 1] + a[n / 2]) / 2;
  } else {
    b = a[(n - 1) / 2];
  }

  for (i = 0; i < n; i++) {
    ans += _abs64(a[i] - b);
  }

  return ans;
}

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

  cout << solve() << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'll solve()':
a.cc:25:12: error: '_abs64' was not declared in this scope; did you mean 'fabsf64'?
   25 |     ans += _abs64(a[i] - b);
      |            ^~~~~~
      |            fabsf64
Language: C++

#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	cin >> N;
	vector<ll>A(N + 1);
	for (int i = 1; i <= N; i++) {
		int a;
		scanf_s("%d", &a);
		A[i] = a - i;
	}
	sort(A.begin() + 1, A.end());
	int b = A[N / 2 + 1];
	for (int i = 1; i <= N; i++) {
		ans += abs(A[i] - b);
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   15 |                 scanf_s("%d", &a);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<deque>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;


int main(){

  int n;std::cin >> n;
  int tmp;
  std::vector<int> b;
  rep(i,0,n){
    std::cin >> tmp;
    b[i] = tmp-(i+1);
  }
  sort(all(b));
  med = b[(n-1)/2];
  int res = 0;
  rep(i,0,n){
    res += abs(b[i]-med);
  }
  std::cout << res << '\n';

}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:3: error: 'med' was not declared in this scope
   35 |   med = b[(n-1)/2];
      |   ^~~
Language: C++

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<deque>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;

int n;
int a[200100];
int b[200100];
std::vector<int> v;

int calc(int a, int b, int i){
  return abs(a-(b-i));
}

int main(){
  std::cin >> n;
  rep(i,1,n+1){
    std::cin >> a[i];
    b[i] = a[i]-i;
  }
  sort(b+1,b+n+1);
  int index = (n+1)/2;
  int opt_b = b[index];
  int res = 0;
  rep(i,1,n+1){
    res += abs(b[i]-opt_b);
  }
  int tmp = 0;
  rep(i,1,n+1){
    tmp += abs(b[i]-opt_b+1);
  }
  res = min(res, tmp);
  int tmp = 0;
  rep(i,1,n+1){
    tmp += abs(b[i]-opt_b-1);
  }
  res = min(res, tmp);

  std::cout << res << '\n';

}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:7: error: redeclaration of 'int tmp'
   51 |   int tmp = 0;
      |       ^~~
a.cc:46:7: note: 'int tmp' previously declared here
   46 |   int tmp = 0;
      |       ^~~
Language: C++

#include <iostream>
int main(void) {
	const int maxn = 200005;
	long long n, d, k;
	std::vector<long long> a(maxn);
	std::cin >> n;
	for (int i = 1; i <= n; i++) {
		std::cin >> a[i];
		a[i] -= i;
	}
	std::sort(a.begin(), a.end());
	long long b = 0;
	if (n % 2 == 0)
		b = (a[n / 2] + a[n / 2 + 1]) / 2;
	else
		b = a[n / 2 + 1];
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = ans + abs(b - a[i]);
	}
	std::cout << ans << std::endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:14: error: 'vector' is not a member of 'std'
    5 |         std::vector<long long> a(maxn);
      |              ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | int main(void) {
a.cc:5:21: error: expected primary-expression before 'long'
    5 |         std::vector<long long> a(maxn);
      |                     ^~~~
a.cc:8:29: error: 'a' was not declared in this scope
    8 |                 std::cin >> a[i];
      |                             ^
a.cc:11:14: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   11 |         std::sort(a.begin(), a.end());
      |              ^~~~
      |              qsort
a.cc:11:19: error: 'a' was not declared in this scope
   11 |         std::sort(a.begin(), a.end());
      |                   ^
Language: C++

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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0 ; i < N; i++) {
        int a;
        cin >> a;
        v[i] = a - i;
    }

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

    int ans1, ans2;
    for(int i = 0; i < N; i++) {
        ans1 += abs(v[i] - v[N/2]);
        ans2 += abs(v[i] - v[N/2+1]);
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}  

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

#include<stdio.h>
#include<stdlib.h>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define INF 2000000000

int int_sort( const void * a , const void * b ) {
  /* 引数はvoid*型と規定されているのでint型にcastする */
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}

int main(){
		int n;
		long a[200000],ans=0,ans2=0,minimum=INF,maximum=0,i,sc=0,sc2=INF;
		scanf("%d",&n);
		for(i=0;i<n;i++){
				scanf("%ld",&a[i]);
				a[i]-=(i+1);
		}
		qsort(a,n,sizeof(long),compare_int);
		if(n%2==1)sc=a[n/2-1];
		else {
				sc=a[n/2-1];
				sc2=a[n/2-2];
		}
		for(i=0;i<n;i++){
				ans+=abs(a[i]-sc);
				if(n%2==0)ans2+=abs(a[i]-sc2);
		}
		if(n%2==1)printf("%ld\n",ans);
		else {
				printf("%ld\n",min(ans,ans2));
		}
		return 0;
}


Compiler output:
main.c: In function 'main':
main.c:28:40: error: 'compare_int' undeclared (first use in this function)
   28 |                 qsort(a,n,sizeof(long),compare_int);
      |                                        ^~~~~~~~~~~
main.c:28:40: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

int N; cin >> N;
    ll a, idx = 1; vl as(N + 1, 0), rs(N + 1, 0);
    while (cin >> a) {
        as[idx] = a;
        rs[idx] = a - idx;
        idx++;
    }
    
    sort(rs.begin() + 1, rs.end(), greater<ll>());
    ll ret = LINF;
    ll b1 = rs[N / 2];
    ll b2 = rs[N / 2 + 1];
    auto getKanashimi = [&](const ll b){
        ll tmp = 0;
        for (int i = 1; i <= N; i++) {
            tmp += abs(as[i] - (b + i));
        }
        return tmp;
    };
    
    ret = min(ret, getKanashimi(b1));
    ret = min(ret, getKanashimi(b2));
    cout << ret << endl;
    return 0;

Compiler output:
a.cc:1:8: error: 'cin' does not name a type
    1 | int N; cin >> N;
      |        ^~~
a.cc:2:5: error: 'll' does not name a type
    2 |     ll a, idx = 1; vl as(N + 1, 0), rs(N + 1, 0);
      |     ^~
a.cc:2:20: error: 'vl' does not name a type
    2 |     ll a, idx = 1; vl as(N + 1, 0), rs(N + 1, 0);
      |                    ^~
a.cc:3:5: error: expected unqualified-id before 'while'
    3 |     while (cin >> a) {
      |     ^~~~~
a.cc:9:9: error: expected constructor, destructor, or type conversion before '(' token
    9 |     sort(rs.begin() + 1, rs.end(), greater<ll>());
      |         ^
a.cc:10:5: error: 'll' does not name a type
   10 |     ll ret = LINF;
      |     ^~
a.cc:11:5: error: 'll' does not name a type
   11 |     ll b1 = rs[N / 2];
      |     ^~
a.cc:12:5: error: 'll' does not name a type
   12 |     ll b2 = rs[N / 2 + 1];
      |     ^~
a.cc:13:26: error: non-local lambda expression cannot have a capture-default
   13 |     auto getKanashimi = [&](const ll b){
      |                          ^
a.cc:13:35: error: 'll' does not name a type
   13 |     auto getKanashimi = [&](const ll b){
      |                                   ^~
a.cc:19:6: error: expected ')' before ';' token
   19 |     };
      |      ^
      |      )
a.cc:13:28: note: to match this '('
   13 |     auto getKanashimi = [&](const ll b){
      |                            ^
a.cc: In lambda function:
a.cc:19:6: error: expected '{' before ';' token
   19 |     };
      |      ^
a.cc: At global scope:
a.cc:21:5: error: 'ret' does not name a type
   21 |     ret = min(ret, getKanashimi(b1));
      |     ^~~
a.cc:22:5: error: 'ret' does not name a type
   22 |     ret = min(ret, getKanashimi(b2));
      |     ^~~
a.cc:23:5: error: 'cout' does not name a type
   23 |     cout << ret << endl;
      |     ^~~~
a.cc:24:5: error: expected unqualified-id before 'return'
   24 |     return 0;
      |     ^~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
 
ll lmin(ll x,ll y){
  if(x<y) return x;
  else return y;
}
 
int main(){
  ll n;
  cin >>n;
  ll a[n];
  ll ans=10010000000;
  rep(i,n){
    cin >> a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  ll b=a[n/2];
  ll res =0;
  rep(j,n)res+=abs(a[j]-b[h]);
  ans=lmin(res,ans);
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:27: error: 'h' was not declared in this scope
   25 |   rep(j,n)res+=abs(a[j]-b[h]);
      |                           ^
Language: C++

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

int main(){
    int N; cin >> N;
    int A[200010];
    for(int i=0; i<N; ++i){
        cin >> A[i];
        A[i] -= i+1;
    }
    sort(A, A+N);
    int P=N/2
    long S=0;
    for(int i=0; i<N; ++i) S += abs(A[i]-A[P]);
    cout << S << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: expected ',' or ';' before 'long'
   14 |     long S=0;
      |     ^~~~
a.cc:15:28: error: 'S' was not declared in this scope
   15 |     for(int i=0; i<N; ++i) S += abs(A[i]-A[P]);
      |                            ^
a.cc:16:13: error: 'S' was not declared in this scope
   16 |     cout << S << endl;
      |             ^
Language: C++


#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;



int main(){
	
	int n,a[222222];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a,a+n);
	int num;
	if(n%2==0)num=a[n/2-1];
	else num=a[n/2];
		
	llt ans=0;
	for(int i=0;i<n;i++){
		ans+=abs(a[i]-num);
	}
	cout<<ans<<endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'llt' was not declared in this scope; did you mean 'll'?
   45 |         llt ans=0;
      |         ^~~
      |         ll
a.cc:47:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |                 ans+=abs(a[i]-num);
      |                 ^~~
      |                 abs
a.cc:49:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   49 |         cout<<ans<<endl;
      |               ^~~
      |               abs
Language: C++


#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;



int main(){
	
	int n,a[222222];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a,a+n);
	int num;
	if((n-1)%2==0)num=a[(n-1)/2];
	else num=round((a[(n-1)/2]+a[(n-1)/2+1])/2);
		
	int ans=0
	for(int i=0;i<n;i++){
		ans+=abs(a[i]-num);
	}
	cout<<ans<<endl;
		
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:9: error: expected ',' or ';' before 'for'
   46 |         for(int i=0;i<n;i++){
      |         ^~~
a.cc:46:21: error: 'i' was not declared in this scope
   46 |         for(int i=0;i<n;i++){
      |                     ^
Language: C++


#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;



int main(){
	
	int n,a[222222];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a,a+n);
	int num=a[(n-1)/2)];
	int ans=0;
	for(int i=0;i<n;i++){
		ans+=abs(a[i]-num);
	}
	cout<<ans<<endl;
		
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:26: error: expected ']' before ')' token
   41 |         int num=a[(n-1)/2)];
      |                          ^
      |                          ]
a.cc:41:26: error: expected ',' or ';' before ')' token
Language: C++

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
int n;
ll a[210000];
int main()
{
    cin>>n;
    for (int i=0; i<n; ++i)
    {
        cin>>a[i];
        a[i]-=(i+1);
    }
    sort(a,a+n);
    ll b=a[n/2];
    ll s=0;
    for (int i=0; i<n; ++i)
        s+=abs(a[i]-b);
    cout<<s<<endl;
    return 0;
}



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

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

int main() {
    ll n; cin >> n;
    ll a[20001];
    ll ans = 0;
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        a[i] -= (i + 1);
    }
    sort(a, a + n);
    ll num = a[n/2];
    rep(i, n){
        ans += abs(a[i] - num);
    }
    cout << ans << endl;
    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const int INF = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N;
    cin >> N;
    vector<LL> a(N);
    int min = INF;
    REP(i,N)
    {
        LL tmp;
        cin >> tmp;
        a[i] = tmp - i - 1;
        dump(a[i])
        if(a[i] < min) min = a[i];
    }
    if(min < 0)
    {
        REP(i,N)
        {
            a[i] -= min;
            dump(a[i])
        }
    }
    LL sum = 0;
    REP(i,N)
    {
        sum += a[i];
    }

    LL avel = (sum + N - 1) / N;
    LL aves = sum / N;
    dump(avel)
    dump(aves)
    LL resl = 0, ress = 0;
    REP(i,N)
    {
        resl += abs(a[i] - avel);
        ress += abs(a[i] - aves);
    }
    LL res = min(resl,ress);
    cout << res << endl;

}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:89:17: error: 'min' cannot be used as a function
   89 |     LL res = min(resl,ress);
      |              ~~~^~~~~~~~~~~
Language: C++

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

int N, A[200005];

int main() {
    cin >> N;
    for(i=0;i<N;i++) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A, A + N);

    int b = A[N / 2];

    int ans = 0;
    for(i=0;i<N;i++) { ans += abs(A[i] - b); }
    cout << ans << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'i' was not declared in this scope
   10 |     for(i=0;i<N;i++) {
      |         ^
a.cc:19:9: error: 'i' was not declared in this scope
   19 |     for(i=0;i<N;i++) { ans += abs(A[i] - b); }
      |         ^
Language: Java

import java.util.*;

public class Main(){
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int[] A=new int[N];
    for(int i=0;i<N;i++){    
      A[i] = sc.nextInt();
    }
    
    int num=0;
    int num_tmp=0;
    
    for(int b=0;b<N;b++){
      for(int i=0;i<N;i++){
        num_tmp+=Math.abs(A[i]-(b+i));
      }
      if(num==0 || num>num_tmp){
        num=num_tmp;
      }
    }
    
    System.out.println(num);
    
  }
}


Compiler output:
Main.java:3: error: '{' expected
public class Main(){
                 ^
1 error
Language: Java

import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A[] = new int[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		int num = 0, min = 10000;

		for (int i = 0-N; i < N; i++) {
			num=0;
			for (int j = 0; j < N; j++) {
				num += Math.abs(A[j] - (i + (j + 1)));
			}
			min=Math.min(min, num);
		}
		System.out.println(min);

	}

Compiler output:
Main.java:26: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n;
  cin>>n;
  vector<int> v;
  REP(i,n){
    int x;
    v.pb(x-i-1);
  }

  VSORT(v);

  cout<<v[v.sizse()/2]<<endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:13: error: 'class std::vector<int>' has no member named 'sizse'; did you mean 'size'?
   32 |   cout<<v[v.sizse()/2]<<endl;
      |             ^~~~~
      |             size
Language: C++

{
    int n;
    cin >> n;
    long long ans =0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        a[i]=x-i-1;
    }
    sort(a.begin(),a.end());
    int p;
    if(n%2==0){
       p = (a[n/2]+a[n/2-1])/2;
    }else{
       p = a[n/2];
    }
    for(int j=0;j<n;j++){
        ans = ans+ abs(a[j]-p);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:1:1: error: expected unqualified-id before '{' token
    1 | {
      | ^
Language: C++

#include <iostream>
#include<algorithm>

using namespace std;

long long abss(int* A,int n,int b){
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(A[i]-b);
    }
    return ans;
}

int main(){
    
    int n;
    cin>>n;
    long long A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
        A[i]=A[i]-(i+1);
    }

    
   /* for(int i=1;i<n;i++){
        long long v=A[i];
        int j=i-1;
        while(j>=0&&A[j]<v){
            swap(A[j],A[j+1]);
            j--;
        }
        A[j+1]=v;
    }*/
    sort(A,A+n);
    
    long long a;
    if(n%2==1){
        a=A[n/2];
        cout<<abss(A,n,a)<<endl;
        return 0;
    }else{
        long long a=abss(A,n,A[n/2]);
        long long b=abss(A,n,A[(n/2)-1]);
        cout<<min(a,b)<<endl;
    }
    
    //cout<<a<<endl;
 //   int ans=abss(A,n,a);
   // cout<<ans<<endl;

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:20: error: cannot convert 'long long int*' to 'int*'
   39 |         cout<<abss(A,n,a)<<endl;
      |                    ^
      |                    |
      |                    long long int*
a.cc:6:21: note:   initializing argument 1 of 'long long int abss(int*, int, int)'
    6 | long long abss(int* A,int n,int b){
      |                ~~~~~^
a.cc:42:26: error: cannot convert 'long long int*' to 'int*'
   42 |         long long a=abss(A,n,A[n/2]);
      |                          ^
      |                          |
      |                          long long int*
a.cc:6:21: note:   initializing argument 1 of 'long long int abss(int*, int, int)'
    6 | long long abss(int* A,int n,int b){
      |                ~~~~~^
a.cc:43:26: error: cannot convert 'long long int*' to 'int*'
   43 |         long long b=abss(A,n,A[(n/2)-1]);
      |                          ^
      |                          |
      |                          long long int*
a.cc:6:21: note:   initializing argument 1 of 'long long int abss(int*, int, int)'
    6 | long long abss(int* A,int n,int b){
      |                ~~~~~^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
using namespace std;
using ll = long long;
const int INF = 1e8;
int main() {
	int N;
	int A[200001];
	cin >> N;
	vector<int>B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		B[i] += A[i] - (i+1);
	}
	sort(B.begin(), B.end());
	int ans = 0;
	int b;
	
	if (N % 2) {
		b = B[N / 2];
		for (int i = 0; i < N; ++i) {
			ans += abs(B[i] - b);
		}
		cout << ans << endl;
	}
	else {
		b = round((B[N / 2] + B[N / 2 - 1]) / 2);
		for (int i = 0; i < N; ++i) {
			ans += abs(B[i] - b);
		}
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:21: error: 'round' was not declared in this scope
   30 |                 b = round((B[N / 2] + B[N / 2 - 1]) / 2);
      |                     ^~~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  int n;
  int max=0:
  int ans=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]-=i;
  }
  sort(a,&a[n]);


    for(int i=0;i*2<n;i++){
      ans+=(a[n-1-i]-a[i]);
    }
  
    
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:12: error: expected ',' or ';' before ':' token
    7 |   int max=0:
      |            ^
a.cc:19:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |       ans+=(a[n-1-i]-a[i]);
      |       ^~~
      |       abs
a.cc:23:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C++

#include <bits/stdc++>
using namespace std;
vector<ll> a;
int main(){
    ll n,b;
    cin >> n;
    a.resize(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]-=i;
    }

    sort(a.begin(),a.end());
    if(n%2==1){
        ll med1 = a[n/2];
        ll med2 = a[n/2-1];
        b = (med1+med2)/2;
    }else{
        b=a[n/2];
    }

    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-b);
    }

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

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

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long[] a = new long[n];
		for (long i = 0; i < n; i++) {
			a[i] = sc.nextLong() - i - 1;
		}

		java.util.Arrays.sort(a);

		long b = a[n / 2];

		// System.out.println(Arrays.toString(a));

		long result = 0;
		for (long i = 0; i < n; i++) {
			result += Math.abs(a[i] - b);
		}
		System.out.println(result);
	}
}

Compiler output:
Main.java:7: error: incompatible types: possible lossy conversion from long to int
		long[] a = new long[n];
		                    ^
Main.java:9: error: incompatible types: possible lossy conversion from long to int
			a[i] = sc.nextLong() - i - 1;
			  ^
Main.java:14: error: incompatible types: possible lossy conversion from long to int
		long b = a[n / 2];
		             ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
			result += Math.abs(a[i] - b);
			                     ^
4 errors
Language: C++

#include <iostream>
#include<functional>
using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N, a[200001], b[200001];
	cin >> N;
	for (i = 0; i < N; i++) { cin >> a[i]; a[i] = a[i] - i; }
sort(a,a+N);
	for (i = 0; i < N; i++) {
		ans += llabs(a[i] - a[N / 2]);
	}

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

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

#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N, a[200001], b[200001];
	cin >> N;
	for (i = 0; i < N; i++) { cin >> a[i]; a[i] = a[i] - i; }
sort(a,a+N);
	for (i = 0; i < N; i++) {
		ans += llabs(a[i] - a[N / 2]);
	}

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

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

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int n;
  cin >> n;
  long long sum = 0;
  int a[n];
  int b[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i] - (i+1);
  }
  sort(b,b+n);
  int ans = 0
  for(int i = 0; i < n; i++){
    ans += abs(a[i] - (b[n/2] + i+1) );
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:3: error: expected ',' or ';' before 'for'
   38 |   for(int i = 0; i < n; i++){
      |   ^~~
a.cc:38:18: error: 'i' was not declared in this scope
   38 |   for(int i = 0; i < n; i++){
      |                  ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(logn ll = 0; i < (long)(n); i++)

int main() {

  ll n;
  cin >> n;

  vector<ll> array(n);
  ll tmp = 0;
  REP(i, n){
    cin >> array[i];
    tmp += array[i] - (i + 1);
    //tmp += array[i] - (i + 1);
  }

  //cout << tmp << endl;

  //tmp = round(double(tmp) / double(n));

  //cout << tmp << endl;
  ll tmp1;
  if (tmp > 0) {
    tmp = tmp / n;
    tmp1 = tmp + 1;
  } else {
    tmp = tmp / n;
    tmp1 = tmp - 1;
  }
  //cout << tmp << endl;
  //cout << tmp1 << endl;
  ll sum1 = 0;
  ll sum2 = 0;
  REP(i, n) {
    sum1 += llabs(array[i] - (tmp + i + 1));
    sum2 += llabs(array[i] - (tmp1 + i + 1));
  }
  cout << min(sum1, sum2) << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:23: error: 'logn' was not declared in this scope; did you mean 'long'?
   24 | #define REP(i, n) for(logn ll = 0; i < (long)(n); i++)
      |                       ^~~~
a.cc:33:3: note: in expansion of macro 'REP'
   33 |   REP(i, n){
      |   ^~~
a.cc:33:7: error: 'i' was not declared in this scope
   33 |   REP(i, n){
      |       ^
a.cc:24:36: note: in definition of macro 'REP'
   24 | #define REP(i, n) for(logn ll = 0; i < (long)(n); i++)
      |                                    ^
a.cc:24:23: error: 'logn' was not declared in this scope; did you mean 'long'?
   24 | #define REP(i, n) for(logn ll = 0; i < (long)(n); i++)
      |                       ^~~~
a.cc:56:3: note: in expansion of macro 'REP'
   56 |   REP(i, n) {
      |   ^~~
a.cc:56:7: error: 'i' was not declared in this scope
   56 |   REP(i, n) {
      |       ^
a.cc:24:36: note: in definition of macro 'REP'
   24 | #define REP(i, n) for(logn ll = 0; i < (long)(n); i++)
      |                                    ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int ll = 0; i < (ll)(n); i++)

int main() {

  ll n;
  cin >> n;

  vector<ll> array(n);
  ll tmp = 0;
  REP(i, n){
    cin >> array[i];
    tmp += array[i] - (i + 1);
    //tmp += array[i] - (i + 1);
  }

  //cout << tmp << endl;

  //tmp = round(double(tmp) / double(n));

  //cout << tmp << endl;
  ll tmp1;
  if (tmp > 0) {
    tmp = tmp / n;
    tmp1 = tmp + 1;
  } else {
    tmp = tmp / n;
    tmp1 = tmp - 1;
  }
  //cout << tmp << endl;
  //cout << tmp1 << endl;
  ll sum1 = 0;
  ll sum2 = 0;
  REP(i, n) {
    sum1 += llabs(array[i] - (tmp + i + 1));
    sum2 += llabs(array[i] - (tmp1 + i + 1));
  }
  cout << min(sum1, sum2) << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:7: error: 'i' was not declared in this scope
   33 |   REP(i, n){
      |       ^
a.cc:24:35: note: in definition of macro 'REP'
   24 | #define REP(i, n) for(int ll = 0; i < (ll)(n); i++)
      |                                   ^
a.cc:24:43: error: 'll' cannot be used as a function
   24 | #define REP(i, n) for(int ll = 0; i < (ll)(n); i++)
      |                                       ~~~~^~~
a.cc:33:3: note: in expansion of macro 'REP'
   33 |   REP(i, n){
      |   ^~~
a.cc:56:7: error: 'i' was not declared in this scope
   56 |   REP(i, n) {
      |       ^
a.cc:24:35: note: in definition of macro 'REP'
   24 | #define REP(i, n) for(int ll = 0; i < (ll)(n); i++)
      |                                   ^
a.cc:24:43: error: 'll' cannot be used as a function
   24 | #define REP(i, n) for(int ll = 0; i < (ll)(n); i++)
      |                                       ~~~~^~~
a.cc:56:3: note: in expansion of macro 'REP'
   56 |   REP(i, n) {
      |   ^~~
Language: C++

//2018.09.21

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


int main() {

    int n;
    cin >> n;

    vector<int> a;
    int tmp,maxv=0,minv=2000000000;
    vector<long> diff;
    int i;
    for(i=0;i<n;i++){
        cin >> tmp;
        a.push_back(tmp);
        diff.push_back(a[i]-(i+1));
    }

    std::sort(diff.begin(),diff.end());
    int med = diff[n/2];

    int ans=0;
    for(i=0;i<n;i++){
        ans += abs(a[i]-(med+1+i));
    }

    cout << ans << endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   23 |     std::sort(diff.begin(),diff.end());
      |          ^~~~
      |          qsort