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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>b;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pw 1000000000
#define pi 3.141592653589793238
#define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second > b.second);
}
int large(int x,map<int,int> g,int n)
{
    int y=x;
    f(i,0,n)
    {
        if(i==x)
            continue;
        if(g[i]==1)
            continue;
        else if(g[i]==0){
            if(abs(x-i)>abs(x-y))
                y=i;
        }
    }
    return y;
}
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
       int n;
       cin>>n;
       //string s;
       int a[n];
       f(i,0,n)
       cin>>a[i];
       vector<pair<int,int>> v;
       f(i,0,n)
       v.pb(mp(i,a[i]));
       sort(v.begin(),v.end(),sortbysec);
       int mh=0;
       map<int,int> g;
       f(i,0,n)
       {
           int y=large(v[i].first,g,n);
           g[y]++;
           mh+=v[i].second*abs(v[i].first-y);
       }
       map<int,int> m1;
       f(i,0,n)
       m1[a[i]]++;
       fv(i,v)
       {if(m1[v.second]>1)
       {cout<<mh+1;return 0;}}
       cout<<mh;
       //sort(a,a+n);
       cout<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:17: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   60 |        {if(m1[v.second]>1)
      |                 ^~~~~~
Language: C

#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
//const i64 smod = 998244353ll;
const i64 inf = 1'000'000'000'000'000'000ll + 7;

const double eps = 1e-8;

const i64 MAXN = 2 * 1'000 + 6;
i64 n, k;

i64 a[MAXN];

i64 val(pair<i64, i64> p) {
    return a[p.first] * abs(p.first - p.second);
}

struct less_key {
    bool operator() (const pair<i64, i64>& p1, const pair<i64, i64>& p2)  const {
        i64 v1 = val(p1);
        i64 v2 = val(p2);

        pair<i64, i64> c1 = { v1, -a[p1.first] };
        pair<i64, i64> c2 = { v2, -a[p2.first]};

        if (c1 != c2) {
            return c1 < c2;
        }
        else {
            return p1.second < p2.second;
        }
    }
};

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

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

    set<pair<i64, i64>, less_key> q;
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 0; j < n; j++) {
            q.insert({ i, j });
        }
    }

    i64 R = 0;
    while (!q.empty()) {
        auto c = *q.rbegin();
        R += val(c);

        for (i64 i = 0; i < n; i++) {
            q.erase({i, c.second});
        }

        for (i64 j = 0; j < n; j++) {
            q.erase({c.first, j});
        }
    }

    cout << R << endl;


    return 0;
}

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

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

const int N = 4005;
typedef long long ll;

ll ans, f[N][N], res;
int n;
struct node {
	ll val;
	int pos;
} a[N];

bool cmp(node a, node b) { return a.val > b.val; }

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++) {
		cin>>a[i].val;
		a[i].pos = i;
	}
	sort(a + 1, a + n + 1, cmp);
	memset(f, -0x7f, sizeof(f));
	f[0][n + 1] = 0;
	for(int i = 1; i <= n; i++)
		for(int l = 0; l <= i; l++) {
			int r = n - i + l + 1;
			if(l >= 1)f[l][r] = max(f[l][r], f[l - 1][r] + abs(a[i].pos - l)*a[i].val);
			if(r <= n)f[l][r] = max(f[l][r], f[l][r + 1] + abs(a[i].pos - r)*a[i].val);
		}
	for(int i = 0; i <= n; i++)
		ans = max(ans, f[i][i + 1]);
	cout<<ans<<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 <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <deque>
using namespace std;

typedef long long ll;

deque<pair<ll, ll> > v;
deque<ll> L;
ll dp[2222][2222], n;

ll solve(ll s, ll e, ll val)
{
	ll cnt = s - 1 + n - e;

	if (s == e)
		return val + v[cnt].first * abs(s - v[cnt].second);
	else
		return dp[s][e] = max(dp[s][e], max(solve(s + 1, e, val + v[cnt].first * abs(v[cnt].second - s)), solve(s, e - 1, val + v[cnt].first * abs(v[cnt].second - e))));
}

