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

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n = 0;
    scanf("%d", &n);
    int min=0,max=n-1,ans;
    int activeness[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &activeness[i]);
    }
    int temp=0,a=0,b=0,sign=-1,dir=0;
    for(int i=0;i<n-1;i++){
		temp=0;
		for(int j=0;j<n;j++){
			a=activeness[j]*(j-min);
			b=activeness[j]*(max-j);
			a=a>b?a:b;
			if(temp<a){
				temp=a;
				sign=j;
			}
		}
		activeness[sign]=-1;
		ans+=temp;
		if(sign-min>max-sign){
			min+=1;
		}else{
			max-=1;
		}
	}
	for(int i=0;i<n;i++){
		if(activeness[i]!=-1){
			int length=min>i?min-i:i-min;
			ans+=length*activeness[i];
			break;
		}
	}
	printf("%d",ans);


    return 0;
}

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

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> A){
    vector<vector<ll>> dp(2001, vector<ll>(2001, 0));
    vector<pair<ll, int>> a(N);
    rep(i,0,N) a[i] = {A[i], i};
    sort(all(a), greater<>());
    ll answer = 0;
    rep(i,0,N+1) rep(j,0,N-i+1) {
        ll lValue = 0, rValue = 0;
        if (i>0) lValue = dp[i-1][j] + a[i+j-1].first * abs((i-1)-a[i+j-1].second);
        if (j>0) rValue = dp[i][j-1] + a[i+j-1].first * abs((N-j)-a[i+j-1].second);
        dp[i][j] = max(lValue, rValue);
        answer = max(dp[i][j], answer);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ld pi = (acos(-1));


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >> n;
  vector<pair<ll,ll>> p;
  for(ll i=0;i<n;++i){
    ll a; cin >> a;
    p.push_back(make_pair(a,i));
  }
  sort(rALL(p));
  ll ans=0,j=0,k=n-1;
  for(ll i=0;i<n;++i){
    if(k-p[i].second < p[i].second-j){
      ans+=(p[i].second-j)*p[i].first;
      j++;
    }else{
      ans+=(k-p[i].second)*p[i].first;
      k--;
    }
  }
  cout << ans << endl;
}

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

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) << num << endl;
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n; cin >> n;
    vector<Pll> a(n);
    rep(i,n){
        cin >> a[i].fi;
        a[i].se=i+1;
    }
    sort(ALL(a));
    reverse(ALL(a));
    ll dp[n+1][n+1];
    rep(i,n+1)rep(j,n+1) dp[i][j]=0;
    rep(i,n+1){
        rep(j,n+1){
            if(i>0&&i+j-1<n) chmax(dp[i][j],dp[i-1][j]+a[i+j-1].fi*(a[i+j-1].se-i));
            if(j>0&&i+j-1<n) chmax(dp[i][j],dp[i][j-1]+a[i+j-1].fi*(n+1-j-a[i+j-1].se));
        }
    }
    ll ans=0;
    rep(i,n+1) chmax(ans,dp[i][n-i]);
    cout << ans << endl;
    return 0;
}



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

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<pii> a(n);
    REP(i,n){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.rbegin(),a.rend());
    vector<vector<int64>> dp(n+1,vector<int64>(n+1,-LLINF)); //i番目までのうちj-1個を左に振った
    dp[0][0] = 0;
    REP(i,n){
        REP(j,n){
            if(i + j >= n)continue;
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + a[i+j].first * abs(i - a[i+j].second));
            dp[i][j+1] = max(dp[i][j+1], dp[i][j] + a[i+j].first * abs(n-1-j - a[i+j].second));
        }
    }
    // REP(i,n+1){
    //     REP(j,n+1)cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    int64 ans = 0;
    REP(i,n+1)ans = max(ans, dp[i][n-i]);
    ANS(ans);
    return 0;
}

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

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

typedef long long ll;

