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<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define POL_MAX 200
#define N_MAX 1000000
using namespace std;

int N;
int dp[N_MAX+1];
int odd_dp[N_MAX+1];
const int INF = INT_MAX / 3;

int main(){

	int n=1;
	int value=0;
	vector<int> pol, kisu_pol;
	while(true) {
		value = n*(n+1)*(n+2) / 6;
		if (value >= N_MAX) { break; }
		pol.push_back(value);
		if (value % 2 != 0) { kisu_pol.push_back(value); }
		n++;
	}

	rep(j, N_MAX+1) { dp[j] = j; }
	REP(j, 1, N_MAX+1) {
		REP(i, 1, pol.size()) {
			if(j<pol[i]) break;
			dp[j] = min(dp[j], dp[j-pol[i]] + 1);
		}
	}
	
	rep(j, N_MAX+1) { odd_dp[j] = j; }
	REP(j, 1, N_MAX+1) {
		REP(i, 1, kisu_pol.size()) {
			if(j<kisu_pol[i]) break;
			odd_dp[j] = min(odd_dp[j], odd_dp[j-kisu_pol[i]] + 1);
		}
	}
	
	while(cin >> N) {
		if (N == 0) { break; }
		cout << dp[N] << " " << odd_dp[N] << endl;
	}

	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

const int MAX_N = 182;
int num[MAX_N];
VI odd;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  num[0] = 0;
  for(int i=1;i<MAX_N;++i){
	num[i] = i*(i+1)*(i+2)/6;
	if(num[i] % 2 == 1) odd.PB(num[i]); // i % 4 == 1
  }

  VI pr;
  REP(i,MAX_N) REP(j,MAX_N)
	pr.PB(num[i]+num[j]);
  SORT(pr);
  
  VI dp(1000000+1,123456789);
  dp[0] = 0;
  for(int i=1;i<1000000+1;++i){
	for(int j=0;j<SZ(odd);++j){
	  if(i < odd[j]) break;
	  dp[i] = min(dp[i], dp[i - odd[j]] + 1);
	}
  }

  int N;
  while(cin>>N,N){
	int cnt = 0;
	if(*lower_bound(num, num+MAX_N, N) == N) cnt=1;
	else if(*lower_bound(ALL(pr), N) == N) cnt=2;
	else{
	  REP(i,SZ(pr)){
		int x = N - pr[i];
		if(x < 0) break;
		if(*lower_bound(num, num+MAX_N, x) == x){
		  cnt=3; break;
		}
		if(*lower_bound(ALL(pr), x) == x){
		  cnt=4;
		}
	  }
	  if(!cnt) cnt = 5;
	}
	cout << cnt << " " << dp[N] << endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

const int INF=1<<29;

int main(){
	vector<int> dp(1000001,INF);
	vector<int> odp(1000001,INF);
	dp[0]=0;
	odp[0]=0;
	
	int num=0;
	for(int i=1;num<1000001;i++){
		num=i*(i+1)*(i+2)/6;
		for(int j=num;j<1000001;j++){
			dp[j]=min(dp[j],dp[j-num]+1);
			if(num%2==1)
			odp[j]=min(odp[j],odp[j-num]+1);
		}
	}
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		printf("%d %d\n",dp[n],odp[n]);
	}
}

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

using P = pair<int, int>;

P solve(int n, vector<int> &v, vector<int> &w, vector<int> &ma, vector<int> &mb){
	if(n == 0) return P(0, 0);
	if(ma[n] < 1e6) return P(ma[n], mb[n]);
	for(size_t i=0; i<v.size(); ++i){
		if(v[i] > n) break;
		if(v[i] == n){
			ma[n] = 1;
			break;
		}
		ma[n] = min(ma[n], 1+solve(n-v[i], v, w, ma, mb).first);
	}
	for(size_t i=0; i<w.size(); ++i){
		if(w[i] > n) break;
		if(w[i] == n){
			mb[n] = 1;
			break;
		}
		mb[n] = min(mb[n], 1+solve(n-w[i], v, w, ma, mb).second);
	}
	return P(ma[n], mb[n]);
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	const int N = 1'000'000;
	vector<int> v, w, ma(N, N), mb(N, N);
	for(int i=1; i<=1000; ++i){
		int t = i * (i+1) / 2 * (i+2) / 3;
		v.push_back(t);
		if(t % 2 == 1) w.push_back(t);
	}
	for(int i=1; i<N; ++i) solve(i, v, w, ma, mb);
//	for(size_t i=0; i<v.size(); ++i) cout << i << " " << v[i] << "\n";
	while(1){
		int n; cin >> n;
		if(n == 0) break;
		cout << ma[n] << " " << mb[n] << "\n";
	}
}