int main(void)
{
	ll a, i;

	scanf("%lld", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%lld", &a);
		v.push_back(make_pair(a, i));
	}

	sort(v.begin(), v.end(), greater<>());

	printf("%lld", solve(1, n, 0));
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long 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())
const ll M=2002;
ll a[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	set<ll> st;
	for(int i=1;i<=n;i++)
	{
		st.insert(i);
		cin>>a[i];
	}
	ll ans=0;
	ll l=1,r=n;
	while(sz(st))
	{
		ll idx=-1;
		ll mx=-1;
		for(auto u:st)
		{
			if(a[u]*(abs(u-l))>mx)
			{
				mx=a[u]*abs(u-l);
				idx=u;
			}
			if(a[u]*abs(u-r)>mx)
			{
				mx=a[u]*abs(u-r);
				idx=u;
			}
		}
		if(a[idx]*abs(idx-l)==mx)
		{
			// cout<<l<<" "<<idx<<" "<<mx<<endl;
			l++;
			st.erase(idx);
		}
		else
		{
			// cout<<r<<" "<<idx<<" "<<mx<<endl;
			r--;
			st.erase(idx);
		}
		ans+=mx;
	}
	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: Java

import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();
        long[] a = new long[n];
        for(int i=0; i<n; i++){
            a[i] = stdIn.nextLong();
        }

        Integer[] seed = new Integer[n];
        for(int i=0; i<n; i++){
            seed[i] = i;
        }
        Permutation<Integer> p = new Permutation(seed);

        long max = 0;
        do{
            Integer[] perm = p.getTarget();
            long temp = 0;
            for(int i=0; i<perm.length; i++){
                temp += (Math.abs(perm[i] - i) * a[i]);
            }
            if(temp > max){
                max = temp;
            }
        }while(p.next());

        System.out.println(max);
    }
}

class Permutation<T> extends Serializable {

    private int baseIndex;
    private int index;
    private T[] objs;
  
    private Permutation<T> subPermutation;
  
    public Permutation(T[] objs) {
      this(0, 0, objs.clone());
    }
  
    private Permutation(int baseIndex, int index, T[] objs) {
      if (objs == null || objs.length == 0) {
        throw new IllegalArgumentException();
      }
  
      this.baseIndex = baseIndex;
      this.index = index;
      this.objs = objs;
  
      if (this.index < this.objs.length - 1) {
        this.subPermutation =
          new Permutation<T>(this.baseIndex + 1, this.index + 1, this.objs);
      }
    }
  
    public T[] getTarget() {
      return this.objs;
    }
  
    public boolean next() {
      if (this.subPermutation == null) {
        return false;
      }
  
      boolean result = this.subPermutation.next();
      if (result == true) {
        return true;
      }
  
      this.swap(this.baseIndex, this.index);
  
      ++this.index;
      if (this.objs.length <= this.index) {
        this.index = this.baseIndex;
        return false;
      }
  
      this.swap(this.index, this.baseIndex);
      return true;
    }
  
    @Override
    public String toString() {
      // snip.
    }
  
    private void swap(int index1, int index2) {
      T tmp = this.objs[index1];
      this.objs[index1] = this.objs[index2];
      this.objs[index2] = tmp;
    }
  }

Compiler output:
Main.java:35: error: cannot find symbol
class Permutation<T> extends Serializable {
                             ^
  symbol: class Serializable
Main.java:88: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: C

#include<stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):-(a))
typedef long long ll;

int main(){
  ll n,a[2000],p[2000], sum, i, k,l,apk_m,apl_m,k_m,l_m,ap;
  bool moved[2000] = {false,};
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",a+i);
  }
  k=0;
  l=n-1;
  while(k<=l){
    apk_m = -1;
    apl_m = -1;
    for(i=0;i<n;i++){
      if(!moved[i]){
        ap = a[i] * abs(i - k);
        if(apk_m < ap || (apk_m == ap && a[k_m] < a[i])){
          apk_m = ap;
          k_m = i;
        }
        ap = a[i] * abs(i - l);
        if(apl_m < ap || (apl_m == ap && a[l_m] < a[i])){
          apl_m = ap;
          l_m = i;
        }
      }
    }
    if(apk_m >= apl_m){
      p[k] = k_m;
      moved[k_m]=true;
      k++;
    }
    else{
      p[l] = l_m;
      moved[l_m]=true;
      l--;
    }
  }
  sum = 0;
  for(i=0;i<n;i++){
    //printf("%lld\n",p[i]);
    sum +=a[p[i]] * abs(i - p[i]);
  }
  printf("%lld",sum);
}