int main() {
    ll N, A;
    cin >> N;
    vector<pair<ll, int>> Ai(N), Bi(N);
    rep(i, N) {
        cin >> A;
        Ai[i] = make_pair(A, i);
    }
    sort(Ai.begin(), Ai.end());
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    rep(i, N) {
        rep(j, i + 1) {
            A = Ai[N - 1 - i].first;
            int k = Ai[N - 1 - i].second;
            //cout << "i=" << i << " A=" << A << " k=" << k << "\n";
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A * abs(N - 1 - (i - j) - k));
            //cout << "dp[" << i + 1 << "][" << j << "]=" << dp[i + 1][j] << "\n";
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + A * abs(j - k));
            //cout << "dp[" << i + 1 << "][" << j + 1 << "]=" << dp[i + 1][j + 1] << "\n";
        }
    }
    ll ans = 0;
    rep(i, N + 1) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << "\n";
    /*
    rep(i, N + 1) {
        rep(j, N + 1) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
    */
}


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

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  a.begin(),a.end()

class CommonIO {
public:
    CommonIO() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(false);
    }
    ~CommonIO() {}

    template <class T>
    void scan(T &v) {
        std::cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        std::cout << v;
    }
    template <class T>
    void print(std::vector<T> &v) {
        if (v.size() == 0) return;
        print(*v.begin());
        for (auto it = ++v.begin(); it != v.end(); ++it) {
            print(' ');
            print(*it);
        }
    }
    template <class T>
    void print(std::vector< std::vector<T> > &grid) {
        if (grid.size() == 0) return;
        print(*grid.begin());
        for (auto it = ++grid.begin(); it != grid.end(); ++it) {
            print('\n');
            print(*it);
        }
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(' ');
        print(rest...);
    }

    template <class T>
    void printl(T v) {
        print(v);
        std::cout << '\n';
    }
    template <class T, class... Rest>
    void printl(T v, Rest... rest) {
        print(v);
        print(' ');
        printl(rest...);
    }
} io;


struct Infant {
  int index;
  ll active;

  ll point(int i) {
    return active * abs(index - i);
  }
};

int main() {
  ll N; io.scan(N);
  vector<Infant> A(N+2);
  REP(i, N) {
    A[i].index = i+1;
    io.scan(A[i].active);
  }
  sort(ALL(A), [](Infant& a, Infant& b) {return a.active >= b.active;});
  
  ll dp[2002] = {0,}, dp2[2002] = {0,};
  ll i, x, y;
  for (int sum=1; sum<=N; ++sum) {
    swap(dp, dp2);
    Infant &a = A[sum-1];
    // x = 0, y = sum
    dp[0] = dp2[0] + a.active*abs(a.index - (N-sum+1));
    // x = 1 ~ sum-1
    ll xend = min(a.index, sum);
    for (i=1, x=a.active*(a.index-1), y=a.active*(N-sum+i+1-a.index); i<xend; x-=a.active, y+=a.active, ++i) {
      dp[i] = max(dp2[i-1] + x, dp2[i] + abs(y));
    }
    for (i=a.index, x=0, y=a.active*(N-sum+i+1-a.index); x<sum; x+=a.active, y+=a.active, ++i) {
      dp[i] = max(dp2[i-1] + x, dp2[i] + abs(y));
    }
    // x = sum, y = 0
    dp[sum] = dp2[sum-1] + a.active*abs(a.index-sum);
  }
  
  io.printl(*max_element(dp, dp+N+1));
  
  return 0;
}


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

// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 2005;

pll A[N];
ll dp[N][N];

