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 <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
int dp[1000010];
int dp2[1000010];

int main(){
	int a = 1, b;
	vi v;
	vi u;
	while((b = a*(a+1)*(a+2)/6)<1e6){
		v.pb(b);
		if(b%2 == 1){
			u.pb(b);
		}
		a++;
	}
	//cout<<v.size()<<endl;
	for(int i = 0; i < 1000010; i++){
		dp[i] = INF;
		dp2[i] = INF;
	}
	dp[0] = 0;
	dp2[0] = 0;
	for(int i = 0; i < v.size(); i++){
		for(int j = v[i]; j < 1000010; j++){
			dp[j] = min(dp[j], dp[j-v[i]]+1);
			if(i < u.size()){
				dp2[j] = min(dp2[j], dp2[j-u[i]]+1);
			}
		}
	}
	//cout<<"OK"<<endl;
	int n;
	while(cin>>n && n > 0){
		cout<<dp[n]<<" "<<dp2[n]<<endl;
	}
}

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

#define MAXNUM 1000001
#define MAX 100
using namespace std;

int all[MAXNUM], odd[MAXNUM], fourall[1000], fourodd[1000];

int main()
{
	int n;
	int counter = 0;

	//配列の初期化
	for (int i = 1; i < MAXNUM; i++){
		all[i] = MAX;
		odd[i] = MAX;

	}

	//1からMAXNUMまでの中に存在する正四面体数を洗い出す．
	int now = 0, four, allcounter = 1, oddcounter = 1;
	while (1){
		now++;
		four = now  *(now + 1)*(now + 2) / 6;
		all[four] = 1;
		fourall[allcounter++] = four;
		if (four % 2 == 1){
			odd[four] = 1;
			fourodd[oddcounter++] = four;
		}
		if (four > MAXNUM * 2)
			break;

	}
	cout << "ok" << endl;

	//1からMAXNUMまで，配列を埋める.
	for (int i = 1; i < MAXNUM; i++){
		for (int j = 1; i > fourall[j]; j++){
			all[i] = min(all[i], 1 + all[i - fourall[j]]);
			if (i > fourodd[j])
				odd[i] = min(odd[i], 1 + odd[i - fourodd[j]]);
		}
	}

	cout << "a";
	//入力
	while (cin >> n, n)
		cout << all[n] << " " << odd[n] << endl;

	return 0;

}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[111111];
int memo2[111111];
 
int solve(int n){
   
  if(!n) return 0;
  if(~memo[n]) return memo[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(p[i]&1 && n >= p[i]) ans = min(ans, solve2(n-p[i])+1);
 
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));
 
  for(int i=0;i<181;i++) p[i] = i*(i+1)*(i+2)/6;

  for(int i=0;i<111111;i++){ solve(i), solve2(i); }
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
 
}

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

int main(){
	int num[100010];
	for(int i=0; i< 100010; i++) num[i] = 10e8;
	num[0] = 0;
	for(int j=0; j< 100010; j++){
		for(int i=1; i < 1000; i++){
			int m = i*(i+1)*(i+2)/6;
			if(10010 <= i*(i+1)*(i+2)/6+j) continue;
			num[j+m] = min(num[j]+1, num[j+m]);
		}
	}
	int num2[100010];
	for(int i=0; i< 100010; i++) num2[i] = 10e8;
	num2[0] = 0;
	for(int j=0; j< 100010; j++){
		for(int i=1; i < 1010; i++){
			int m = i*(i+1)*(i+2)/6;
			if(m == 0) continue;
			if(m%2 == 0) continue;
			if(10010 <= i*(i+1)*(i+2)/6+j) continue;
			num2[j+m] = min(num2[j]+1, num2[j+m]);
		}
	}
	int n;
	while(cin >> n, n){
		cout << num[n] << " " << num2[n] << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
using P = pair<int,int>;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)

int main(){
    const int MAX = 1000000;
    vector<int> tetra,tetra_odd;
    vector<int> ans(MAX+1,MAX), ans_odd(MAX+1,MAX);
    ans[0] = 0;
    ans_odd[0] = 0;

    int n=1;
    while(n*(n+1)*(n+2) / 6 <= MAX){
        int k = n*(n+1)*(n+2) / 6;
        tetra.emplace_back(k);
        if(k&1) tetra_odd.emplace_back(k);
        n++;
    }

    for(int i=0;i<=MAX;i++){
        for(int j=0;j<tetra.size();j++){
            if(i-tetra[j] < 0) continue;
            ans[i] = min(ans[i],ans[i-tetra[j]]+1);
        }
    }

    for(int i=0;i<=MAX;i++){
        for(int j=0;j<tetra_odd.size();j++){
            if(i-tetra_odd[j] < 0) continue;
            ans_odd[i] = min(ans_odd[i],ans_odd[i-tetra_odd[j]]+1);
        }
    }

    int N;
    while(cin >> N, N != 0){
        cout << ans[N] << " " << ans_odd[N] << endl;
    }
}