Compiler output:
main.c: In function 'main':
main.c:8:3: error: unknown type name 'bool'
    8 |   bool moved[2000] = {false,};
      |   ^~~~
main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include<stdio.h>
  +++ |+#include <stdbool.h>
    2 | #define max(a,b) ((a)>(b)?(a):(b))
main.c:8:23: error: 'false' undeclared (first use in this function)
    8 |   bool moved[2000] = {false,};
      |                       ^~~~~
main.c:8:23: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:8:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:34:18: error: 'true' undeclared (first use in this function)
   34 |       moved[k_m]=true;
      |                  ^~~~
main.c:34:18: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

struct Pos
{
    int pos;
    ll happiness;
};

bool cmp( const Pos &a, const Pos &b ){
    return a.happiness > b.happiness;
}


const int MAX = 2001;
ll dp[MAX][MAX];


int main(){

    int n;
    cin >> n;
    vector<Pos> v(n);
    for(int i = 0; i < n; i++){
        v[i].pos = i;
        cin >> v[i].happiness;
    }
    sort( all(v), cmp );

    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < MAX; j++){
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        // h:左からが何個埋まっているか
        for(int h = 0; h <= i; h++){
            ll t = i - h;
            ll happy;
            happy = v[i].happiness * abs( v[i].pos - h );
            dp[h + 1][t] = max(dp[h + 1][t],  dp[h][t] + happy );

            happy = v[i].happiness * abs( v[i].pos - (n - 1 - t) );
            dp[h][t + 1] = max(dp[h][t + 1],  dp[h][t] + happy );

        }
    }


    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ans = max(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>

#define rep(i, n) for ( int i = 0; i < (n); ++i )
using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

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

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

	ll s = 0;
	ll e = n - 1;
	ll sum = 0;

	rep( i, n ) {
		// 嬉しさ最大のインデックスを求める
		ll _max = 0;
		ll p, p2 = -1;
		rep( i, n ) {
			if ( _max < max(a[i] * (i - s), a[i] * (e - i)) ) {
				_max = max(a[i] * (i - s), a[i] * (e - i));
				p2 = p;
				p = i;
			}
		}

		if ( (p - s) > (e - p) ) {
//			cout << p << "->" << s << ", " << ((p - s) * a[p]) << endl;
			sum += (p - s) * a[p];
			s++;
		}
		else if ( (p - s) < (e - p) ) {
//			cout << p << "->" << e << ", " << ((e - p) * a[p]) << endl;
			sum += (e - p) * a[p];
			e--;
		}
		else {
			if ( p2 > p ) {
//				cout << p << "->" << s << ", " << ((p - s) * a[p]) << endl;
				sum += (p - s) * a[p];
				s++;
			}
			else {
//				cout << p << "->" << e << ", " << ((e - p) * a[p]) << endl;
				sum += (e - p) * a[p];
				e--;
			}
		}
		a[p] = 0;
	}

	cout << sum << endl;

	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 st              first
#define nd              second
#define pb              push_back
#define lwb             lower_bound
#define upb             upper_bound
#define all(a)          (a).begin(), (a).end()
#define Reset(s, n)     memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       (a).resize(unique(all(a)) - (a).begin())
#define bit(n, i)       (((n) >> (i)) & 1)
#define cntbit(n)       __builtin_popcountll(n)

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
const ll INF = 1e9;
const ld PI = acos((ld) -1);
const ld EPS = 1e-12;
inline bool isPrime (ll x){ if(x <= 1) return 0; if(x <= 3) return 1; if (!(x % 2) || !(x % 3)) return 0; ll s = sqrt(1.0 * x) + EPS; for(ll i = 5; i <= s; i += 6){if (!(x % i) || !(x % (i + 2))) return 0;}return 1;}
inline ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline void onbit(ll &a, int i){a |= 1LL << i;}
inline void offbit(ll &a, int i){onbit(a, i), a -= (1LL << i);}

const int N = 3e3 + 5;

int n, m, k;
ll a[N], b[N];
ll f[N][N][3];

void solve(){
   cin >> n;
   std::vector<pair<int, int>> b(n + 1);
   for(int i = 1; i <= n; i++){
      cin >> a[i];
      b[i] = {a[i], i};
   }
   b[0] = {INF, INF};
   sort(all(b), greater<pair<int,int>>());
   ll res = 0;
   for(int k = 1; k <= n; k++){
      int x = b[k].st;
      int y = b[k].nd;
      int len = n - k + 1;
      for(int i = 1; i + len - 1 <= n; i++){
         f[i][len][0] = max(f[i - 1][len + 1][0] + b[k].st * abs(b[k].nd - i), 
                            f[i][len + 1][1] + b[k].st * abs(b[k].nd - i));
         f[i][len][1] = max(f[i - 1][len + 1][0] + b[k].st * abs(b[k].nd - (i + len - 1)), 
                            f[i][len + 1][1] + b[k].st * abs(b[k].nd - (i + len - 1)));
         res = Max(res, f[i][len][0], f[i][len][1]);
      }
   }
   cout << res << "\n";

  

}

int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   cout << fixed << setprecision(10);
   //    freopen("input.txt", "r", stdin);
   //    freopen("output.txt", "w", stdout);
   int query = 1;
   // cin >> query;
   int start = 1000 * clock() / CLOCKS_PER_SEC;
   while(query--) solve();
   cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC  - start << "ms\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<iostream>
#include<cmath>
using namespace std;
int n;
struct dian
{
    long long x;
    int id;
}a[2010];
bool cmp(const dian &x,const dian &y)
{
     return x.x>y.x;
}
long long f[2010][2010],ans;
int main()
{
     int i,j;
     cin>>n;
     for(i=1;i<=n;i++) 
     {
         cin>>a[i].x;
         a[i].id=i;
     }
     sort(a+1,a+n+1,cmp);
     for(i=1;i<=n;i++)
      for(j=0;j<=i;j++)
      {
          if(j==0) f[i][j]=f[i-1][j]+a[i].x*abs(a[i].id-(n-i+j+1));
          else if(j==i) f[i][j]=f[i-1][j-1]+a[i].x*abs(a[i].id-j);
          else
          f[i][j]=max(f[i-1][j-1]+a[i].x*abs(a[i].id-j),f[i-1][j]+a[i].x*abs(a[i].id-(n-i+j+1)));
      }
     for(i=0;i<=n;i++) if(f[n][i]>ans) ans=f[n][i];
     //cout<<f[1][1]<<" "<<f[1][0]<<endl;
     cout<<ans;
     cin>>i;
}
          
     
     


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

#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int,int>> A(n);
    for(int i=0;i<n;i++){
        cin >> A[i].first;
        A[i].second=i;
    }
    sort(all(A));
    reverse(all(A));
    int l=0,r=n-1;
    int sum=0;
    for(int i=0;i<n;i++){
        if(A[i].second>=l+(r-l)/2){
            sum+=A[i].first*(abs(A[i].second-l));
            l++;
        }
        else{
            sum+=A[i].first*(abs(A[i].second-r));
            r--;
        }
    }
    cout << sum;
    
}

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

