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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    vector<int> v;
    int cnt = 1;

    while(true){
        
        int tmp = (cnt*(cnt+1)*(cnt+2))/6;
        if(tmp > 1000000) break;
        v.push_back(tmp);
        cnt++;
    }
    int s = v.size();
    int dp[1000005];
    int  odd[1000005];
    for(int i = 0; i < 1000005;i++){
        dp[i] = inf;
        odd[i] = inf;
    }
    dp[0] = 0;
    dp[1] = 1;
    odd[0] = 0;
    odd[1] = 1;
    for(int i = 0; i < 1000005; i++){
        for(int j = 0; j < v.size(); j++){
            if(i + v[j] < 1000005){
                dp[i+v[j]] = min(dp[i+v[j]],dp[i] + 1); 
                if(v[j] % 2 == 1){
                    odd[i+v[j]] = min(odd[i+v[j]],odd[i] + 1); 
                }
            }
        }
    }
    while(true){
        int x;  cin >> x;
        if(x == 0) break;
        cout << dp[x] << ' ' << odd[x] << endl;
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;



int main() {
    int MAX = 10e6;

    vector<int> dp(MAX+1, INF);
    vector<int> odd_dp(MAX+1, INF);

    dp[0] = 0;
    odd_dp[0] = 0;


    // FOR(i,0,10e6+1){
    //     cout << i << endl;
    //     FOR(j,1,1000){
    //         int num = j*(j+1)*(j+2)/6;
    //         if (i+num >= 10e6) break;
    //         dp[i+num] = min(dp[i+num], dp[i]+1);
    //         if(j%2 == 0){
    //             odd_dp[i+num] = min(odd_dp[i+num], odd_dp[i]+1);
    //         }
    //     }
    // }

    FOR(j,1,1000){
        int num = j*(j+1)*(j+2)/6;
        if (num > MAX) break;
        FOR(i,0,MAX+1){
            if (i+num > MAX) break;
            dp[i+num] = min(dp[i+num], dp[i]+1);
            if(num%2 == 1){
                odd_dp[i+num] = min(odd_dp[i+num], odd_dp[i]+1);
            }
        }
    }

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

        cout << dp[N] << " " << odd_dp[N] << endl;

    }
    return 0;
}

// #include <iostream>
// #include <vector>
// using namespace std;

// const int MAX = 1000100;
// const int INF = 1<<29;

// int main() {
//     vector<int> dp(MAX, INF), odddp(MAX, INF);
//     dp[0] = odddp[0] = 0;
//     for (int i = 1;; ++i) {
//         int num = i * (i+1) * (i+2) / 6;
//         if (num >= MAX) break;
//         for (int j = num; j < MAX; ++j) {
//             dp[j] = min(dp[j], dp[j-num]+1);
//             if (num & 1) odddp[j] = min(odddp[j], odddp[j-num]+1);
//         }
//     }
//     int n;
//     while (cin >> n) {
//         if (n == 0) break;
//         cout << dp[n] << " " << odddp[n] << endl;
//     }
// }

C++: #include<stdio.h>
#include<vector>
std::vector<int>t,o;
const int N=1000000,V=1<<9;
int a[N],b[N];
int main()
{
	int i,j,n;
	for(i=1;i<N;++i)a[i]=b[i]=V;
	for(i=1;n=(i*(i+1)*(i+2))/6,n<N;++i)if(a[n]=1,t.push_back(n),n&1)b[n]=1,o.push_back(n);
	for(i=t.size()-1;i>=0;--i)
	{
		a[t[i]]=1;
		for(j=t[i];j+t[i]<N;++j)if(a[j]+1<a[j+t[i]])a[j+t[i]]=a[j]+1;
	}
	for(i=o.size()-1;i>=0;--i)
	{
		b[o[i]]=1;
		for(j=o[i];j+o[i]<N;++j)if(b[j]+1<b[j+o[i]])b[j+o[i]]=b[j]+1;
	}
	while(scanf("%d",&n),n)printf("%d %d\n",a[n],b[n]);
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int ball[210], dp1[1000010], dp2[1000010];

int main() {
    for(int i = 1; i <= 200; i++) {
        ball[i] = i * (i + 1) * (i + 2) / 6;
    }

    fill_n(dp1, 1000010, iINF);
    fill_n(dp2, 1000010, iINF);
    dp1[0] = 0;
    dp2[0] = 0;

    for (int i = 1; i <= 1000000; i++) {
        for (int j = 1; j <= 200; j++) {
            if (i - ball[j] < 0) continue;
            dp1[i] = min(dp1[i], dp1[i - ball[j]] + 1);
            if (ball[j] & 1) dp2[i] = min(dp2[i], dp2[i - ball[j]] + 1);
        }
    }

    int N;
    while(cin >> N && N) {
        cout << dp1[N] << " " << dp2[N] << endl;
    }
}