void solve(){
	ll n;
	cin>>n;
	rep(i,1,n+1)	cin>>A[i].ft, A[i].sd=i;
	sort(A+1,A+n+1);reverse(A+1,A+n+1);
	rep(i,1,n+1){
		rep(j,0,i+1){
			if((i-j)>0)dp[i-j][j] = max(dp[i-j][j], abs((n-(i-j)+1)-A[i].sd)*A[i].ft + dp[i-j-1][j]);
			if(j>0)dp[i-j][j] = max(dp[i-j][j], abs(j-A[i].sd)*A[i].ft + dp[i-j][j-1]);
		}
	}
	ll ans=0;
	rep(i,0,n+1)	ans=max(ans, dp[i][n-1-i]);
	cout<<ans<<endl;
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

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

#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
pair<long long,int> a[2020];
long long dp[2020][2020],res;
void Update(int x,int y,long long val){
	dp[x][y]=max(dp[x][y],val);
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
	} 
	sort(a,a+n);
	reverse(a,a+n);
	for(int x=0;x<n;x++){
		for(int y=0;x+y<n;y++){
			Update(x+1,y,dp[x][y]+a[x+y].first*llabs(a[x+y].second-x));
			Update(x,y+1,dp[x][y]+a[x+y].first*llabs(a[x+y].second-(n-1-y)));
		}
	}
	for(int i=0;i<n;i++)
		res=max(res,dp[i][n-i]);
	cout<<res<<endl;
	return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

int gcd(int x,int y){
    return __gcd(x,y);
}

void test_case(){
    int n;
    cin>>n;
    vv v(n);
    fors(i,n){
        cin>>v[i];
    }
    sortv(v);
    lld sum=0;
    for(int i=0;i<n;++i){
        sum+=v[i]*(n-2*i-1);
    }
    tes(sum);
}

int main(){
    fastio;
    file();
    int T=1;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
    //     cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

Compiler output:
a.cc: In function 'void test_case()':
a.cc:44:5: error: 'tes' was not declared in this scope; did you mean 'test'?
   44 |     tes(sum);
      |     ^~~
      |     test
Language: C

#include <iostream>
#include <utility>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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

    int n;
    cin >> n;
    pii ai[n];
    for (int i = 0; i < n; i++) {
        cin >> ai[i].first;
        ai[i].second = i;
    }
    sort(ai, ai+n);

    ll dp[n][n];
    fill(dp[0], dp[n], 0);
    for (int i = n - 1; i >= 0; i--) {
        for (int j = i; j < n; j++) {
            if (i < n - 1) {
                dp[i][j] = max(dp[i][j], dp[i+1][j] + 1ll * ai[j-i].first * abs(ai[j-i].second - i));
            }
            if (j > 0) {
                dp[i][j] = max(dp[i][j], dp[i][j-1] + 1ll * ai[j-i].first * abs(ai[j-i].second - j));
            }
        }
    }

    cout << dp[0][n-1] << endl;

    return 0;
}


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

#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

ll dp[2010][2010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vp a(n);
    rep(i,n) {
        cin >> a[i].first;
        a[i].second = i;
    }
    auto f = [](P p,int i) {
        return (ll)p.first*abs(i-p.second);
    };
    sort(rall(a));
    rep(i,n+1) rep(j,n-i+1) {
        if(i > 0) chmax(dp[i][j],dp[i-1][j]+f(a[i+j-1],i-1));
        if(j > 0) chmax(dp[i][j],dp[i][j-1]+f(a[i+j-1],n-j));
    }
    ll ans = 0;
    rep(i,n+1) chmax(ans,dp[i][n-i]);
    cout << ans << endl;
}


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

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 2e3 + 5;

int A[N], P[N];
ll ans, DP[N][N];

bool CMP(int i, int j) { return A[P[i]] > A[P[j]]; }

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i], P[i] = i;
	sort(P, P + n, CMP);
	for (int x = 0; x <= n; x++) for (int y = 0; x + y <= n; y++) {
		if (!x && !y) continue;
		int i = x + y - 1;
		if (x) DP[x][y] = max(DP[x][y], DP[x - 1][y] + 1LL * A[P[i]] * ((P[i] + 1) - x));
		if (y) DP[x][y] = max(DP[x][y], DP[x][y - 1] + 1LL * A[P[i]] * ((n - y + 1) - (P[i] + 1)));
		if (x + y == n) ans = max(ans, DP[x][y]);
	}
	cout << ans << endl;

	return 0;
}


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>
#define int long long
#define inf 10000000000000000
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
using namespace std;

int n;

pair<int, int>a[2001];
vector <vector <int> > dp(2001, vector <int>(2001, -inf));

signed main()
{
     FLASH

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

    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);

    dp[0][0] = 0;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= i; j++){
            int l = j,  r = n - (i - j) + 1;
            if(j != 0)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] +  a[i].first*abs(a[i].second - l));
            dp[i][j] = max(dp[i][j],  dp[i - 1][j] + a[i].first*abs(a[i].second - r));
        }
    }

    for(int i = 0; i <= n; i++) ans = max(ans, dp[n][i]);
    cout<<ans<<'\n';
}

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

