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


#include<bits/stdc++.h>


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
ll a[N];

void solve(int testCase){

    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
            scanf("%lld" , &a[i]);
    }

    vi v(n , 0);
    iota(v.begin() , v.end() , 0);


    int l = 0 , r = n-1;
    for(int i = 0 ; i < n ; i ++){

            int mx = -1;
            int dx = -1;
            for(int j = l ; j <= r ; j ++){
                    ll tmp = a[v[j]];

                    ll cost = tmp * max(abs(v[j] - l) , abs(v[j] - r));
                    if(cost > mx){
                            mx = cost;
                            dx = j;
                    }
            }

            if(dx == -1) break;

            if(abs(v[dx] - l) > abs(v[dx] - r)){
                    swap(v[l] , v[dx]);
                    l ++;
            }
            else {
                    swap(v[r] , v[dx]);
                    r --;
            }
    }

    ll ans = 0;
    for(int i = 0 ; i < n ; i ++){
            for(int j = 0 ; j < n ; j ++){
                    if(v[j] == i){
                            ans += 1ll * abs(i - j) * a[i];
                            break;
                    }
            }
    }

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

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
pair<ll,ll> a[2005];
ll d[2005][2005];
int main(){
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        s.insert(i);
    }
    for(ll i=1;i<=n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=i;j++){
            ll x=n+1-(i-j),p=a[i].second,v=a[i].first;
            if(j==0&&x<n+1) d[j][x]=d[j][x+1]+abs(x-p)*v;
            else if(x==n+1&&j>0) d[j][x]=d[j-1][x]+abs(j-p)*v;
            else d[j][x]=max(d[j][x+1]+abs(x-p)*v,d[j-1][x]+abs(j-p)*v);
            ans=max(ans,d[j][x]);
        }
    }
    cout<<ans<<endl;
}   

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 's' was not declared in this scope
   11 |         s.insert(i);
      |         ^
Language: C

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[2010][2010];

