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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll dp1[1000005];
ll dp2[1000005];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(ll i = 1; i <= 1000000; i++) {
        dp1[i] = INF;
        dp2[i] = INF;
    }
    ll tmp = 0;
    while(true) {
        tmp++;
        ll now = tmp * (tmp + 1) * (tmp + 2) / 6;
        //cerr << tmp << " " << now << endl;
        if(now > 1000000) break;
        for(ll after = now; after <= 1000000; after++) {
            dp1[after] = min(dp1[after], dp1[after-now] + 1);
        }
        if(now % 2 == 0) continue;
        for(ll after = now; after <= 1000000; after++) {
            dp2[after] = min(dp2[after], dp2[after-now] + 1);
        }
    }
        while(true) {
            int n;
            cin >> n;
            if(n == 0) break;
            cout << dp1[n] << " " << dp2[n] << endl;
        }
    return 0;
}

C++: #include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vll proc(200, 0);
    for (ll i = 1; i < 200; i++) proc[i] = i * (i + 1) * (i + 2) / 6;

    vll dp(1000005, HIGHINF), odd_dp(1000005, HIGHINF);
    dp[0] = odd_dp[0] = 0;
    for (ll i = 0; i < 1000005; i++) {
        for (ll j = 0; j < 200; j++) {
            if (i - proc[j] >= 0) {
                chmin(dp[i], dp[i - proc[j]] + 1);
                if (proc[j] % 2 == 1) chmin(odd_dp[i], odd_dp[i - proc[j]] + 1);
            }
        }
    }

    ll n;
    while (true) {
        cin >> n;
        if (n == 0) break;
        cout << dp[n] << ' ' << odd_dp[n] << '\n';
    }
    return 0;
}

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

int main(){
   int tetra[181];
   int dp[MAX+1],dpodd[MAX+1];
   for(int i=0;i<MAX+1;i++) {dp[i]=i; dpodd[i]=i;}
   for(int i=1;i<181;i++){
      tetra[i-1] = i * (i+1) * (i+2) / 6;
   }
   for(int i=0;i<180;i++){
      int p = tetra[i];
      for(int j=0;p+j <= MAX;j++){
         if(dp[p+j] > dp[j]) dp[p+j] = dp[j] + 1;
         if(p%2 == 1){
            if(dpodd[p+j] > dpodd[j]) dpodd[p+j] = dpodd[j] + 1;
         }
      }
   }
   while(1){
      int n;
      cin >> n;
      if(n==0) break;
      cout << dp[n] << " " << dpodd[n] << endl;
   }
}