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 <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main(){
	std::vector<int> quadruple{ 1, 3 }, quadruple_double, quadruple_odd;
	while (quadruple[quadruple.size() - 2] <= 1000000) {
		quadruple.push_back(quadruple.back() + quadruple.size() + 1);
		quadruple[quadruple.size() - 2] += quadruple[quadruple.size() - 3];
	}
	quadruple.pop_back(); quadruple.pop_back();
	for (auto i = 0; i < quadruple.size(); ++i) {
		for (auto j = 0; j <= i; ++j) {
			quadruple_double.push_back(quadruple[i] + quadruple[j]);
		}
	}
	std::sort(quadruple_double.begin(), quadruple_double.end());
	quadruple_double.erase(std::unique(quadruple_double.begin(), quadruple_double.end()), quadruple_double.end());
	std::copy_if(quadruple.begin(), quadruple.end(), std::back_inserter(quadruple_odd), [](const int a) {return a % 2 == 1; });
	std::vector<int> min_odd(1000001, 1000000);
	min_odd[0] = 0;
	for (auto i = 0; i < min_odd.size(); ++i) {
		for (const auto o : quadruple_odd) if (o + i < min_odd.size()) {
			if (min_odd[o + i] > min_odd[i] + 1) {
				min_odd[o + i] = min_odd[i] + 1;
			}
		}
		else break;
	}

	while (true) {
		int n; std::cin >> n; if (n == 0) return 0;
		if (std::binary_search(quadruple.begin(), quadruple.end(), n)) {
			std::cout << 1;
		}
		else if (std::binary_search(quadruple_double.begin(), quadruple_double.end(), n)) {
			std::cout << 2;
		}
		else if (std::any_of(quadruple.begin(), quadruple.end(), [&quadruple_double, n](const int q) {return std::binary_search(quadruple_double.begin(), quadruple_double.end(), n - q); })) {
			std::cout << 3;
		}
		else if (std::any_of(quadruple_double.begin(), quadruple_double.end(), [&quadruple_double, n](const int q) {return std::binary_search(quadruple_double.begin(), quadruple_double.end(), n - q); })) {
			std::cout << 4;
		}
		else {
			std::cout << 5;
		}
		std::cout << ' ' << min_odd[n] << '\n';
	}
}

C++: #include<cstdio>
#include<cstring>

#define MIN(X,Y) ((X)<(Y) ? (X) : (Y))

short tbl[2000000], otbl[2000000];

int main(void) {
    memset(tbl,0x7F, sizeof(tbl));
    memset(otbl,0x7F, sizeof(otbl));

    for(int i=1; i*i*i<1050000; i++)
        tbl[i*(i+1)*(i+2)/6] = 1;
    for(int i=1; i<1005000; i++)
        for(int j=1; i-j*(j+1)*(j+2)/6>0; j++)
            tbl[i] = MIN(tbl[i], 1+tbl[i-j*(j+1)*(j+2)/6]);

    for(int i=1; i*i*i<1050000; i+=4)
        otbl[i*(i+1)*(i+2)/6] = 1;
    for(int i=1; i<1005000; i++)
        for(int j=1; i-j*(j+1)*(j+2)/6>0; j+=4)
            otbl[i] = MIN(otbl[i], 1+otbl[i-j*(j+1)*(j+2)/6]);

    while(1) {
        int n;
        scanf("%d",&n);
        if(!n) break;
        printf("%d %d\n",tbl[n],otbl[n]);
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <cmath>
#include <queue>
#include <utility>
using namespace std;

using P = pair<int, int>;
using Iterator = vector<int>::iterator;
vector<int> s;
vector<int> odd_s;

void make_shimentai(){
    for(int i = 1; ; ++i){
        int sum = i * (i + 1) * (i + 2) / 6;

        if(sum >= 1000000) break;

        s.emplace_back(sum);

        if(sum % 2 == 1) odd_s.emplace_back(sum);
    }
}

int bfs(const int v, Iterator it, vector<int> &s, const int ans){
    // first:????¨????, second:?¶????????????°
    queue<P> q;
    q.push(make_pair(*it, 1));

    while(!q.empty()){
        P p = q.front(); q.pop();
        if(p.first == v) return p.second;

        for(Iterator it_ = s.begin(); it_ <= it; ++it_){
            int sum = p.first + *it_;
            if(sum <= v && p.second + 1 <= ans)
                q.push(make_pair(sum, p.second + 1));
        }
    }
    return INT_MAX;
}

int solve(const int v, vector<int> &s){
    Iterator it = lower_bound(s.begin(), s.end(), v);
    if(*it != v) it--;

    int ans = INT_MAX;

    for(;it != s.begin() - 1; --it){
        ans = min(ans, bfs(v, it, s, ans));
        if(ans == 1) break;
    }

    return ans;
}

/*int solve(const int v, vector<int> s){
  decltype(s)::iterator it = lower_bound(s.begin(), s.end(), v);
  if(*it != v) it--;

  int ans = INT_MAX;
  for(;it != s.begin()-1; it--){
  vector<int>::iterator it_ = it;
  int v_ = v;
  int count = 0;
  while(true){
  if(v_ == 0) break;
  if(v_ - *it_ < 0){
  it_--;
  continue;
  }

  v_ -= *it_;
  count++;
  if(ans < count) break;
  }
  ans = min(ans, count);
  }

  return ans;
  }*/

int main(){
    make_shimentai();

    while(true){
        int v;
        cin >> v;
        if(v == 0) break;

        int ans = solve(v, s);
        cout << ans << " ";
        ans = solve(v, odd_s);
        cout << ans << "\n";
    }

    return EXIT_SUCCESS;
}