Go: package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	var nums []int
	for i := 1; i < 2*100+1; i++ {
		nums = append(nums, i*(i+1)*(i+2)/6)
	}
	var ins []int
	N := 0
	for true {
		n := sc.nextInt()
		if n == 0 {
			break
		}
		ins = append(ins, n)
		N = max(N, n)
	}
	dp := make([]int, N+1)
	dp2 := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		dp[i] = INF
		dp2[i] = INF
	}
	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n > N {
			break
		}
		for j := 0; j < N+1; j++ {
			if j >= n {
				dp[j] = min(dp[j], dp[j-n]+1)
				if n%2 != 0 {
					dp2[j] = min(dp2[j], dp2[j-n]+1)
				}
			}
		}
	}
	for i := 0; i < len(ins); i++ {
		fmt.Fprintln(wtr, dp[ins[i]], dp2[ins[i]])
	}
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 10007;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int dp[1001000],dp2[1001000];
vector<int> pollock, pollock2;
int main() {
	for (int i = 1;; i++) {
		LL num = i;
		num *= (num + 1)*(num + 2);

		if (num > 1000000)break;

		if (i % 2 == 0)pollock2.emplace_back(num);
		pollock.emplace_back(num);
	}
	for (int i = 0; i < 1000000; i++) {
		dp[i] = dp2[i] = i;
	}
	for (int i = 1; i < pollock.size(); i++) {
		for (int j = pollock[i]; j <= 1000000; j++) {
			dp[j] = min(dp[j], dp[j - pollock[i]] + 1);
		}
	}
	for (int i = 1; i < pollock2.size(); i++) {
		for (int j = pollock2[i]; j <= 1000000; j++) {
			dp2[j] = min(dp2[j], dp2[j - pollock2[i]] + 1);
		}
	}
	int n;
	while (cin >> n&&n) {
		cout << dp[n] << " " << dp2[n] << endl;
	}
}

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

int tr[300];
int sq[300];
int dp1[1000000];
int dp2[1000000];

int main() {

  for(int i=1; i < 300; i++) {
    tr[i] = tr[i-1] + i;
    sq[i] = sq[i-1] + tr[i];
  }
  for(int i=1; i < 1000000; i++) {
      dp1[i] = 1000111000;
      dp2[i] = 1000111000;
  }

  cout << sq[30] << endl;
  for(int i=0; i<1000000; i++) {
    for(int j=1; j < 300; j++) {
      if(i+sq[j] < 1000000) {
        dp1[i+sq[j]] = min(dp1[i] + 1, dp1[i+sq[j]]);
        if(sq[j]%2 == 1) {
          dp2[i+sq[j]] = min(dp2[i] + 1, dp2[i+sq[j]]);
        }
      }
    }
  }

  int n;
  while(cin >> n, n) {
    cout << dp1[n] << " " << dp2[n] << endl;
  }

  return 0;
}

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

int main(){
  const int N = 1000000;
  int dp[2][N+1], n;
  
  for(int i=0;i<=N;i++)dp[0][i] = dp[1][i] = N;
  dp[0][0] = dp[1][0] = 0;
  
  int val = 1;
  for(int i=1;val<=N;i++){
    for(int j=0;j+val<=N;j++){
      int nxt = j+val;
      dp[0][nxt] = min(dp[0][nxt],dp[0][j] + 1);
      if(val&1)dp[1][nxt] = min(dp[1][nxt],dp[1][j] + 1);
    }
    val = i*(i+1)*(i+2)/6;
  }

  while(scanf("%d",&n),n)printf("%d %d\n",dp[0][n],dp[1][n]);
}

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

int main(){
	vector<int> ttr;
	int n = 1;
	while(1){
		int tr = n*(n+1)*(n+2) / 6;
		if(tr > 1000000) break;
		ttr.push_back(tr);
		n++;
	}

	vector<int> dp(1000010,1000000);
	vector<int> dp_odd(1000010,1000000);
	dp[0] = dp_odd[0] = 0;

	for( int i = 0; i < ttr.size(); i++ ){
		for( int j = 0; j < 1000000-ttr[i]+1; j++ ){
			dp[j+ttr[i]] = min(dp[j+ttr[i]], dp[j]+1);
			if(ttr[i] % 2) dp_odd[j+ttr[i]] = min(dp_odd[j+ttr[i]], dp_odd[j]+1);
		}
	}

	while(cin >> n, n){
		cout << dp[n] << ' ' << dp_odd[n] << endl;
	}
}

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

int dp[2][1000001];

int f(int n)
{
    return n * (n + 1) * (n + 2) / 6;
}

int main()
{
    int n;
    while(cin >> n && n) {
        for(int k = 0; k < 2; k++)
            fill(dp[k], dp[k] + 1000001, 1000000);
        
        dp[0][0] = dp[1][0] = 0;
        for(int i = 1; i <= n; i++) {
            for(int k = 1; ; k++) {
                int num = f(k);
                if(i - num >= 0) {
                    dp[0][i] = min(dp[0][i], dp[0][i - num] + 1);
                    if((num % 2) == 1) {
                        dp[1][i] = min(dp[1][i], dp[1][i - num] + 1);
                    }
                } else {
                    break;
                }
            }
        }
        cout << dp[0][n] << " " << dp[1][n] << endl;
    }
}