int main() {
    int n; cin >> n;
    vector<pli> a(n);
    rep(i, n) {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(all(a));
    reverse(all(a));
    rep(i, n+1) rep(j, n+1) dp[i][j] = -LLINF;
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, n) {
            chmax(dp[i+1][j+1], dp[i][j] + a[i].first * abs(a[i].second - j));
            chmax(dp[i+1][j], dp[i][j] + a[i].first * abs(a[i].second - (n-i+j-1)));
        }
    }

    ll ans = 0;
    rep(i, n+1) chmax(ans, dp[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

#include <bits/stdc++.h>

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;


struct Infant {
    ll index;
    ll active;
};

queue<P> enu(int n) {
    queue<P> q;
    for (int i = 0; i < n; i++) {
        for (int x = 0; x <= i; x++) {
            q.push({x, i - x});
        }
    }
    return q;
}

int main() {
    int n;
    cin >> n;

    vector<Infant> infants(n);
    rep(i, n) infants[i].index = i;
    rep(i, n) cin >> infants[i].active;

    sort(infants.rbegin(), infants.rend(), [&](Infant i, Infant j) { return i.active < j.active; });

    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
    queue<P> q = enu(n);


    while (!q.empty()) {
        P p = q.front();
        q.pop();
        ll i = p.first + p.second;
        Infant infant = infants[i];
        ll from = dp[p.first][p.second];

        ll to_l = abs(infant.index - p.first) * infant.active;
        ll to_r = abs(infant.index - (n - p.second - 1)) * infant.active;

        cmax(dp[p.first + 1][p.second], from + to_l);
        cmax(dp[p.first][p.second + 1], from + to_r);
    }

    vector<ll> candidate;
    rep(i, n) {
        ll now = *max_element(dp[i].begin(), dp[i].end());
        candidate.push_back(now);
    }
    ll ans = *max_element(candidate.begin(), candidate.end());
    cout << ans << endl;

}

//ll ans = 0;
//rep(i, n) {
//Infant infant = target[i];
//ll diff = abs(infant.index - i);
//ll now = infant.active * diff;
//ans += now;
//}
//return ans;

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;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<" is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

pii a[2009];
ll dp[2009][2009];

ll ans(int i, int st, int en)
{
	if(st>en) return 0;
	if(dp[st][en]!=-1) return dp[st][en];
	ll ans1=ans(i+1,st,en-1)+1LL * a[i].fi * (en-a[i].se);
	ll ans2=ans(i+1,st+1,en)+1LL * a[i].fi * (a[i].se-st);
	return dp[st][en]=max(ans1,ans2);
}

void solve()
{
	int n;
	cin>>n;
	int i;
	for(i=1;i<=n;i++)
	{
		cin>>a[i].fi;
		a[i].se=i;
	}
	memset(dp,-1,sizeof(dp));
	sort(a+1,a+1+n,[](pii x, pii y){return x.fi>y.fi;});
	cout<<ans(1,1,n);
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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 ll long long
#define endl '\n'
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define mod 1000009
#define line cout<<"--------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
vector<pair<ll ,ll > > v;
ll  n;
ll  dp[2009][2009];
ll  call(ll  ind, ll  pre)
{
    if(ind==v.size()) return 0;
    ll  ses=n-1-(ind-pre);
    ll  &ret=dp[ind][pre];
    if(ret!=-1) return ret;
    ll  a=0,b=0;
    a=v[ind].first*(v[ind].second-pre)+call(ind+1,pre+1) ;
    b=v[ind].first*(ses-v[ind].second)+call(ind+1,pre) ;
    return ret=max(a,b);
}
int   main()
{
    memset(dp,-1,sizeof dp );
    cin>>n;
    for(ll  i=0;i<n;i++)
    {
        int x; cin>>x;
        v.pb(mp(x,i));
    }
    sort(v.rbegin(),v.rend());
    cout<<call(0,0)<<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 <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	vb c(n,true) ;
	ll r = n-1 ;
	ll ans = 0 ;
	while(r>=0){
		ll R=0 ;
		ll pos = 0 ;
		for(int i=0;i<n;i++){
			if(!c.at(i)) continue ;
			if(R<a.at(i)*sa(i,r)){
				R = a.at(i)*sa(i,r) ;
				posr = i ;
			}
		}
		ans += R ;
		c.at(pos) = false ;
		r-- ;
	}
	cout << ans << endl ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:33: error: 'posr' was not declared in this scope; did you mean 'pos'?
   51 |                                 posr = i ;
      |                                 ^~~~
      |                                 pos
Language: C

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c=0,d,e,f,i,j,k,l=0,m,n;
    cin>>n;
    int x[n],y[n];
    m=n-1;
    for(i=0;i<n;i++)
    {
        cin>>x[i];
        y[i]=x[i];
    }

 sort(x, x+n, greater<int>());

for(i=0;i<n;i++)
{
    for(j=0;j<n;j++)
    {
        if(x[i]==y[j])
        {
            if(j<=(n-1)/2)
               {
                c=c+x[i]*abs(j-m);
                m--;
                cout<<c<<" "<<m<<" "<<j<<" "<<i<<" "<<x[i]<<" "<<y[j];
                }

        else
        {
          c=c+x[i]*abs(j-l);
          l++;
          cout<<c<<" "<<l<<" "<<j<<" "<<i<<" "<<x[i]<<" "<<y[j]<<endl;
        }
    }
}
}
cout<<c<<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;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<pair<ll, ll>> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.rbegin(), v.rend());

  vector<vector<ll>> dp(n, vector<ll>(n+1, -LINF));
  dp[0][0] = v[0].first * abs(n - 1 - v[0].second);
  dp[0][1] = v[0].first * v[0].second;

  for(int i=1;i<n;++i) {
    for(int j=0;j<n;++j) {
      if(dp[i-1][j] == -LINF) continue;
      chmax(dp[i][j+1], dp[i-1][j] + v[i].first * abs(v[i].second - j));
      chmax(dp[i][j], dp[i-1][j] + v[i].first * abs(n - 1 - (i - j) - v[i].second));
    }
  }

  ll ans = 0;
  for(int i=0;i<n;++i) {
    chmax(ans, dp[n-1][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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
vector<pair<int,int>> A;
ll memo[2000][2000];
bool visited[2000][2000];
ll f(int p, int q) {
	if (p == N) return 0;
	if (visited[p][q]) return memo[p][q];
	visited[p][q] = true;
	ll Ax = A[p].first;
	int x = A[p].second;
	ll r1 = f(p+1, q+1) + Ax * abs(x-q);
	int y = N-1-(p-q);
	ll r2 = f(p+1, q) + Ax * abs(x-y);
	return memo[p][q] = max(r1, r2);
}
int main() {
	cin >> N;
	for (int i = 0; i < N; ++ i) {
		int ai;
		cin >> ai;
		A.push_back({ai, i});
	}
	sort(A.rbegin(), A.rend());
	cout << f(0, 0) << 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 _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

struct BIT
{
	//[0,mn]
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}
};

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

	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> P(N, 0);
	vector<bool> USED(N, false);
	int l = 0, r = N - 1;

	rep(i, 0, N)cin >> A[i];

	int ans = 0;
	rep(i, 0, N)
	{
		int idx = -1;
		int dir = 1;
		int m = -1;

		rep(j, 0, N)
		{
			if (USED[j])continue;
			int rr = abs(r - j);
			int rl = abs(j - l);
			if (chmax(m, A[j]*rr))
			{
				idx = j, dir = 1;
			}
			if (chmax(m, A[j] * rl))
			{
				idx = j, dir = 0;
			}
		}

		if (dir == 1)
		{
			r--;
		}
		else
		{
			l++;
		}
		USED[idx] = true;
		ans += m;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

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

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

typedef struct {
	int parent;
	int height = 1;
}node_t;
vector<node_t> node;

int root(int n) {
	if (node[n].parent == 0) return n;
	root(node[n].parent);
}

bool same(int x, int y) {
	if (root(x) == root(y))
		return true;
	else
		return false;
}

void unite(int a, int b) {
	int root_a = root(a), root_b = root(b);

	if (root_a != root_b) {
		if (node[root_a].height >= node[root_b].height) {
			node[root_a].height = max(node[root_a].height, node[root_b].height + 1);
			node[root_b].parent = root_a;
		}

		else {
			node[root_b].height++;
			node[root_a].parent = root_b;
		}
	}

}

int main(void) {
	ll N;
	cin >> N;

	vector<ll> A(N + 1);
	vector<pair<ll, pair<int, int>>> edge;
	for (ll i = 1; i <= N; i++) {
		cin >> A[i];
		for (ll j = 1; j <= N; j++) {
			edge.push_back(make_pair(-A[i] * abs(i - j), make_pair(i, j)));
		}
	}

	sort(edge.begin(), edge.end());
	ll ans = 0;

	vector<bool> visit_to(N + 1);
	vector<bool> visit_from(N + 1);
	for (int i = 0; i < edge.size(); i++) {
		if (visit_from[edge[i].second.first]||visit_to[edge[i].second.second])
			continue;
		visit_to[edge[i].second.second] = true;
		visit_from[edge[i].second.first] = true;
		ans += edge[i].first;

	}
	cout << -ans << endl;
}

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>
using namespace std;
int main() {
  int n;
  vector<int> num(n);
  for(int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  int left = 0;
  int right = 0;
  long long sum = 0;
  for(int i = 0; i < n; i++) {
    int max = 0;
    int maxi;
    for(int j = 0; j < n-i; j++) {
      if(max < num.at(j)) {
        max = num.at(j);
        maxi = j;
      }
    }
    if(maxj <= n/2) {
      right++;
      sum += num.at(maxi)*(n-1-maxi);
      swap(num.at(maxi),num.at(n-i-1);
    }
    else if(maxj > n/2) {
      left++;
      sum += num.at(maxi)*(maxi+1);
      swap(num.at(maxi),num.at(i);
    }
  }
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:8: error: 'maxj' was not declared in this scope; did you mean 'maxi'?
   21 |     if(maxj <= n/2) {
      |        ^~~~
      |        maxi
a.cc:24:38: error: expected ')' before ';' token
   24 |       swap(num.at(maxi),num.at(n-i-1);
      |           ~                          ^
      |                                      )
a.cc:29:34: error: expected ')' before ';' token
   29 |       swap(num.at(maxi),num.at(i);
      |           ~                      ^
      |                                  )
Language: C

#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long ;
int n;

ll a[nax];


int main () {
    scanf("%d", &n);

    for (int i = 1 ;  i <= n;  ++ i) {
        scanf("%lld", a + i);
    }

    ll ans = 0;

    for (int i = 1 ; i < n ; ++ i) {

        ll s = 0;

        vector<ll> x, y;

        for (int j = 1 ; j <= i ; ++ j) {
            x.push_back(a[j]);
            s -= a[j] * (ll)(j - 1);
        }


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

        for (int j = i + 1 ; j <= n ; ++ j) {
            y.push_back(a[j]);
            s -= a[j] * (ll)(n - j);
        }

        sort(y.begin(), y.end());
       // reverse(y.begin(), y.end());

        ll dist = (n - i);

        for (int j = 0 ; j < i ; ++ j)
            s += x[j] * (dist ++);

        dist = i;

        for (int j = 0 ;j < n - i ; ++ j) {
            s += y[j] * (dist ++);
        }

        ans = max(ans, s);
    }

    printf("%lld\n", ans);
}
/*
    Good Luck
        -Lucina
*/


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

import java.util.*;

public class Solution {
    int[] ip;
    int N;

    private int dfs(int st, Set<Integer> visited ){
        if(st >= N)
            return 0;

        int ans = 0;
        for(int i = 0; i < N; i++){
            if(!visited.contains(i) && i != st){
                visited.add(i);
                ans = Math.max(ans, (ip[st] * Math.abs(i - st)) + dfs(st + 1, visited));
                visited.remove(i);
            }
        }
        return ans;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Solution s1 = new Solution();
        s1.N = Integer.parseInt(sc.nextLine());
        String[] ar = sc.nextLine().split("\\s");
        s1.ip = new int[ar.length];

        for(int i = 0; i < ar.length; i++){
            s1.ip[i] = Integer.parseInt(ar[i]);
        }
        int ans = s1.dfs(0, new HashSet<>());
        System.out.println(ans);
    }
}


Compiler output:
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: C

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
l, r = 0, N-1
ans = 0
used = set()
while l <= r:
    left = [(A[i] * abs(i - l), i) for i in range(N) if i not in used]
    right = [(A[i] * abs(r - i), i) for i in range(N) if i not in used]
    vl, il = max(left, key=lambda x: x[0])
    vr, ir = max(right, key=lambda x: x[0])
    if vl > vr:
        used.add(il)
        ans += vl
        l += 1
    else:
        used.add(ir)
        ans += vr
        r -= 1
print(ans)

Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import sys
      | ^~~~~~
main.c:2:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'input'
    2 | input = sys.stdin.readline
      | ^~~~~
Language: C++

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


int z(int x, int y){
  if (x<y){
    return y-x;
  }
  else{
    return x-y;
  }

int main() {
  int N;
  cin>> N;
  vector<int> A(N);
  for (int i =0; i<N; i++){
    cin >> A.at(i);
  }
  
  vector<int> B(N);
  for (int i=0; i<N; i++){
    B.at(i)=i;
  }

  for (int j =1; j<N; j++){
    for (int i = 0; i<j; i++){
      if(A.at(i) < A.at(j)){
        int tmp = A.at(i);
        A.at(i)=A.at(j);
        A.at(j)=tmp;
        int tnp =B.at(i);
        B.at(i)=B.at(j);
        B.at(j)=tnp;  
      }
    }
  }
  
  vector<int> C(N);
  int sum =0;
  
  
  for(int i =0; i < N; i++){
    int max =0;
    int min =0;
    for(int j =0; j<N; j++){
      if (C.at(j) != 0){
        min = j+1;
      }
      else{
        max++;
      }
    }
    
    if(z(B.at(i) -min) < z(B.at(i)-max)){
      C.at(max)=1;
      sum += A.at(i) * z(B.at(i)-max);
    }
    else{
      C.at(min)=1;
      sum +=A.at(i) * z(B.at(i)-max);
    }
  }

  cout << sum;
}




Compiler output:
a.cc: In function 'int z(int, int)':
a.cc:13:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   13 | int main() {
      |         ^~
a.cc:13:9: note: remove parentheses to default-initialize a variable
   13 | int main() {
      |         ^~
      |         --
a.cc:13:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:13:12: error: a function-definition is not allowed here before '{' token
   13 | int main() {
      |            ^
a.cc:66:2: error: expected '}' at end of input
   66 | }
      |  ^
a.cc:5:20: note: to match this '{'
    5 | int z(int x, int y){
      |                    ^
Language: C++

import numpy as np
N = int(input())
a= list(map(int,input().split()))
score=np.array(a)
b=np.sort(score)
c=b[-1::-1]
#print(c)
x=np.argsort(a)
y=x[-1::-1]
#print(y)

#c:score、y:index
cand=list(range(N))

count=0
for i in range(N):
    if (y[i]-cand[0])>(cand[-1]-y[i]):
        count+=c[i]*abs(y[i]-cand[0])
        cand.pop(0)
    elif (y[i]-cand[0])<(cand[-1]-y[i]):
        count+=c[i]*abs(cand[-1]-y[i])
        cand.pop(-1)
    else:
        if y[i+1]>y[i]:
            count+=c[i]*abs(y[i]-cand[0])
            cand.pop(0)
        else:
            count+=c[i]*abs(cand[-1]-y[i])
            cand.pop(-1) 

print(count)


Compiler output:
a.cc:7:2: error: invalid preprocessing directive #print
    7 | #print(c)
      |  ^~~~~
a.cc:10:2: error: invalid preprocessing directive #print
   10 | #print(y)
      |  ^~~~~
a.cc:12:2: error: invalid preprocessing directive #c
   12 | #c:score、y:index
      |  ^
a.cc:12:4: error: extended character 、 is not valid in an identifier
   12 | #c:score、y:index
      |    ^
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

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


int z(int x, int y){
  if (x<y){
    return y-x;
  }
  else{
    return x-y;
  }

int main() {
  int N;
  cin>> N;
  vector<int> A(N);
  for (int i =0; i<N; i++){
    cin >> A.at(i);
  }
  
  vector<int> B(N);
  for (int i=0; i<N; i++){
    B.at(i)=i;
  }

  for (int j =1; j<N; j++){
    for (int i = 0; i<j; i++){
      if(A.at(i) < A.at(j)){
        int tmp = A.at(i);
        A.at(i)=A.at(j);
        A.at(j)=tmp;
        int tnp =B.at(i);
        B.at(i)=B.at(j);
        B.at(j)=tnp;  
      }
    }
  }
  
  vector<int> C(N);
  int sum =0;
  
  
  for(int i =0; i < N; i++){
    int max =0;
    int min =0;
    for(int j =0; j<N; j++){
      if (C.at(j) != 0){
        min = j+1;
      }
      else{
        max++;
      }
    }
    
    if(z(B.at(i) -min) < z(B.at(i)-max)){
      C.at(max)=1;
      sum += A.at(i) * z(B.at(i)-max);
    }
    else{
      C.at(min)=1;
      sum +=A.at(i) * z(B.at(i)-max);
    }

  cout << sum;
}




Compiler output:
a.cc: In function 'int z(int, int)':
a.cc:13:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   13 | int main() {
      |         ^~
a.cc:13:9: note: remove parentheses to default-initialize a variable
   13 | int main() {
      |         ^~
      |         --
a.cc:13:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:13:12: error: a function-definition is not allowed here before '{' token
   13 | int main() {
      |            ^
a.cc:65:2: error: expected '}' at end of input
   65 | }
      |  ^
a.cc:5:20: note: to match this '{'
    5 | int z(int x, int y){
      |                    ^
Language: C

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0; i < n;i++){
        int k;
        cin >> k;
        a[i] = make_pair(k,i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int hajime = 0;
    int owari = n-1;
    long long ans = 0;
    int s = -1;
    for(int i = 0; i < n;i++){
        if(s == 0){
            if(owari-a.at(i-2).second > a.at(i-2).second - hajime){
                ans += a.at(i-2).first*(owari-a.at(i-2).second);
                owari--;
                s--;
            }
            else{
                ans += a.at(i-2).first*(a.at(i-2).second-hajime);
                hajime++;
                s--;
            }
        }
        else{
            if(owari-a.at(i).second == a.at(i).second - hajime){
                s = 1;
            }
            else if(owari-a.at(i).second > a.at(i).second - hajime){
                ans += a.at(i).first*(owari-a.at(i).second);
                owari--;
                s--;
            }
            else{
                ans += a.at(i).first*(a.at(i).second-hajime);
                hajime++;
                s--;
            }
        }
        
    }
    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 <cstdlib>
#include<vector>
#include<algorithm>
using namespace std;

#define M 1000000007

int main()
{   
    long long N;
    std::cin >> N;
    
    vector<long long>A(N, 0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    long long sum = 0;
    long long max, maxid;
    for(int i=0; i<N; i++){
        // max
        max = 0;
        for(int j=0; j<A.size(); j++){
            if(max<A[j]){
                maxid = j;
                max = A[j];
            }
        }
        if(maxid-A[0] > A[A.size()-1]-maxid){
            sum += A[maxid] * maxid-A[0];
            A.pop_front();
        }else{
            sum += A[maxid] * A[A.size()-1]-maxid;
            A.pop_back();
        }
          
    }
    std::cout << sum << std::endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: 'class std::vector<long long int>' has no member named 'pop_front'
   31 |             A.pop_front();
      |               ^~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#define f 100000;

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>nin(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> nin[i];
	}
	int j;

	// DPテーブル
	vector<vector<int>> dp(n, vector<int>(10000000));


	for (i = 0; i < 10000000; i++) {
		dp[0][i] = 0;
	}
	for (i = 0; i < 10000000; i++) {
		for (j = 1; i < n + 1; j++) {
			dp[j][i] = max(dp[j][i - nin[j - 1]], dp[j][i - 1]);
		}

	}
	cout<<dp[]

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:18: error: expected primary-expression before ']' token
   32 |         cout<<dp[]
      |                  ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> r(n);

  rep(i, n) {
    r[i] = i;
  }

  rep(i, n) {
    cin >> a[i];
  }

  rep(i, n - 1) {
    int m = 0;
    int k = i;
    for (int j = i + 1; j < n; j++) {
      int v = 0
        + abs(r[j] - i) * a[r[j]] 
        + abs(r[i] - j) * a[r[i]]
        - abs(r[i] - i) * a[r[i]]
        - abs(r[j] - j) * a[r[j]]; 
      if (v > m) {
        m = v;
        k = j;
      }
    }
    if (k != i) {
      int t = r[k];
      r[k] = r[i];
      r[i] = t;
    }

  int s = 0;

  rep(i, n) {
    s += abs(r[i] - i) * a[r[i]];
  }

  cout << s << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:2: error: expected '}' at end of input
   49 | }
      |  ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
int main()
{
    using namespace std;
    int N;
    cin >> N;
    map<int, int> A;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        B[i] = i;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'B' was not declared in this scope
   11 |         B[i] = i;
      |         ^
Language: C

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#define N 1000000010
using namespace std;
int n,a[N],b[N];
int main(){
	cin>>n;
	int i;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		b[i]=i;
	}
	int max=0,all=0;
	while(next_permutation(b+1,b+n)){
		for(i=1;i<=n;++i){
			all=all+a[i]*abs(i-b[i]);
		}
		if(all>max){
			max=all;
		}
	}
	cout<<all;
	return 0;
	
	
}

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

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0; i < n;i++){
        int k;
        cin >> k;
        a[i] = make_pair(k,i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int hajime = 0;
    int owari = n-1;
    long long ans = 0;
    int s = -1;
    for(int i = 0; i < n;i++){
        if(s == 0){
            if(owari-a.at(i-2).second > a.at(i-2).second - hajime){
                ans += a.at(i-2).first*(owari-a.at(i-2).second);
                owari--;
                s--;
        }
            else{
                ans += a.at(i-2).first*(a.at(i-2).second-hajime);
                hajime++;
                s--;
        }
        }
        else{
            if(owari-a.at(i).second == a.at(i).second - hajime){
                s = 1;
            }
            else if(owari-a.at(i).second > a.at(i).second - hajime){
                ans += a.at(i).first*(owari-a.at(i).second);
                owari--;
                s--;
            }
            else{
                ans += a.at(i).first*(a.at(i).second-hajime);
                hajime++;
                s--;
            }
        }
        
    }
    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>

using namespace std;

long A[2001];


bool comparaison(int i, int j)
{
    return (A[i] < A[j]);
}



int main() {

  long N;

  cin >> N;
  long i,j,k;

  for (i=0;i<N;i++)
    cin >> A[i];


  long pos[2001];

  for (i=0;i<N;i++)
      pos[i] = i;

  sort(pos, pos + N,comparaison);

  long perm[2001];
  for (i=0;i<N;i++)
    perm[i] = 0;

  long max_i,max_ind,poids;

  poids = 0;
  for (i=N-1;i>=0;i--) {
      // on cherche la distance maximum avec pos[i]
      max_i = -1;
      for (j=0;j<N;j++)
        if (perm[j] == 0)
          if (abs(j-pos[i]) > max_i) {
            max_ind = j;
            max_i = abs(max_ind-pos[i]);
          }
      perm[max_ind] = 1;
      poids += max_i*A[pos[i]];
  }
  cout << poids;
  return 0;
}


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

#include<bits/stdc++.h>

#define maxn 100005

using namespace std;
typedef long long ll;

int main(){
  #define TASK "ABC"
 // freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
  ios_base::sync_with_stdio(0);

  int n;
  cin >> n;

  vector < pair < int, int > > a(n);

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

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

  vector < vector < ll > > d(n, vector < ll >(n, 0));

  d[0][n - 1] = 0;
  for (int len = n - 1; len > 0; --len)
    for (int i = 0; i + len < n; ++i) {
      int j = i + len;

      d[i][j - 1] = max(d[i][j - 1], d[i][j] + ll(abs(a[len].second - j)) * a[len].first);
      d[i + 1][j] = max(d[i + 1][j], d[i][j] + ll(abs(a[len].second - i)) * a[len].first);
    }

  ll ans = 0;

  for (int i = 0; i < n; ++i)
    ans = max(ans, d[i][i] + ll(abs(a[0].second - i)) * a[0].first);

  cout << ans;
  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 <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 100000000000000;

ll dp[2005][2005];

int main()
{
    ll n;
    cin >> n;
    P p[2005];
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        p[i] = P(a, i);
    }
    sort(p, p + n, greater<P>());
    for(int j = 1; j <= n; j++) dp[0][j] = -INF;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= i; j++){
            dp[i][j] = max(dp[i - 1][j] + p[i - 1].first * (p[i - 1].second - (i - 1 - j)),
                           dp[i - 1][j - 1] + p[i - 1].first * (n - j - p[i - 1].second));
        }
        dp[i][0] = dp[i - 1][0] + p[i - 1].first * (p[i - 1].second - (i - 1));
    }
    ll ans = 0;
    for(int j = 0; j <= n; j++) ans = max(ans, dp[n][j]);
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |     sort(p, p + n, greater<P>());
      |     ^~~~
      |     short
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 fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, l = 0, r, t, k = 1; lint s = 0;
  cin >> n; r = n-1;
  vector<pii> v(n);
  rep(i, n){
    cin >> v[i].fi;
    v[i].se = i;
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  t = v[0].fi;
  queue<int> q;
  rep(i, n-1){
    if(v[i+1].fi == t) ++k;
    else{
      q.push(k);
      t = v[i+1].fi;
      k = 1;
    }
  }
  q.push(t);
  t = 0;
  while(!q.empty()){
    int c = t, d = t+q.front()-1;
    rep(i, q.front()){
      if(i % 2 == 0){
        s += v[c].fi * abs(v[i].se-l);
        ++l;
        ++c;
      }
      else{
        s += v[d].fi * abs(r-v[i].se);
        --r;
        --d;
      }
    t += q.front();
    q.pop();
  }
  cout << s << endl;
  return 0;
};

Compiler output:
a.cc: In function 'int main()':
a.cc:70:3: error: expected '}' at end of input
   70 | };
      |   ^
a.cc:30:12: note: to match this '{'
   30 | int main() {
      |            ^
Language: C

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

int a[2010];
bool vis[2010];

int main() {
	
	int n;
	cin >> n;
	
	for(int i=1;i<=n;++i) cin >> a[i];
	
	int l = 1 , r = n;
	
	long long ans = 0;


	for(int i=1;i<=n;++i) {
		bool p = 0 , pid = 0;
		int id = 0;
		long long Max = 0;
		for(int j=1;j<=n;++j) {
			if (vis[j]) continue;
			if (j - l > r - j) p = 1; else p = 0;
			long long tmp = a[j] * 1LL * max(abs(j - l) , abs(r - j));
			if (tmp >= Max) Max = tmp , id = j , pid = p;
		}
		ans += Max;
		vis[id] = 1;
		if (pid) ++ l; else -- r;
	}
	
	cout << ans << '\n';
	
	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;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    int n;
    cin>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    vbo count(n,true);
    ll sum=0;
    if(!(n%2)){
        ll m;
        int tmp;
        ll tmpp;
        rep(i,n/2){
            m=-1;
            rep(j,n){
                if(m<a[j]*abs(j-i)&&count[j]){
                    m=a[j]*abs(j-i);
                    tmp=j;
                    tmpp=a[j];
                }
                else if(m==a[j]*abs(j-i)&&tmpp<a[j]&&count[j]){
                    m=a[j]*abs(j-i);
                    tmp=j;
                    tmpp=a[j];
                }
            }
            sum+=m;
            count[tmp]=false;
            m=-1;
            rep(j,n){
                if(m<a[j]*abs(n-1-i-j)&&count[j]){
                    m=a[j]*abs(n-1-i-j);
                    tmp=j;
                    tmpp=a[j];
                }
                else if(m==a[j]*abs(n-1-i-j)&&tmpp<a[j]&&count[j]){
                    m=a[j]*abs(n-1-i-j);
                    tmp=j;
                    tmpp=a[j];
                }
            }
            sum+=m;
            count[tmp]=false;
        }
    }
    else{
        ll m;
        int tmp;
        ll tmpp;
        rep(i,(n-1)/2){
            m=-1;
            rep(j,n){
                if(m<a[j]*abs(j-i)&&count[j]){
                    m=a[j]*abs(j-i);
                    tmpp=a[j];
                    tmp=j;
                }
                else if(m==a[j]*abs(j-i)&&tmpp<a[j]&&count[j]){
                    m=a[j]*abs(j-i);
                    tmp=j;
                    tmpp=a[j];
                }
            }
            sum+=m;
            count[tmp]=false;
            m=-1;
            rep(j,n){
                if(m<a[j]*abs(n-1-i-j)&&count[j]){
                    m=a[j]*abs(n-1-i-j);
                    tmpp=a[j];
                    tmp=j;
                }
                else if(m==a[j]*abs(n-1-i-j)&&tmpp<a[j]&&count[j]){
                    m=a[j]*abs(n-1-i-j);
                    tmp=j;
                    tmpp=a[j];
                }
            }
            sum+=m;
            count[tmp]=false;
        }
        rep(k,n){
            if(count[k]){
                sum+=a[k]*abs(k-(n-1)/2);
                break;
            }
        }
    }
    cout<<sum<<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 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
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, l = 0, r, t, k = 1; lint s = 0;
  cin >> n; r = n-1;
  vector<pii> v(n);
  rep(i, n){
    cin >> v[i].fi;
    v[i].se = i;
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  t = v[0].fi;
  queue<int> q;
  rep(i, n-1){
    if(v[i+1].fi == t) ++k;
    else{
      q.push(k);
      t = v[i+1].fi;
      k = 1;
    }
  }
  q.push(t);
  t = 0;
  while(!q.empty()){
    int c = t, d = t+q.top()-1;
    rep(i, q.top()){
      if(i % 2 == 0){
        s += v[c].fi * abs(v[i].se-l);
        ++l;
        ++c;
      }
      else{
        s += v[d].fi * abs(r-v[i].se);
        --r;
        --d;
      }
    t += q.top();
    q.pop();
  }
  cout << s << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:24: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   53 |     int c = t, d = t+q.top()-1;
      |                        ^~~
      |                        pop
a.cc:54:14: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   54 |     rep(i, q.top()){
      |              ^~~
a.cc:2:38: note: in definition of macro 'rep'
    2 | #define rep(i, n) for(int i = 0; i < n; ++i)
      |                                      ^
a.cc:65:12: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   65 |     t += q.top();
      |            ^~~
      |            pop
a.cc:70:2: error: expected '}' at end of input
   70 | }
      |  ^
a.cc:30:12: note: to match this '{'
   30 | int main() {
      |            ^
Language: Java

import java.util.*;
import javafx.util.Pair;
import java.io.*;
public class Main
{
	public static void main(String args[]) throws IOException{
		BufferedReader in = new BufferedReader();
		int n =in.nextInt();
		// boolean x[] = new boolean[n];
		Pair<Integer, Integer> arr[] = new Pair[n];
		for(int i=0; i<n; i++){
			arr[i]=new Pair<>(in.nextInt(),i);
		}
		Arrays.parallelSort(arr,(a,b)->b.getKey()-a.getKey());
		int lo=0, hi=n-1, sc=0;
		for(Pair<Integer, Integer> i: arr)
		{
			if(Math.abs(i.getValue()-hi)>=Math.abs(i.getValue()-lo)){
				sc+= i.getKey()*Math.abs(i.getValue()-hi--);
			}else{
				sc+= i.getKey()*Math.abs(i.getValue()-lo++);
			}
			// out(i+" "+lo+" "+hi+" "+sc+"\n");
		}
		out(sc+"");
	}
	static void out(String s){
		System.out.print(s);
	}
}



class BufferedReader 
{ 
    java.io.BufferedReader br; 
    StringTokenizer st; 

    public BufferedReader() 
    { 
        br = new java.io.BufferedReader(new
                    InputStreamReader(System.in)); 
    } 

    public String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 

    public int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 

    public long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 

    public double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 

    public String nextLine() 
    { 
        String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}

Compiler output:
Main.java:2: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:10: error: cannot find symbol
		Pair<Integer, Integer> arr[] = new Pair[n];
		^
  symbol:   class Pair
  location: class Main
Main.java:10: error: cannot find symbol
		Pair<Integer, Integer> arr[] = new Pair[n];
		                                   ^
  symbol:   class Pair
  location: class Main
Main.java:12: error: cannot find symbol
			arr[i]=new Pair<>(in.nextInt(),i);
			           ^
  symbol:   class Pair
  location: class Main
Main.java:16: error: cannot find symbol
		for(Pair<Integer, Integer> i: arr)
		    ^
  symbol:   class Pair
  location: class Main
5 errors
Language: C

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

int main() {
  ll n;
  cin >> n;
  
  vector<ll>a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  ll front = 0;
  ll back = n-1;
  
  ll ans = 0;
  for(int i=0; i<n; i++){
   ll Max=0;
   int Order;
   for(int j=0; j<n; j++){
     if(Max<a[j]){
       Max=a[j];
       Order=j;
     }
   }
    
    if(Order-front>back-Order){
     ans+=Max*(Order-front); 
     front++;
     a[Order]=0;
    }
    else{
     ans+=Max*(back-Order);
     back--;
     a[Order]=0;
    }
    
  }
  
  cout << ans+1 << endl;

}

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