Language: C++

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N+10);
  ll sum;
  ll ans = 0;
  ll memo1 = 0;
  ll memo2 = 0;
  ll memo3 = 0;
  for(ll i = 1;i < N+1;i++){
    cin >> A[i];
    A[i] -= i;
    sum += A[i];
  }
  for(ll i = 1;i < N+1;i++){
    memo1 += abs(sum / N - A[i]);
    memo2 += abs((sum/N+1)-A[i]);
    if(sum < 0){
      memo3 += abs((sum/N-1)-A[i]);
    }
  }
  if(sum >= 0){
  ans = min(memo1,memo2);
  cout << ans << endl;
  }else{
    cout << min(memo1,memo3) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   23 |   cin >> N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:24:3: error: 'vector' was not declared in this scope
   24 |   vector<ll> A(N+10);
      |   ^~~~~~
a.cc:24:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:24:12: error: expected primary-expression before '>' token
   24 |   vector<ll> A(N+10);
      |            ^
a.cc:24:14: error: 'A' was not declared in this scope
   24 |   vector<ll> A(N+10);
      |              ^
a.cc:43:9: error: 'min' was not declared in this scope; did you mean 'std::min'?
   43 |   ans = min(memo1,memo2);
      |         ^~~
      |         std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:44:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   44 |   cout << ans << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:44:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   44 |   cout << ans << endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:46:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   46 |     cout << min(memo1,memo3) << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:46:13: error: 'min' was not declared in this scope; did you mean 'std::min'?
   46 |     cout << min(memo1,memo3) << endl;
      |             ^~~
      |             std::min
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:46:33: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   46 |     cout << min(memo1,memo3) << endl;
      |                                 ^~~~
      |                                 std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~