Language: C++

include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    vector<pair<long long, int>> A(N+1);
    A.at(0).first = 0;
    for (long long i = 1; i < N+1; i++){
        A.at(i).second= i;
        cin >> A.at(i).first;
    }
    sort(A.begin() + 1, A.end(), greater<pair<long long, int>>() );
    vector<vector<long long>> dp(N+1, vector<long long> (N+1));
    dp.at(0).at(0) = 0;
    for (int xy = 1; xy < N+1; xy++){
        for (int x = 1; x < xy; x++){
            dp.at(x).at(xy-x) = max( dp.at(x-1).at(xy-x) + A.at(xy).first * abs( A.at(xy).second - x ) , 
                                  dp.at(x).at(xy-x-1) + A.at(xy).first * abs( A.at(xy).second - N + xy - x - 1 ));
        }
        dp.at(0).at(xy) = dp.at(0).at(xy-1) + A.at(xy).first * abs( A.at(xy).second - N + xy - 1 );
        dp.at(xy).at(0) = dp.at(xy-1).at(0) + A.at(xy).first * abs( A.at(xy).second - xy );
    }
    long long ans = 0;
    for (int i = 0; i <= N; i++){
        ans = max(ans, dp.at(i).at(N-i));
    }
    printf("%lld\n", ans);
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> N;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<pair<long long, int>> A(N+1);
      |     ^~~~~~
a.cc:6:12: error: 'pair' was not declared in this scope
    6 |     vector<pair<long long, int>> A(N+1);
      |            ^~~~
a.cc:6:17: error: expected primary-expression before 'long'
    6 |     vector<pair<long long, int>> A(N+1);
      |                 ^~~~
a.cc:7:5: error: 'A' was not declared in this scope
    7 |     A.at(0).first = 0;
      |     ^
a.cc:12:34: error: 'greater' was not declared in this scope
   12 |     sort(A.begin() + 1, A.end(), greater<pair<long long, int>>() );
      |                                  ^~~~~~~
a.cc:12:47: error: expected primary-expression before 'long'
   12 |     sort(A.begin() + 1, A.end(), greater<pair<long long, int>>() );
      |                                               ^~~~
a.cc:12:58: error: expected primary-expression before 'int'
   12 |     sort(A.begin() + 1, A.end(), greater<pair<long long, int>>() );
      |                                                          ^~~
a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |     sort(A.begin() + 1, A.end(), greater<pair<long long, int>>() );
      |     ^~~~
      |     short
a.cc:13:19: error: expected primary-expression before 'long'
   13 |     vector<vector<long long>> dp(N+1, vector<long long> (N+1));
      |                   ^~~~
a.cc:14:5: error: 'dp' was not declared in this scope
   14 |     dp.at(0).at(0) = 0;
      |     ^~
a.cc:17:77: error: 'abs' was not declared in this scope
   17 |             dp.at(x).at(xy-x) = max( dp.at(x-1).at(xy-x) + A.at(xy).first * abs( A.at(xy).second - x ) ,
      |                                                                             ^~~
a.cc:17:33: error: 'max' was not declared in this scope
   17 |             dp.at(x).at(xy-x) = max( dp.at(x-1).at(xy-x) + A.at(xy).first * abs( A.at(xy).second - x ) ,
      |                                 ^~~
a.cc:20:64: error: 'abs' was not declared in this scope
   20 |         dp.at(0).at(xy) = dp.at(0).at(xy-1) + A.at(xy).first * abs( A.at(xy).second - N + xy - 1 );
      |                                                                ^~~
a.cc:25:15: error: 'max' was not declared in this scope
   25 |         ans = max(ans, dp.at(i).at(N-i));
      |               ^~~
a.cc:27:5: error: 'printf' was not declared in this scope
   27 |     printf("%lld\n", ans);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | include <bits/stdc++.h>