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 <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;

int d[1000001];
int d2[1000001];

int main()
{
	int n;
	Fill(d, INF);
	Fill(d2, INF);
	
	vector<int> v,v2;
	for (int i = 1;; i++){
		int t = i * (i + 1) * (i + 2) / 6;
		if (t > 1e6)break;
		v.push_back(t);
		d[t] = 1;
		if (t % 2){
			d2[t] = 1;
			v2.push_back(t);
		}
	}

	For(i,1, 1e6){
		rep(j, v.size())if(i + v[j] < 1e6){
			d[i + v[j]] = min(d[i + v[j]], d[i] + 1);
		}
		rep(j, v2.size())if (i + v2[j] < 1e6){
			d2[i + v2[j]] = min(d2[i + v2[j]], d2[i] + 1);
		}
	}

	while (cin >> n && n){

		cout << d[n] << " " << d2[n] << endl;

	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	vector<int> tet;
	vector<int> tet_odd;
	for (int i = 1; i*(i+1)*(i+2)<6000000; ++i) {
		tet.push_back((i*(i+1)*(i+2))/6);
		if (i%4 == 1) tet_odd.push_back((i*(i+1)*(i+2))/6);
	}
	reverse(tet_odd.begin(), tet_odd.end());
	set<int> tet_one, tet_two, tet_three;
	for (int t : tet) {
		tet_one.insert(t);
		for (int u : tet) {
			tet_two.insert(t+u);
			for (int v : tet) {
				tet_three.insert(t+u+v);
			}
		}
	}
	int dp[1000001];
	for (int i = 0; i < 1000001; ++i) dp[i] = i;
	for (int i = 2; i < 1000001; ++i) {
		for (int to : tet_odd) {
			if (i>=to) dp[i] = min(dp[i], dp[i-to]+1);
		}
	}

	while (1) {
		int x; cin >> x;
		int ans1 = 5;
		if (x == 0)	return 0;
		auto on = tet_one.find(x);
		auto tw = tet_two.find(x);
		auto th = tet_three.find(x);
		if (on != tet_one.end()) ans1 = 1;
		else if (tw != tet_two.end()) ans1 = 2;
		else if (th != tet_three.end()) ans1 = 3;
		else {
			for (int i = 2; i*2 <= x; ++i)
			{
				auto fo = tet_two.find(i);
				auto ur = tet_two.find(x-i);
				if (fo != tet_two.end() && ur != tet_two.end()) {
					ans1 = 4;
					break;
				}
			}
		}

		cout << ans1 << " " << dp[x] << endl;
	}
}

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

const int N = 1000000;
int dp[2][N+1];

int main(){
  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;
      if(dp[0][nxt]>dp[0][j])dp[0][nxt] = dp[0][j] + 1;
      if( (val&1) && (dp[1][nxt]>dp[1][j]))dp[1][nxt] = dp[1][j] + 1;
    }
    val *= (i+3), val /= i;
  }

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

C++: 
#include <iostream>
#include <vector>

using namespace std;

#define INF 1000000000


#define MAX_N 1000000

int N;

vector<pair<int, int> > ans_list;

int memo[MAX_N];

//nを作るのに必要な正四面体数の最小数を返す関数
int solve(int n){
  if(memo[n] > 0)
    return memo[n];

  if(n == 1)
    return memo[1] = 1;

  bool tmp_flag = false;
  int tmp = INF;
  for(int i = 1; i*(i+1)*(i+2)/6 <= n; i++){
    if(i*(i+1)*(i+2)/6 == n){
      tmp_flag = true;
      break;
    }
    tmp =  min(tmp, solve(i*(i+1)*(i+2)/6) + solve(n - i*(i+1)*(i+2)/6));
  }

  if(tmp_flag)
    tmp = 1;

  return memo[n] = tmp;

}

int odd_memo[MAX_N];

//nを作るのに必要な正四面体数の最小値を返す関数(奇数版)
int odd_solve(int n){
  
  if(odd_memo[n] > 0)
    return odd_memo[n];

  if(n == 1)
    return odd_memo[n] = 1;

  bool tmp_flag = false;
  int tmp = INF;
  for(int i = 1; i*(i+1)*(i+2)/6 <= n; i++){
    int a = i*(i+1)*(i+2)/6;
    int b = n-a;
    if(a == n && a%2 == 1){
      tmp_flag = true;
      break;
    }
    if(a % 2 == 1 || b%2 == 1)
      tmp =  min(tmp, odd_solve(a) + odd_solve(b));
  }

  if(tmp_flag)
    tmp = 1;

  return odd_memo[n] = tmp;

}


int main(){

  while(true){
    cin >> N;
    if(N == 0)
      break;

    ans_list.push_back(make_pair(solve(N), odd_solve(N)));

  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i].first << " " << ans_list[i].second << endl;
  }

  return 0;

}

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

const int N = 1000000;
int dp[2][N+1];

int main(){
  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=2;val<=1000000;i++){
    for(int j=0;j+val<=1000000;j++){
      dp[0][j+val] = min(dp[0][j+val],dp[0][j] + 1);
      if(val&1)dp[1][j+val] = min(dp[1][j+val],dp[1][j] + 1);
    }
    val = i*(i+1)*(i+2)/6;
  }

  int n;
  while(cin >> n,n)cout << dp[0][n] << " " << dp[1][n] << endl;
}