import java.util.*;
import java.io.*;
public class E {
    int N;
    Pair[] ps;
    HashMap<String, Long> DP = new HashMap<>();
    public long opt(int l, int i) {
        int r = N - i + l - 1;
        if(i == N) return 0;
        String T = "" + l + ";" + i;
        if(DP.containsKey(T)) {
            return DP.get(T);
        }
        long v1 = Math.abs(ps[i].idx - l)*ps[i].value + opt(l+1, i+1);
        long v2 = Math.abs(ps[i].idx - r)*ps[i].value + opt(l, i+1);
        DP.put(T, Math.max(v1, v2));
        return Math.max(v1, v2);
    }
    class Pair implements Comparable<Pair> {
        int idx;
        long value;
        public Pair(int idx, long value) {
            this.idx=idx;this.value=value;
        }
        public int compareTo(Pair p){
            return -Long.compare(value, p.value);
        }
    }
    void solve(BufferedReader in) throws Exception {
        N = toInt(in.readLine());
        int[] A = toInts(in.readLine());
        ps = new Pair[N];
        for(int i = 0; i<N; i++) {
            ps[i] = new Pair(i, A[i]);
        }
        Arrays.sort(ps);
        System.out.println(opt(0, 0));
    }
    int toInt(String s) {return Integer.parseInt(s);}
    int[] toInts(String s) {
        String[] a = s.split(" ");
        int[] o = new int[a.length];
        for(int i = 0; i<a.length; i++) o[i] = toInt(a[i]);
        return o;
    }
    void e(Object o) {
        System.err.println(o);
    }
    public static void main(String[] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        (new E()).solve(in);
    }
}


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

