Language: C++

include "bits/stdc++.h"
 
#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}
 
using namespace std;
using ll = long long;
using P = pair<ll, int>;
 
void Main() {
  int n;
	cin >> n;
  vector<int> A(n);
  vector<P> ord;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
    ord.emplace_back(A[i], i);
	}
 
  vector<ll> dp(n+1, 0);
	sort(ord.begin(), ord.end());
  rep(i, n) {
    rep(l, n - i + 1) {
			int r = l + i;
			const auto &[a, pos] = ord[i];
			dp[l] = max(dp[l] + a * abs(pos - r), dp[l + 1] + a * abs(pos - l));
		}
	}
 
  cout << dp[0] << endl;
}
 
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include "bits/stdc++.h"
      | ^~~~~~~
a.cc:11:11: error: 'pair' does not name a type
   11 | using P = pair<ll, int>;
      |           ^~~~
a.cc: In function 'void Main()':
a.cc:15:9: error: 'cin' was not declared in this scope
   15 |         cin >> n;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | include "bits/stdc++.h"
a.cc:16:3: error: 'vector' was not declared in this scope
   16 |   vector<int> A(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | include "bits/stdc++.h"
a.cc:16:10: error: expected primary-expression before 'int'
   16 |   vector<int> A(n);
      |          ^~~
a.cc:17:10: error: 'P' was not declared in this scope
   17 |   vector<P> ord;
      |          ^
a.cc:17:13: error: 'ord' was not declared in this scope
   17 |   vector<P> ord;
      |             ^~~
a.cc:19:24: error: 'A' was not declared in this scope
   19 |                 cin >> A[i];
      |                        ^
a.cc:23:12: error: expected primary-expression before '>' token
   23 |   vector<ll> dp(n+1, 0);
      |            ^
a.cc:23:14: error: 'dp' was not declared in this scope
   23 |   vector<ll> dp(n+1, 0);
      |              ^~
a.cc:24:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |         sort(ord.begin(), ord.end());
      |         ^~~~
      |         short
a.cc:29:49: error: 'abs' was not declared in this scope
   29 |                         dp[l] = max(dp[l] + a * abs(pos - r), dp[l + 1] + a * abs(pos - l));
      |                                                 ^~~
a.cc:29:33: error: 'max' was not declared in this scope
   29 |                         dp[l] = max(dp[l] + a * abs(pos - r), dp[l + 1] + a * abs(pos - l));
      |                                 ^~~
a.cc:33:3: error: 'cout' was not declared in this scope
   33 |   cout << dp[0] << endl;
      |   ^~~~
a.cc:33:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:33:20: error: 'endl' was not declared in this scope
   33 |   cout << dp[0] << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | include "bits/stdc++.h"
a.cc: In function 'int main()':
a.cc:37:8: error: 'cin' is not a member of 'std'
   37 |   std::cin.tie(nullptr);
      |        ^~~
a.cc:37:8: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:38:8: error: 'std::ios_base' has not been declared
   38 |   std::ios_base::sync_with_stdio(false);
      |        ^~~~~~~~
a.cc:39:8: error: 'cout' is not a member of 'std'
   39 |   std::cout << std::fixed << std::setprecision(15);
      |        ^~~~
a.cc:39:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:21: error: 'fixed' is not a member of 'std'
   39 |   std::cout << std::fixed << std::setprecision(15);
      |                     ^~~~~
a.cc:1:1: note: 'std::fixed' is defined in header '<ios>'; this is probably fixable by adding '#include <ios>'
  +++ |+#include <ios>
    1 | include "bits/stdc++.h"
a.cc:39:35: error: 'setprecision' is not a member of 'std'
   39 |   std::cout << std::fixed << std::setprecision(15);
      |                                   ^~~~~~~~~~~~
a.cc:1:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
  +++ |+#include <iomanip>
    1 | include "bits/stdc++.h"