Language: C++

#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)

const int MAX = 410;
const ll INF = LLONG_MAX;
int N;
ll dp[MAX][MAX], size[MAX];

ll get_size(int l, int r) {
  return size[r+1] - size[l];
}

ll solve(int l, int r) {
  if (l >= r) return 0;
  if (dp[l][r] >= 0) return dp[l][r];
  if (r-l == 1) return dp[l][r] = get_size(l, r);

  ll ret = INF;
  FOR (i, l, r+1) ret = min(ret, solve(l, i-1) + solve(i+1, r) + min(get_size(l, i), get_size(i, r)) + get_size(l, r));
  return dp[l][r] = ret;
}

int main () {
  cin >> N;
  REP (i, MAX) REP (j, MAX) dp[i][j] = -1;
  size[0] = 0;
  REP (i, N) {
    cin >> a;
    size[i+1] = size[i] + a;
  }
  cout << solve(0, N-1) << endl;
}

Compiler output:
a.cc: In function 'll get_size(int, int)':
a.cc:16:10: error: reference to 'size' is ambiguous
   16 |   return size[r+1] - size[l];
      |          ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:13:18: note:                 'll size [410]'
   13 | ll dp[MAX][MAX], size[MAX];
      |                  ^~~~
a.cc:16:22: error: reference to 'size' is ambiguous
   16 |   return size[r+1] - size[l];
      |                      ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:13:18: note:                 'll size [410]'
   13 | ll dp[MAX][MAX], size[MAX];
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:32:3: error: reference to 'size' is ambiguous
   32 |   size[0] = 0;
      |   ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:13:18: note:                 'll size [410]'
   13 | ll dp[MAX][MAX], size[MAX];
      |                  ^~~~
a.cc:34:12: error: 'a' was not declared in this scope
   34 |     cin >> a;
      |            ^
a.cc:35:5: error: reference to 'size' is ambiguous
   35 |     size[i+1] = size[i] + a;
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:13:18: note:                 'll size [410]'
   13 | ll dp[MAX][MAX], size[MAX];
      |                  ^~~~
a.cc:35:17: error: reference to 'size' is ambiguous
   35 |     size[i+1] = size[i] + a;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:13:18: note:                 'll size [410]'
   13 | ll dp[MAX][MAX], size[MAX];
      |                  ^~~~