#include<stdio.h>
#include<math.h>
void main()
{
  int n,i,s,m,t;
  int a[50];
  scanf("%d",&n);
  for(i=0;i<ni++)
  {
    scanf("%d",&a[i]);
  }
  m=n/2;
  for(i=0;i<m;i++)
  {
    t=a[i];
    a[i]=a[m+i];
    a[m+i]=t;
    s=s+a[i]*abs((i+1)-(m-i+1))+a[m+i]*abs((m-i+1)-(i+1));
  }
  printf("%d",s);
}

Compiler output:
main.c: In function 'main':
main.c:8:13: error: 'ni' undeclared (first use in this function); did you mean 'i'?
    8 |   for(i=0;i<ni++)
      |             ^~
      |             i
main.c:8:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:17: error: expected ';' before ')' token
    8 |   for(i=0;i<ni++)
      |                 ^
      |                 ;
main.c:18:14: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   18 |     s=s+a[i]*abs((i+1)-(m-i+1))+a[m+i]*abs((m-i+1)-(i+1));
      |              ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | void main()
Language: C

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

int main() {
  ll Ans = 0;  // 回答：
  int N; cin >> N;  // 人数
  vector<int>  A(N);  // 嬉しさ配列
  rep(i,N){ cin >> A.at(i); }
  vector<int>  B(N);  // 並べ替え後配列
  rep(i,N){ B.at(i)=i;} // 最初は０からＮ－１でソート済み

  ll wk_U;  // 一時的嬉しさ
  do {
	// 順列に対する処理
    // 並び順毎にその時の嬉しさを計算する。
    wk_U=0;
    rep(i,N){
      wk_U += A.at(i) * abs(i-B.at(i));
    }
    Ans = max(Ans,wk_U);
	} while (next_permutation(B.begin(),B.end()));


  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;

long long n,dp[2005][2005];
pair<long long,long long> arr[2005];

long long rec(long long i,long long j)
{
    if(dp[i][j]!=-1)return  dp[i][j];
    if(i > j)return 0;
    long long idx = i+(n-j)-1;
    long long x1 = abs(i-arr[idx].second)*arr[idx].first+rec(i+1,j);
    long long x2 = abs(j-arr[idx].second)*arr[idx].first+rec(i,j-1);
    return dp[i][j] = max(x1,x2);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    long long i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>arr[i].first;
        arr[i].second = i;
    }
    sort(arr,arr+n);
    reverse(arr,arr+n);
    memset(dp,-1,sizeof(dp));
    cout<<rec(0,n-1)<<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>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  long long a[n];
  REP(i, n) cin>>a[i];
  vector<int> to(n, -1);
  int l = 0, r = n - 1;
  REP(_, n){
    int mi = -1;
    long long mv = -1;
    REP(i, n){
      if(to[v] >= 0) continue;
      if(mv < a[i]){
        mi = i;
        mv = a[i];
      }
    }
    if(abs(mi - l) >= abs(r - mi)){
      to[mi] = l;
      l++;
    }else{
      to[mi] = r;
      r--;
    }
  }
  long long ans = 0;
  REP(i, n) ans += a[i] * (long long)abs(to[i] - i);
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:81:13: error: 'v' was not declared in this scope
   81 |       if(to[v] >= 0) continue;
      |             ^
Language: C

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxn = 2e3+10;

vector<pair<long long,long long> > a, b;

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int n;

	cin >> n;

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

        cin >> x;

        if(i + i <= n) a.push_back({x, i});
        else b.push_back({x, i});
	}

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

	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	long long ans = 0;

	long long id = 0, val = 0;

	for(int j=n; j>(n+1)/2; j--){
        for(int i=0; i<a.size(); i++){
            if(abs(a[i].second-j) * a[i].first > val){
                val = abs(a[i].second-j) * a[i].first;
                id = i;
            }
            else if(abs(a[i].second-j) * a[i].first == val and a[i].first < a[id].first){
                val = abs(a[i].second-j) * a[i].first;
                id = i;
            }
        }

        ans += val;
        a[id] = {0, 0};
        id = val = 0;
	}

	id = val = 0;

	for(int j=(n+1)/2; j>=1; j--){
        for(int i=0; i<b.size(); i++){
            if(abs(b[i].second-j) * b[i].first > val){
                val = abs(b[i].second-j) * b[i].first;
                id = i;
            }
            else if(abs(b[i].second-j) * b[i].first == val and b[i].first < b[id].first){
                val = abs(b[i].second-j) * b[i].first;
                id = i;
            }
        }

        ans += val;
        a[id] = {0, 0};
        id = val = 0;
	}

	cout << ans << endl;

	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 <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const int N = read_item();
	vector<int> A(N);
	for(auto i : range(N)) {
		A[i] = read_item();
	}
	vector<pair<int,int>> sorted(N);
	for(auto i : range(N)) {
		sorted[i] = {A[i], i};
	}
	sort(sorted.rbegin(), sorted.rend());

	vector<vector<i64>> dp(N + 1);
	for(auto& d : dp) {
		d.resize(N + 1, -inf);
	}
	dp[0][0] = 0;

	for(auto i : range(N)) {
		for(auto j : range(N)) {

			auto& a = dp[i + 1][j];
			const i64 v = sorted[i].first;
			const int pos = sorted[i].second;

			const int left = j - 1;
			const int right = N - (i + 1 - j);

			if(left >= 0) {
				const i64 b = dp[i][j - 1] + abs(pos - left) * v;
				a = max(a, b);
			}
			if(right < N) {
				const i64 b = dp[i][j] + abs(pos - right) * v;
				a = max(a, b);
			}
		}
	}

	i64 ans = dp[N][0];
	for(auto i : range(N + 1)) {
		ans = max(ans, dp[N][i]);
	}
	printf("%lld\n", ans);

	return 0;
}

