// This file is generated by mkfile.py
// Date: 2025-09-29

#include <limits.h>
#include <solution/1039.h>

#define min(x, y) (x) < (y) ? (x) : (y)

int minScoreTriangulation(int *values, int valuesSize)
{
    int dp[valuesSize][valuesSize];
    for (int i = 0; i < valuesSize; i++)
        for (int j = 0; j < valuesSize; j++)
            dp[i][j] = 0;

    for (int len = 2; len < valuesSize; len++)
    {
        for (int i = 0; i + len < valuesSize; i++)
        {
            int j = i + len;
            dp[i][j] = INT_MAX;

            for (int k = i + 1; k < j; k++)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + values[i] * values[j] * values[k]);
            }
        }
    }
    return dp[0][valuesSize - 1];
}