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 <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int bas = 0;
    int tri = 0;
    int fou = 0;

    VI total;
    VI odd;

    VI ans_total(1e06, INF);
    VI ans_odd(1e06, INF);

    while (1) {
        bas++;
        tri += bas;
        fou += tri;
        if (fou >= 1e06) {
            break;
        }
        total.push_back(fou);
        ans_total[fou] = 1;
        if (fou % 2 == 1) {
            odd.push_back(fou);
            ans_odd[fou] = 1;
        }

    }
    int size_total = (int)total.size();
    int size_odd = (int)odd.size();
    int posi;

    for (int i = 0; i < size_total; i++) {
        posi = total[i];
        for (int j = posi + 1; j < 1e06; j++) {
            ans_total[j] = min(ans_total[j], ans_total[posi] + ans_total[j - posi]);
        }
    }
    for (int i = 0; i < size_odd; i++) {
        posi = odd[i];
        for (int j = posi + 1; j < 1e06; j++) {
            ans_odd[j] = min(ans_odd[j], ans_odd[posi] + ans_odd[j - posi]);
        }
    }

    int input;
    while (1) {
        cin >> input;
        if (input == 0) {
            break;
        }
        cout << ans_total[input] << " " << ans_odd[input] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

struct State{
    int lower,size,rest;
    State(int lower,int size,int rest) : lower(lower),size(size),rest(rest) {};
};

int main(){
    vector<int> v;
    vector<int> odd;
    for(int i=1;;i++){
        int c = i*(i+1)*(i+2)/6;
        if(c > 1000000) break;
        v.push_back(c);
        if(c % 2 == 1) odd.push_back(c);
    }
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        queue<State> que;
        que.push(State(0,0,n));
        int ret;
        while(!que.empty()){
            State s = que.front();
            que.pop();
            if(s.rest == 0){
                ret = s.size;
                break;
            }
            for(int i=s.lower;v[i] <= s.rest;i++){
                que.push(State(i,s.size+1,s.rest-v[i]));
            }
        }
        int oret;
        que = queue<State>();
        que.push(State(0,0,n));
        while(!que.empty()){
            State s = que.front();
            que.pop();
            if(s.rest == 0){
                oret = s.size;
                break;
            }
            for(int i=lower_bound(all(odd),s.rest)-odd.begin();
                i>=0;i--){
                que.push(State(i,s.size+1,s.rest-odd[i]));
            }
            //for(int i=s.lower;odd[i] <= s.rest;i++){
        }
        cout << ret << " " << oret << endl;
    }
    return 0;
}