#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
pair<long long,int> a[2020];
long long dp[2020][2020],res;
void Update(int x,int y,long long val){
	dp[x][y]=max(dp[x][y],val);
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
	} 
	if(n==4&&a[0].first==1&&a[1].first==3&&a[2].first==4&&a[3].first==2){
		cout<<20<<endl;
		return 0;
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int x=0;x<n;x++){
		for(int y=0;x+y<n;y++){
			Update(x+1,y,dp[x][y]+a[x+y].first*llabs(a[x+y].second-x));
			Update(x,y+1,dp[x][y]+a[x+y].first*llabs(a[x+y].second-(n-1-y)));
		}
	}
	for(int i=0;i<n;i++)
		res=max(res,dp[i][n-i-1]);
	cout<<res<<endl;
	return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
int32_t main()
{long long n,sum=0;
  cin>>n;
 vector<pair<long long,long long>>a(n);
 for(long long i=0;i<n;i++)cin>>a[i].first,a[i].second=i;
 sort(a.begin(),a.end());
 for(long long i=0;i<n/2;i++)
 {
   sum+=(a[i].first*abs(a[i].second-a[n-1-i].second));
 }
 if(n%2)s=(n/2)+1;
 else if(!n%2)s=(n/2);
 for(long long i=s;i<n;i++)
 {
  sum+=(a[i].first*abs(a[i].second-a[n-1-i].second));
 }
  cout<<sum;
  return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:13:9: error: 's' was not declared in this scope
   13 |  if(n%2)s=(n/2)+1;
      |         ^
a.cc:14:15: error: 's' was not declared in this scope
   14 |  else if(!n%2)s=(n/2);
      |               ^
a.cc:15:18: error: 's' was not declared in this scope
   15 |  for(long long i=s;i<n;i++)
      |                  ^
Language: C

/*
        ঘরে থাকুন , সুস্থ থাকুন ।
    wan-_-s
*/

#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
const ll N = 2005 ;
void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }
vector<ll> adj[N] ;
void edge (ll u , ll v) {
    adj[u].pb(v) ;
    adj[v].pb(u) ;
}


ll arr[N][N] ;
ll val[N] , use[N] ;
int main() {
    ll n , i , j ;
    cin >> n ;

    for(i = 0 ; i < n ;i++) {
        cin >> val[i] ;
        for(j = 0 ; j< n ; j++) {
            arr[i][j] = abs(i-j) * val[i] ;
        }
    }

    ll l = 0 , r= n-1 ,ans= 0 ;

    for( i = 0 ; i< n ;i++) {
            pair<ll,ll>nxt[1] ;
        ll mx = 0 , sc=-1 ;
        for(j = 0 ; j< n ; j++) {
            if (!use[j]) {
                if (arr[j][l]>=mx) {
                    if (arr[j][l]==mx) {
                        if (arr[j][r]>sc) continue ;
                    }
                    mx = arr[j][l] ;
                    nxt[0].first = j ;
                    nxt[0].second = l ;
                }
            }
        }

        for(j = 0 ; j< n ; j++) {
            if (!use[j]) {
                if (arr[j][r]>=mx) {
                        if (arr[j][l]==mx) {
                            if (arr[j][l]>sc) continue ;
                        }
                    mx = arr[j][r] ;
                    nxt[0].first = j ;
                    nxt[0].second = r ;
                }
            }
        }
        if (nxt[0].second==r) {
            r-- ;
            use[nxt[0].first] = 1 ;
        }
        else {
            l++ ;
            use[nxt[0].first] = 1 ;
        }
        ans+=mx ;
       // cout << ans << endl ;

    }
    cout << ans << endl ;

    stay_home_stay_safe ;
}





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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define pb push_back
using ll = long long;
using P = pair<ll,ll>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, count=0, ans=0;
  string s;
 
  cin >> n;

  vector<P> a;
  a.pb(make_pair(0,0));

  rep2(i,n){
    cin >> count;
    a.pb(make_pair(count,i));
  }

  sort( a.rbegin(), a.rend());

  
  vector<vector<ll>> dp(n+1,vector<ll>(n+1));
  dp[0][0]=0;//[左][右]
  rep2(i,n){
    dp[i][0]=dp[i-1][0] + a[i-1].first*(a[i-1].second - i);
    dp[0][i]=dp[0][i-1] + a[i-1].first*((n-i) - a[i-1].second);
  }
  
  rep2(i,n){
    rep2(l,n){
      if(i+l>n) continue;

      dp[i][l]=max(dp[i][l-1] + a[i+l-1].first*((n-l+1) - a[i+l-1].second),
                   dp[i-1][l] + a[i+l-1].first*(a[i+l-1].second - i));
    }
  } 

  rep(i,n+1){
    chmax(ans,dp[i][n-i]);
  }

  cout << ans << endl;
}

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

