Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const N = 100

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var p [N]int
	var m [N + 1][N + 1]int
	for i := 1; i <= n; i++ {
		sc.Scan()
		p[i-1], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		p[i], _ = strconv.Atoi(sc.Text())
	}

	for l := 2; l <= n; l++ {
		for i := 1; i <= n-l+1; i++ {
			j := i + l - 1
			m[i][j] = (1 << 21)
			for k := i; k <= j-1; k++ {
				m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
			}
		}
	}

	return fmt.Sprintf("%d", m[1][n])
}

func main() {
	fmt.Println(answer(os.Stdin))
}

C++: #include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int dp[101][101] = {0};
int pa[100];
int solve(int i, int j) {
    if(i == j)
        return dp[i][j] = 0;
    else if(dp[i][j] != 0)
        return dp[i][j];
    else {
        int mi = INFINT;
        int lr = pa[i - 1] * pa[j];
        for(int k = 0; k < j - i; k++) {
            mi =
                min(mi, solve(i, i + k) + solve(i + k + 1, j) + lr * pa[i + k]);
        }
        return dp[i][j] = mi;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, g;
    cin >> n >> pa[0] >> pa[1];
    rep(i, 1, n) cin >> g >> pa[i + 1];

    rep(i, 1, n + 1) rep(j, 1, n + 1) dp[i][j] = 0;
    rep(i, 1, n) dp[i][i + 1] = pa[i - 1] * pa[i] * pa[i + 1];

    cout << solve(1, n) << endl;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;

static const int N = 100;

int main(){
int n,p[N+1],m[N+1][N+1];
cin >> n;

for(int i=1;i<=n;i++){
cin >> p[i-1] >> p[i];
}

for(int i=1;i<=n;i++) m[i][i]=0;
for(int l=2;l<=n;l++){
for(int i=1;i<=n-l+1;i++){
int j=i+l-1;
m[i][j]=(1<<10);
for(int k = i;k<=j-1;k++){
m[i][j]=min(m[i][j],m[i][k]+m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
}
}
}
cout << m[1][n]<< endl;

return 0;

}

C++: #include <iostream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
	}
	cout << 0 << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll dp[200][200];
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() { 
  int n;
  cin >> n;
  Fill(dp,INT_MAX);
  vl r(n+1),c(n);
  rep(i,n) cin >> r[i] >> r[i+1];
  rep(i,n) dp[i][i] = 0;
  

  for(int w = 1;w<n;w++){
    for(int i =0;i+w<n;i++){
      int j = i+w;
      for(int k=i;k<j;k++){
        ll prod = r[i]*r[k+1]*r[j+1];
        dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]+prod);
      }
    }
  }
  cout<<dp[0][n-1]<<endl;
  return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <array>
#include <memory>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf(" %d", list[i]);
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _Matrix {
    int row;
    int col;
} Matrix;

std::map<string, int> memo;
int GetCost(const vector<Matrix> list, int begin, int end)
{
    // printf("%d - %d\n", begin, end);
    if (begin == end) return 0;
    string hash = std::to_string(begin) + "," + std::to_string(end);
    if (memo[hash] != 0) return memo[hash];
    int min = std::numeric_limits<int>::max();
    for(int p = begin; p < end; p++){
        int r  = list[begin].row;
        int c1 = list[p].col;
        int c2 = list[end].col;
        int left = GetCost(list, begin, p);
        int right = GetCost(list, p + 1, end);
        min = std::min(min, left + right + r * c1 * c2);
        string lhash = std::to_string(begin) + "," + std::to_string(p);
        string rhash = std::to_string(p + 1) + "," + std::to_string(end);
        memo[lhash] = left;
        memo[rhash] = right;
        // min = std::min(min, GetCost(list, begin, p) + GetCost(list, p + 1, end) + r * c1 * c2);
    }
    return min;
}

void solve() {
    int n;
    scanf("%d", &n);
    vector<Matrix> matrixList(n);
    for(int i = 0; i < n; i++){
        int r, c;
        scanf("%d %d", &r, &c);
        matrixList[i] = {r,c};
    }
    int cost = GetCost(matrixList, 0, n - 1);
    printf("%d\n", cost);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    solve();
    return 0;
}