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;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

// 正四面体数
vector<int> all, odd;

const int MAX = 1000000;
vector<int> dp, dp2;

bool solve() {
    int n;
    cin >> n;
    if(n == 0) {
        return 0;
    }
    print(dp[n], dp2[n]);
    return 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 1;; i++) {
        int s = i * (i + 1) * (i + 2) / 6;
        if(s >= 1000000) {
            break;
        }
        all.emplace_back(s);
        if(s & 1) {
            odd.emplace_back(s);
        }
    }
    int N = all.size();
    dp.assign(MAX + 1, INF);
    dp[0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = all[i]; j <= MAX; j++) {
            chmin(dp[j], dp[j - all[i]] + 1);
        }
    }
    N = odd.size();
    dp2.assign(MAX + 1, INF);
    dp2[0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = odd[i]; j <= MAX; j++) {
            chmin(dp2[j], dp2[j - odd[i]] + 1);
        }
    }
    while(1) {
        if(!solve()) {
            break;
        }
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll inf = 1e8;
const ll co = 1000005;

ll dp[2][1000005];

int main() {
    rep(i,2)rep(j,co) dp[i][j] = inf;
    dp[0][0] = dp[1][0] = 0;
    for (int i = 1; i*(i+1)*(i+2)/6 < co; i++) {
        int l = i*(i+1)*(i+2)/6;
        for (int j = 1; j <= co; j++) {
            if (j >= l) dp[0][j] = min(dp[0][j],dp[0][j-l]+1);
        }
        if (l&1) {
            for (int j = 1; j <= co; j++) {
                if (j >= l) dp[1][j] = min(dp[1][j],dp[1][j-l]+1);
            }
        }
    }

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

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    vector<int>csum;
    int cnt = 1;
    for(;;){
        if(csum.size()&&csum.back()  > 1000000)break;
        csum.push_back(cnt*(cnt+1)*(cnt+2)/6);
        cnt ++;
    }
    csum.pop_back();
    int dp1[1000000+1];
    int dp2[1000000+1];
    rep(i,1000000+1)dp1[i] = dp2[i] = INF;
    dp1[0] = dp2[0] = 0;
    rep(i,1000000+1){
        if(dp1[i] == INF)continue;
        rep(j,csum.size()){
            if(i + csum[j] > 1000000 || csum[j]%2==0)continue;
            cmin(dp1[i+csum[j]],dp1[i]+1);
        }
    }
    rep(i,1000000+1){
        if(dp2[i] == INF)continue;
        rep(j,csum.size()){
            if(i + csum[j] > 1000000)continue;
            cmin(dp2[i+csum[j]],dp2[i]+1);
        }
    }
    int n;
    while(cin >> n,n){
        cout << dp2[n] << " " << dp1[n] << endl;
        
    }
}