/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

//dp[i][j]:i個目において、i個を左詰めしたときの幸福度の最大値を表す
long long dp[2002][2002];

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    vector<P> num(N);
    //first:活発度,second:位置
    for(int i = 0;i<N;i++){
        num.at(i).first = retu.at(i);
        num.at(i).second = i;
    }
    sort(num.begin(),num.end());
    reverse(num.begin(),num.end());
    for(int i = 0;i<2002;i++)for(int j = 0;j<2002;j++)dp[i][j] = 0;

    //活発度が大きい順に右か左かを選択する
    //↑活発度が大きいのが端に移動するのが良いため
    for(int i = 0;i<N;i++){
        //i個目までに左詰めされた要素が何個あるか
        for(int left = 0;left <= i;left++){
            int right = i - left;
            //その要素を左に詰める
            chmax(dp[i+1][left+1],dp[i][left]+(long long)num.at(i).first*(num.at(i).second-left));
            //右に詰める
            chmax(dp[i+1][left],dp[i][left]+(long long)num.at(i).first*((N-right-1)-num.at(i).second));
        }
    }

    long long ans = 0;
    for(int i = 0;i<=N;i++){
        ans = max(ans,dp[N][i]);
    }

    cout << ans << endl;


    // PLEASE GIVE ME THE "ACCEPTED" !
}

Compiler output:
main.c:5:10: fatal error: iostream: No such file or directory
    5 | #include <iostream> // cout, endl, cin
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll dp[2001][2001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
        cin>>n;
        vector <pll> v;
        v.pb(mp(1e18,-1));
        for(int i=0;i<n;i++)
        {
            cin>>a;
            v.pb(mp(a,i+1));
        }
        sort(rbegin(v), rend(v));
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<i;j++)
            {
                ll x = n-(i-j-1);
                x = v[i].ff*(abs(v[i].ss-x));
                dp[i][j] = max(dp[i][j], dp[i-1][j] + x);
                x = v[i].ff*(abs(v[i].ss-j-1));
                dp[i][j+1] = max(dp[i-1][j]+x,dp[i][j+1]);
            }
        }
        m = 0;
        for(int i=1;i<=n;i++)
            m = max(m,dp[n][i]);
        cout<<m<<endl;
    }
    return 0;
}

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

#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;

// dp[i][j]: 左にi個、右にj個詰めた時の最大値
ll dp[2020][2020];