/* wafdayo~~~ */


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;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll a[2200];int id[2200];
ll calc(int x,int y){
	return (abs(id[x]-y)-abs(id[x]-x))*a[id[x]]+(abs(id[y]-x)-abs(id[y]-y))*a[id[y]];	
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		id[i]=i;
		scanf("%lld",&a[i]);
	}
	ll ans=0;
	for(int th=0;th<=20;th++)
	for(int i=1;i<=n;i++){
		for(int j=n;j>=1;j--){
			if(i==j) continue;
			if(calc(i,j)>=0){
				ans+=calc(i,j);
				swap(id[i],id[j]);
			}
		}
	}
	printf("%lld\n",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>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, 1, 0, -1};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<pl> a(n);
	rep(i, n) {
		ll p;
		cin >> p;
		a[i] = {p, i};
	}
	ll ans = 0;
	rep(i, n) {
		rep(j, n - 1) {
			ll l, r;
			if (j < a[j].se)
				l = -a[j].fi;
			else
				l = a[j].fi;
			if (j + 1 > a[j + 1].se)
				r = -a[j + 1].fi;
			else
				r = a[j + 1].fi;
			if (l + r > 0) swap(a[j], a[j + 1]), ans += r + l;
		}
	}
	cout << ans << endl;
	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 <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
P a[2010];
int d[2010][2010];
int ans;

signed main() {
	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);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < i; j++) {
			int x = abs(a[i].second - (n - (i - j - 1)));
			d[i][j] = max(d[i][j], d[i - 1][j] + a[i].first*x);
		}
		for (int j = 1; j <= i; j++) {
			int x = abs(a[i].second - j);
			d[i][j] = max(d[i][j], d[i - 1][j - 1] + a[i].first*x);
		}
	}
	for (int i = 0; i <= n; i++)ans = max(ans, d[n][i]);
	cout << ans << endl;
}

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 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; 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());
  rep(i, n){
    if(abs(v[i].se-l) > abs(r-v[i].se)){
      s += v[i].fi * abs(v[i].se-l);
      ++l;
    }
    else if(abs(v[i].se-l) < abs(r-v[i].se)){
      s += v[i].fi * abs(r-v[i].fi);
      --r;
    }
    else if(i < n-1 && v[i+1].fi < v[i].fi){
      s += v[i].fi * abs(v[i].se-l);
      ++l;
    }
    else if(i < n-1 && v[i+1].fi > v[i].se){
      s += v[i].fi * abs(r-v[i].fi);
      --r;
    }
    else{
      s += v[i].fi * abs(v[i].se-l);
      ++l;
    }
  }
  cout << s << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:19: error: expected ',' or ';' before 'for'
    2 | #define rep(i, n) for(int i = 0; i < n; ++i)
      |                   ^~~
