Go: package main

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

var cache [100][100]int

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	tables := []table{}
	for i := 0; i < num; i++ {
		sc.Scan()
		num1, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		num2, _ := strconv.Atoi(sc.Text())
		t := table{num1, num2}
		tables = append(tables, t)
	}

	fmt.Println(minimum(0, len(tables)-1, tables))
}

type table struct {
	v int
	h int
}

func minimum(i int, j int, t []table) int {
	if i == j {
		return 0
	}

	// fmt.Printf("i:%v j:%v\n", i, j)
	if cache[i][j] != 0 {
		return cache[i][j]
	}

	min := math.MaxInt64
	for k := i; k < j; k++ {
		p := t[i].v
		n := t[k].h
		q := t[j].h
		val := minimum(i, k, t) + minimum(k+1, j, t) + p*n*q
		if val < min {
			min = val
		}
	}

	cache[i][j] = min
	return min
}

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 << 21);
			for (int 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]);
			}
		}
	}
	cout << m[1][n] << endl;

	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define MAX 100
#define infinit 1e+8
int main() {
	int n,p[MAX],m[MAX+1][MAX+1];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i-1] >> p[i];
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (i == j || i==0 || j==0) m[i][j] = 0;
			else m[i][j] = infinit;
		}
    }
	for (int l = 2; l <= n; l++) {
		for (int i = 0; i <= n - l + 1;i++) {
			int j = i + l - 1;
			for (int 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]);
			}

		}
	}
	cout << m[1][n] << endl;
	

}

C++: #include <iostream>
#include <string>
#include <algorithm>

using namespace std;

static const int N = 1000;
static int c[N + 1][N + 1] = {};

static int lcs(string& X, string& Y) {
  const size_t m(X.size());
  const size_t n(Y.size());

  int lcs = 0;
  
  for (size_t i = 1; i <= m; i++) {
    for (size_t j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      }
      else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      lcs = max(lcs, c[i][j]);
    }
  }
  return lcs;
}

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

  string X, Y;
  for (int i = 0; i < n; i++) {
    cin >> X;
    cin >> Y;
    cout << lcs(X, Y) << endl;
  }
 
  return 0;
}

C++: #include <bits/stdc++.h>
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 << 21);
            for (int 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]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}

C++: #include <cassert>
// #include <algorithm>
#include <iostream>
#include <vector>
#include <climits>

struct TSize
{
    int r;
    int c;
    TSize() : r(0), c(0) {}
    TSize(int Ar, int Ac)
     : r(Ar), c(Ac)
    {}
};

class TMcmSolver
{
    typedef std::vector<std::vector<int> > TMatrix;
    TMatrix FMemo;
    const std::vector<TSize>& FChain;

    static int Count(const TSize& Left, const TSize& Right)
    {
        return Left.r * Right.c * Left.c;
    }
    int Solve(int s, int l)
    {
        assert(s <= l);
        if(s == l) return 0;
        if(FMemo[s][l] != 0) return FMemo[s][l];
        if(s + 1 == l){
            FMemo[s][l] = Count(FChain[s], FChain[l]);
        }else{
            int min = INT_MAX;
            for(int i = s; i < l; ++i){
                int c = Solve(s, i) + Count(TSize(FChain[s].r, FChain[i].c), TSize(FChain[i+1].r, FChain[l].c)) + Solve(i+1, l);
                min = std::min(min, c);
            }
            FMemo[s][l] = min;
        }
        // std::cout << "Solve! [" << s << "], [" << l << "]" << std::endl; 
        return FMemo[s][l];
    }
public:
    TMcmSolver(const std::vector<TSize>& Chain)
     : FChain(Chain)
    {
        FMemo.resize(Chain.size());
        for(std::size_t i = 0; i < FMemo.size(); ++i){
            FMemo[i].resize(Chain.size(), 0);
        }
    }
    int Answer()
    {
        return Solve(0, FMemo.size()-1);
    }
    void Print()const
    {
        for(std::size_t s = 0; s < FMemo.size(); ++s){
            for(std::size_t l = 0; l < FMemo[0].size(); ++l){
                std::cout << FMemo[s][l] << '\t';
            }
            std::cout << '\n';
        }
    }
};

int main()
{
    int n;
    std::cin >> n;
    if(n == 1){
        std::cout << 0 << std::endl;
        return 0;
    }
    std::vector<TSize> Chain(n);
    for(int i = 0; i < n; ++i){
        std::cin >> Chain[i].r >> Chain[i].c;
    }
    TMcmSolver Solver(Chain);
    
    std::cout << Solver.Answer() << std::endl;
    // Solver.Print();
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
using namespace std;


#define min(a, b) ((a) < (b) ? (a) : (b))

int N;
const int MAX_N = 110;
const int INF = 0x3fffffff;
int A[MAX_N];
int B[MAX_N];
int dp[MAX_N][MAX_N];

void init() {
    scanf("%d", &N);
    for(int i = 0; i < N; ++i)
        scanf("%d%d",&A[i], &B[i]);
    for(int i = 0 ;i < N; ++i)
        for(int j = 0; j < N; ++j)
            dp[i][j] = INF;
    for(int i = 0; i < N; ++i)
        dp[i][i] = 0;
}

int solve() {
    for(int k = 1; k < N; ++k) {
        for(int i = 0; i < N - k; ++i) {
            for(int j = i; j < i + k; ++j) {
                printf("i = %d j = %d k = %d\n", i, j, k);
                int sz = A[i] * B[j] * B[i + k];
                dp[i][i + k] = min(dp[i][i + k],dp[i][j] + dp[j+1][i + k] + sz);
            }
        }
    }
    // for(int i = 0; i < N; ++i) {                                                                                                                                              
    //  for(int j = 0; j < N; ++j)                                                                                                                                               
    //      printf("%d ", dp[i][j]);                                                                                                                                             
    //  printf("\n");                                                                                                                                                            
    // }                                                                                                                                                                         
    return dp[0][N - 1];
}

int main() {
    init();
    printf("%d\n", solve());
    return 0;
}