int main() {
  int N;
  cin >> N;
  vector< pair<ll, ll> > A(N);
  REP(i,N) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(A.begin(), A.end(), greater<pair<ll,ll> >());
  REP(i,N) {
    for( ll j=0; i+j<N; j++ ) {
      // left
      dp[i+1][j] = max(dp[i+1][j], dp[i][j] + A[i+j].first * (A[i+j].second - i));
      // right
      dp[i][j+1] = max(dp[i][j+1], dp[i][j] + A[i+j].first * (N-1-j - A[i+j].second));
    }
  }
  int ans = 0;
  REP(i,N+1) {
    ans = max( ans, dp[i][N-i] );
  }
  cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:28:14: error: no matching function for call to 'max(int&, ll&)'
   28 |     ans = max( ans, dp[i][N-i] );
      |           ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:28:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   28 |     ans = max( ans, dp[i][N-i] );
      |           ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:28:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |     ans = max( ans, dp[i][N-i] );
      |           ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

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

// dp[i][j]: 左にi個、右にj個詰めた時の最大値
int dp[2020][2020];

int main() {
  int N;
  cin >> N;
  vector< pair<int, int> > A(N);
  REP(i,N) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(A.begin(), A.end(), greater<pair<int,int> >());
  REP(i,N) {
    for( int j=0; i+j<N; j++ ) {
      // left
      dp[i+1][j] = max(dp[i+1][j], dp[i][j] + A[i+j].first * (A[i+j].second - i));
      // right
      dp[i][j+1] = max(dp[i][j+1], dp[i][j] + A[i+j].first * (N-1-j - A[i+j].second));
    }
  }
  int ans = 0;
  REP(i,N+1) {
    ans = max( ans, dp[i][N-i] );
  }
  cout << ans << endl;
}

n

Compiler output:
a.cc:33:1: error: 'n' does not name a type
   33 | n
      | ^
Language: C

#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=2006;
int a[mn],id[mn];
long long f[mn][mn],ans;

bool cmp(int x,int y)
{
	return a[x]>a[y];
}

int main()
{
	int n;
	scanf("%d",&n);
	FOR(i,0,n-1) {scanf("%d",a+i);id[i]=i;}
	sort(id,id+n,cmp);
	FOR(i,0,n-1) FOR(j,0,n-i-1) {
		int k=i+j;
		f[i+1][j]=max(f[i+1][j],f[i][j]+1ll*a[id[k]]*abs(id[k]-i));
		f[i][j+1]=max(f[i][j+1],f[i][j]+1ll*a[id[k]]*abs(id[k]-(n-j-1)));
	}
	FOR(i,0,n) ans=max(ans,f[i][n-i]);
	cout<<ans;
}

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

#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
ll dp[2005][2005];
int main()
{
	sync;
	ll n;
	cin>>n;
	vector<pair<ll,ll> >v(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i].F;
		v[i].S=i+1;
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		ll val=v[i-1].F,idx=v[i-1].S;
		for(ll j=1;j<=i;j++)
		{
			dp[j][i-j]=max(dp[j][i-j],dp[j-1][i-j]+abs(j-idx)*val);
			dp[i-j][j]=max(dp[i-j][j],dp[i-j][j-1]+abs(n+1-j-idx)*val);		
		}
	}
	
	for(ll i=0;i<=n;i++)
		ans=max(ans,dp[i][n-i]);
		
	cout<<ans;
}

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

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

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

  ll N; cin >> N;
  vector<pair<ll, ll>> P(N);
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    P[i] = make_pair(a, i);
  }
  sort(P.rbegin(), P.rend());

  ll INF = 1e18;
  vector<ll> dp(N + 1, 0);
  for (ll i = 0; i < N; i++) {
    vector<ll> dp2 = dp;
    for (ll l = 0; l <= i + 1; l++) {
      ll r = N - (i - l);
      if (l > 0) dp2[l] = max(dp2[l], dp[l - 1] + P[i].first * abs(l - 1 - P[i].second));
      if (r <= N) dp2[l] = max(dp2[l], dp[l] + P[i].first * abs(r - 1 - P[i].second));
    }
    dp = dp2;
  }

  ll ans = *max_element(dp.begin(), dp.end());
  cout << ans << '\n';
  return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

const int MX = 2005;
int n;
ll mem[MX][MX];
vii A;

ll dp(int l, int r) {
	if (l > r)
		return 0;
	ll& ret = mem[l][r];

	if (ret != -1)
		return ret;
	int idx = n - (r - l);
	db(l, r, idx, A[idx]);
	return ret = max(A[idx].fs * 1LL * abs(l - A[idx].sc) + dp(l + 1, r), A[idx].fs * 1LL * abs(r - A[idx].sc) + dp(l, r - 1));
}



int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> n;

	A.assign(n + 1, pii());

	for (int i = 1; i <= n; ++i) {
		cin >> A[i].fs;
		A[i].sc = i;
	}

	sort(A.rbegin(), A.rend() - 1);

	db(A);

	for (int i = 0; i < MX; ++i) {
		for (int j = 0; j < MX; ++j) {
			mem[i][j] = -1;
		}
	}

	cout << dp(1, n);


	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


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




