Language: C++

#pragma GCC optimize("Ofast")
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define long long int __int128
const int N=2e5+10;
int main(){
    ll ans,n,x,a[N],d1[N],d2[N],d[N],dp[N];
    scanf("%lld%lld",&n,&x);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    reverse(a,a+n);
    a[n]=0;
    for(int i=1;i<=n;i++)d[i]=a[i-1]-a[i];
    for(long long int i=1;i<=n;i++)d1[i]=d[i]*i;
    for(long long int i=1;i<=n;i++)d2[i]=d1[i]*i;
    d1[0]=d2[0]=0;
    for(int i=1;i<=n;i++){
        d1[i]+=d1[i-1];
        d2[i]+=d2[i-1];
    }
    dp[0]=5*a[0]+x;
    for(long long int i=1;i<n;i++){
        ans=a[0];
        for(long long int j=1;j<=i;j++)ans+=d[j]*(j+1)*(j+1);
        ans+=a[i]*(i+2)*(i+2)-d2[i]-a[i]*i*i;
        for(long long int j=0;j<i;j++)ans=min(ans,dp[j]+a[j+1]-d2[j+1]+a[j+1]*j*j-a[i]*j*j-j*2*(d1[i]-d1[j+1])+a[i]*(j*j+1-2*i*j-2*j+2*i));
        dp[i]=ans+x+d2[i]+a[i]*i*i;
    }
    printf("%lld\n",dp[n-1]+n*x);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:19: error: two or more data types in declaration of 'i'
    6 | #define long long int __int128
      |                   ^~~
a.cc:15:9: note: in expansion of macro 'long'
   15 |     for(long long int i=1;i<=n;i++)d1[i]=d[i]*i;
      |         ^~~~
a.cc:15:27: error: 'i' was not declared in this scope
   15 |     for(long long int i=1;i<=n;i++)d1[i]=d[i]*i;
      |                           ^
a.cc:6:19: error: two or more data types in declaration of 'i'
    6 | #define long long int __int128
      |                   ^~~
a.cc:16:9: note: in expansion of macro 'long'
   16 |     for(long long int i=1;i<=n;i++)d2[i]=d1[i]*i;
      |         ^~~~
a.cc:16:27: error: 'i' was not declared in this scope
   16 |     for(long long int i=1;i<=n;i++)d2[i]=d1[i]*i;
      |                           ^
a.cc:6:19: error: two or more data types in declaration of 'i'
    6 | #define long long int __int128
      |                   ^~~
a.cc:23:9: note: in expansion of macro 'long'
   23 |     for(long long int i=1;i<n;i++){
      |         ^~~~
a.cc:23:27: error: 'i' was not declared in this scope
   23 |     for(long long int i=1;i<n;i++){
      |                           ^
a.cc:6:19: error: two or more data types in declaration of 'j'
    6 | #define long long int __int128
      |                   ^~~
a.cc:25:13: note: in expansion of macro 'long'
   25 |         for(long long int j=1;j<=i;j++)ans+=d[j]*(j+1)*(j+1);
      |             ^~~~
a.cc:25:31: error: 'j' was not declared in this scope
   25 |         for(long long int j=1;j<=i;j++)ans+=d[j]*(j+1)*(j+1);
      |                               ^
a.cc:6:19: error: two or more data types in declaration of 'j'
    6 | #define long long int __int128
      |                   ^~~
a.cc:27:13: note: in expansion of macro 'long'
   27 |         for(long long int j=0;j<i;j++)ans=min(ans,dp[j]+a[j+1]-d2[j+1]+a[j+1]*j*j-a[i]*j*j-j*2*(d1[i]-d1[j+1])+a[i]*(j*j+1-2*i*j-2*j+2*i));
      |             ^~~~
a.cc:27:31: error: 'j' was not declared in this scope
   27 |         for(long long int j=0;j<i;j++)ans=min(ans,dp[j]+a[j+1]-d2[j+1]+a[j+1]*j*j-a[i]*j*j-j*2*(d1[i]-d1[j+1])+a[i]*(j*j+1-2*i*j-2*j+2*i));
      |                               ^