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 <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {

    vector<int> fourth_powers;
    FOR(i, 1, 1000) {
        int fourth_power = i * (i + 1) * (i + 2) / 6;
        if(fourth_power >= 1e6) break;
        fourth_powers.push_back(fourth_power);
    }
    vector<int> dp(1000005, 1e9), dp_odd(1000005, 1e9);
    
    dp[0] = 0;
    dp_odd[0] = 0;
    dp[1] = 1;
    dp_odd[1] = 1;

    FOR(i, 0, 1e6 + 2) {
        for(int x: fourth_powers) {
            if(i + x > 1e6) continue;
            dp[i + x] = min(dp[i + x], dp[i] + 1);
            if(x % 2 == 1)
                dp_odd[i + x] = min(dp_odd[i+x], dp_odd[i] + 1);
        }
    }

    // FOR(i, 1, 20) cerr << dp[i] << " " << dp_odd[i] << endl;

    while(true) {
        int N;
        cin >> N;
        if(N == 0) break;
        cout << dp[N] << " " << dp_odd[N] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF (1e9+7)

using namespace std;

int tetra[200];
int odd_tetra[200];
int tetracount[1000000];
int oddcount[1000000];

int dfs(int target){
  if(target == 0) return 0;
  if(tetracount[target] != 0) return tetracount[target];
  int res = INF;
  REP(i, 200){
    if(tetra[i] > target) continue;
    if(tetra[i] == 0) break;
    res = min(res, dfs(target - tetra[i]) + 1);
  }
  tetracount[target] = res;
  return res;
}

int odddfs(int target){
  if(target == 0) return 0;
  if(oddcount[target] != 0) return oddcount[target];
  int res = INF;
  REP(i, 200){
    if(odd_tetra[i] > target) continue;
    if(odd_tetra[i] == 0) break;
    res = min(res, odddfs(target - odd_tetra[i]) + 1);
  }
  oddcount[target] = res;
  return res;
}

int main(){
  REP(i, 200) tetra[i] = i * (i+1) * (i+2) / 6;
  int cnt = 0;
  REP(i, 200) if(tetra[i] % 2) odd_tetra[cnt++] = tetra[i];
  sort(tetra, tetra+200, greater<int>());
  sort(odd_tetra, odd_tetra+200, greater<int>());
  int n;
  while(cin >> n and n) cout << dfs(n) << " " << odddfs(n) << endl;
  return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <iostream>

using namespace std;

#define MAX_N 1000000

int N;
int inf = 1000000000;

int d[MAX_N+1], d2[MAX_N+1]; // ?????????j??¨?????????????????????????°??????°

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

int main() {
	d[0] = 0;
    for(int i = 1; i <= MAX_N; i++){
    	d[i] = inf;
       	for (int j = 1; ; j++)
        {
        	if(i < calc_sn(j)) break;
            d[i] = min(d[i], d[i-calc_sn(j)]+1);
        }
    }
    d2[0] = 0;
    for(int i = 1; i <= MAX_N; i++){
    	d2[i] = inf;
       	for (int j = 1; ; j++)
        {
        	if(i < calc_sn(j)) break;
        	if(calc_sn(j) % 2 == 0) continue;
            d2[i] = min(d2[i], d2[i-calc_sn(j)]+1);
        }
    }
    while(1){
    	cin >> N;
    	if(N == 0) break;
    	cout << d[N] << " " << d2[N] << endl;
    }
    return 0;
}

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

using namespace std;

int main(void) {
	int lim = 1000000;
	int dp[lim],odp[lim];
	for (int i = 0; i < lim; ++i) {
		dp[i] = i;
		odp[i] = i;
	}

	int num = 4;
	for (int now = 2; num < lim; ++now) {
		for (int i = num; i < lim; ++i) {
			dp[i] = min(dp[i],dp[i-num]+1);
		}
		if (num%2 == 1) {
			for (int i = num; i < lim; ++i) {
				odp[i] = min(odp[i],odp[i-num]+1);
			}
		}
		num = ((now+1)*(now+2)*(now+3))/6;
	}

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

	return 0;
}