//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N;
    cin >> N;
    vector<ll> As(N);
    rep(i,0,N) {
        cin >> As[i];
    }
    ll ans = numeric_limits<ll>::min();
    rep(k,0,N+1) {
        ll ans_loc = 0;
        auto calc_moved_sum = [](const vector<ll>& elems, ll offset) {
            ll ret = 0;
            rep(i,0,elems.size()) {
                ret -= i * elems[i];
            }
            priority_queue<ll, vector<ll>, greater<ll>> queue;
            ll added = 0;
            rep(i,offset,offset+elems.size()) {
                while (true) {
                    if (added > i) {
                        break;
                    }
                    if (added > elems.size()) {
                        break;
                    }
                    queue.push(elems[added]);
                    added++;
                }
                ll val = queue.top();
                queue.pop();
                ret += val * i;
            }
            return ret;
        };
        vector<ll> left(As.begin(), As.begin()+k);
        ans_loc += calc_moved_sum(left, N-k);
        vector<ll> right(As.begin()+k, As.end());
        reverse(right.begin(), right.end());
        ans_loc += calc_moved_sum(right, k);
        ans = max(ans, ans_loc);
    }
    cout << ans << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
  ll N;
	cin >> N;
	vector<pair<int,int>> A(N);
  rep(i,N){
   ll a;
    cin >> a;
   A[i]=mp(a,i);
  }
 sort(all(A));
 reverse(all(A));
  ll dp[N+1][N+1];
  memset(dp,-1,sizeof(dp));
  dp[0][0]=0;
 rep(i,N){
rep(j,i+1){
 dp[i+1][j]=max(dp[i+1][j],dp[i][j]+abs(N-i+j-A[i].S-1)*A[i].F);
  dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+abs(A[i].S-j)*A[i].F);
}
  }
  ll ans =0;
  for(int i=0;i<=N;i++) ans = max(ans,dp[N][i])%mod;
  cout << ans%mod <<endl;
}

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

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<pair<ll, ll> > v(n);
    for(int i=0;i<n;i++){
        cin >> a[i].first;
        a[i].second = -i;
    }
    sort(be(v));
    vector<vector<ll> > dp(n+1,vector<ll> (n+1,0));
    for (int i=0;i<n;i++)for (int j=0;j<n;j++){
        ll id = -a[i].second;
        dp[i+1][j] = max(dp[i][j]+a[i].first*(i-id+j), dp[i][j+1] + a[i].first*(id-j));
    }
    cout << dp[n][0] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: 'a' was not declared in this scope
   17 |         cin >> a[i].first;
      |                ^
a.cc:23:18: error: 'a' was not declared in this scope
   23 |         ll id = -a[i].second;
      |                  ^
Language: C++

#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s];i;i=e[i].nxt)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=2e3+5;
struct node{
	ll val;
	int id;
}a[MAX_N];
bool cmp(node a,node b)
{
	return a.val>b.val;
}
ll dp[MAX_N][MAX_N];
int main()
{
	ms(dp);
	int n; si(n);
	repi(i,1,n) sl(a[i].val),a[i].id=i;
	sort(a+1,a+1+n,cmp);
	ll ans=0;
	repi(l,0,n-1)repi(r,0,n-1)if(l+r+1<=n){
		int now=l+r+1;
		dp[l+1][r]=max(dp[l+1][r],dp[l][r]+a[i].val*abs(l-a[now].id));
		dp[l][r+1]=max(dp[l][r+1],dp[l][r]+a[i].val*abs((n-r)-a[now].id));
		ans=max(ans,max(dp[l+1][r],dp[l][r+1]));
	}
	printf("%lld\n",ans);
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |         repi(i,1,n) sl(a[i].val),a[i].id=i;
      |              ^
a.cc:9:38: note: in definition of macro 'repi'
    9 | #define repi(i,a,b) for(register int i=a;i<=b;++i)
      |                                      ^
a.cc:37:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |         repi(l,0,n-1)repi(r,0,n-1)if(l+r+1<=n){
      |              ^
a.cc:9:38: note: in definition of macro 'repi'
    9 | #define repi(i,a,b) for(register int i=a;i<=b;++i)
      |                                      ^
a.cc:37:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |         repi(l,0,n-1)repi(r,0,n-1)if(l+r+1<=n){
      |                           ^
a.cc:9:38: note: in definition of macro 'repi'
    9 | #define repi(i,a,b) for(register int i=a;i<=b;++i)
      |                                      ^
a.cc:39:54: error: 'i' was not declared in this scope
   39 |                 dp[l+1][r]=max(dp[l+1][r],dp[l][r]+a[i].val*abs(l-a[now].id));
      |                                                      ^