a.cc:34:3: note: in expansion of macro 'rep'
   34 |   rep(i, n){
      |   ^~~
a.cc:34:7: error: 'i' was not declared in this scope
   34 |   rep(i, n){
      |       ^
a.cc:2:34: note: in definition of macro 'rep'
    2 | #define rep(i, n) for(int i = 0; i < n; ++i)
      |                                  ^
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)

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;


int abs(int n) {
  return n < 0 ? -n : n;
}

int main() {
  int N; io.scan(N);
  vector<ll> A(N);
  REP(i, N) io.scan(A[i]);
  vector<ll> index(N);
  REP(i, N) index[i] = i;
  
  REP(i, N) {
    FOR(j, 1, N) {
      if (A[j-1]*abs(j-1 - index[j-1]) + A[j]*abs(j - index[j]) < A[j-1]*abs(j - index[j-1]) + A[j]*abs(j-1 - index[j])) {
        swap(A[j-1], A[j]);
        swap(index[j-1], index[j]);
      }
    }
  }

  ll sum = 0;
  REP(i, N) {
    sum += A[i]*abs(i-index[i]);
  }
  io.printl(sum);
  
  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;

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

const int MAXN = 2000;

int N;
pii A[MAXN+10];
ll dp[MAXN+10][MAXN+10];

ll solve(int l, int r)
{
	ll &ret=dp[l][r];
	if(ret!=-1) return ret;
	ret=0;

	int t=l+N+1-r+1;
	if(t==N+1) return ret=0;

	ret=max(ret, solve(l+1, r)+(ll)abs(A[t].second-(l+1))*A[t].first);
	ret=max(ret, solve(l, r-1)+(ll)abs(A[t].second-(r-1))*A[t].first);
	return ret;
}

int main()
{
	int i, j;

	scanf("%d", &N);
	for(i=1; i<=N; i++) scanf("%d", &A[i].first), A[i].second=i;
	sort(A+1, A+N+1, greater<pii>());

	memset(dp, -1, sizeof(dp));
	printf("%lld\n", solve(0, N+1));
}

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 <cmath>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
using namespace std;

const double pi = acos(-1);

typedef long long ll;
const int maxn = 2005;
struct pp{
    ll v;
    int id;
    bool operator<( const pp &o )const{
        if( v != o.v )return v > o.v;
        return id < o.id;
    }
};
pp A[maxn];
int mark[maxn];
ll dp[maxn][maxn];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int n;
    cin >> n;

    for( int i = 1; i <= n; i++ )
        cin >> A[i].v, A[i].id = i;

    sort(A+1, A+n+1);

    for( int i = 0; i <= n; i++ )
        for( int j = 0; j <= n; j++ )
            dp[i][j] = -1;

    dp[0][0] = 0;

    ll sol = 0;
    for( int i = 0; i <= n; i++ ){
        for( int j = 0; j <= n; j++ ){
            if( i + j > n )continue;
            if( dp[i][j] == -1 )continue;
            int t = i+j+1;
            int ini = i+1;
            int fin = n-j;
            dp[i+1][j] = max( dp[i+1][j], dp[i][j] + abs(A[t].id - ini) * A[t].v );
            dp[i][j+1] = max( dp[i][j+1], dp[i][j] + abs(A[t].id - fin) * A[t].v );
        }
    }

    for( int i = 0; i <= n; i++ )
        sol = max(sol, dp[i][n-i]);

    cout << sol << "\n";

    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;

int n;


pair < int , int > a[2005];



bool viz[2005];

long long ans;


int main()
{
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >> a[i].first , a[i].second = i;
    for(int i = 1 ; i < n  ; i++)
        for(int j = i + 1 ; j <= n ; j++)
    {
        int u = max(a[i].second - 1 , n - a[i].second) , u1 = max(a[j].second - 1 , n - a[j].second);
        if(1LL * a[i].first * u < 1LL * a[j].first * u1)
            swap(a[i] , a[j]);
    }
    ///sort(a + 1 , a + n + 1 , CMP);
    for(int i = 1 ; i <= n ; i++)
    {
        int p = 0;
        long long mx = 0;
        for(int j = 1 ; j <= n ; j++)
            if(!viz[j] && mx < a[i].first * abs(j - a[i].second))
        {
            p = j;
            mx = 1LL * a[i].first * abs(j - a[i].second);
        }
        ans += mx;
        viz[p] = true;
    }
    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;

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

ll dp[2001][2001];

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

	int n;
	cin >> n;

	vector<pii> a(n);

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

	sort(a.begin(), a.end(), [](const pii& a, const pii& b) {
		return a.first > b.first;
	});

	for (int sum = 0; sum < n; sum++) {
		for (int l = 0; l <= sum; l++) {
			int r = sum - l;

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

	ll res = 0;

	for (int i = 0; i <= n; i++) {
		res = max(res, dp[i][n - i]);
	}

	cout << res;

	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 two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

ll dp[2001][2001];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<pair<ll, ll> > in(n);
    int i;
    rep(i, n) {
        cin >> in[i].first;
        in[i].second = i;
    }
    sort(in.begin(), in.end());
    ll ans(0);
    ll cnt(0);
    memset(dp, 0, sizeof(dp));
    for (int i = n - 1; i >= 0; i--) {
        ll val = in[i].first;
        ll pos = in[i].second;
        cnt++;
        ll cc = n - cnt;
        for (ll j = 0; j < cnt + 1; j++) {
            ll left = j;
            ll right = j + cc;
            // cout << left << ' ' << right << endl;
            ll t = 0;
            if (left > 0) {
                t = max(t, dp[left-1][right] + val * abs(left - 1 - pos));
            }
            if (right < n) {
                t = max(t, dp[left][right+1] + val * abs(right - pos));
            }
            // cout << dp[left][right] << endl;
            dp[left][right] = t;
        }
    }
    rep(i, n) {
        ans = max(ans, dp[i][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

/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;

#define io(F) string t_="";ifstream fin(t_+F+".in");ofstreamfout(t_+F+".out")
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define graph unordered_map<int, unordered_set<int>>
typedef long long ll;

int main() {
	qio; int n; cin >> n;
	vector<ll> nums(n); forl(i, 0, n) cin >> nums[i];
	ll l = 0, r = n-1;
	ll ans = 0;
	forl(i, 0, n) {
		int mv = -1, mp = 0;
		forl(j, 0, n) {
			if(nums[j] >= mv) {
				if(mv == -1) { mv = nums[j]; mp = j; }
				else {
					if(max(abs(mp-l), abs(mp-r)) < max(abs(j-l), abs(j-r))) {
						mv = nums[j];
						mp = j;
					}
				}
			}
		}
		if(abs(mp-l) > abs(mp-r)) {
			ans += nums[mp]*abs(mp-l);
			l++;
		}
		else {
			ans += nums[mp]*abs(mp-r);
			r--;
		}
		nums[mp] = -2;
	}
	println(ans);
}


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<stdio.h>
int main()
{
int A[1000000000],N,n, i, sum=0;
scanf("%d",&N);
if(N>=2&&N<=2000)
{
for(i=1;i<=N;i++)
  {
  scanf("%d", &A[i]) ;
  }
  n=1;
for(i=1;i<=N;i++) 
{
if(n>=A[i])
  sum=sum+n*(A[i]-n) ;
  n++;
else
  sum=sum+n*(n-A[i]) ;
  n++;
}
printf("%d",sum);
}
}


Compiler output:
main.c: In function 'main':
main.c:18:1: error: 'else' without a previous 'if'
   18 | else
      | ^~~~
Language: C

#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
  int n;
  deque<int> vals;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    vals.push_back(tmp);
  }

  int left = 0, right = 0;
  int sum = 0;

  for (int i = 0; i < n; i++) {
    int max_ind = 0;
    int max_point = 0;
    bool is_max_left = false;

    for (int j = 0; j < n; j++) {
      int left_movable = j - left;
      int right_movable = n - j - right - 1;
      int point = max(left_movable, right_movable) * vals[j];

      if (point > max_point) {
        max_ind = j;
        max_point = point;
        is_max_left = left_movable > right_movable;
        // どちらに移動しても変わらないときの処理を考慮する
      }
    }

    vals[max_ind] = 0;
    sum += max_point;

    if (is_max_left) {
      left++;
    } else {
      right++;
    }
  }

  cout << sum << endl;

  return 0;
}

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