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
//------------------------------------------
#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 bfs(int x){
  queue<int> q[2];
  int crt = 0, nxt = 1;
  q[crt].push(x);

  int ret = 0;
  while(true){
	++ret;
	while(!q[crt].empty()){
	  x = q[crt].front(); q[crt].pop();
	  REP(i,SZ(odd)){
		if(x < odd[i]) break;
		if(x == odd[i]) return ret;
		q[nxt].push(x - odd[i]);
	  }
	}

	swap(crt, nxt);
  }
}

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]);
  }

  VI pr;
  REP(i,MAX_N) REP(j,MAX_N)
	pr.PB(num[i]+num[j]);
  SORT(pr);
  
  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 << " " << bfs(N) << endl;
  }
  
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[200]={0},b[200]={0},c[1000001],d[1000001],k=0,i,j,n;

  for(i=1;i<200;i++)a[k++]=i*(i+1)*(i+2)/6;

  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];

  for(i=0;i<1000000;i++)c[i]=d[i]=i;

  for(i=1;i<195;i++)for(j=a[i];j<a[i+1];j++){
    if(j>1000000)break;
    c[j]=c[j-a[i]]+1;
  }
  for(i=1;i<k-2;i++)for(j=b[i];j<b[i+1];j++){
    if(j>1000000)break;
    d[j]=d[j-b[i]]+1;
  }
  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>

using namespace std;
int main(void){
    
    vector<int> p4;
    int c = 1, t = 0;
    while (1) {
        t = c*(c+1)*(c+2)/6;
        if (t >= 1e6) break;
        p4.push_back(t);
        c++;
    }
    
    int a[1010101] = {};
    int b[1010101] = {};
    for (int i = 1; i < 1010101; i++) {
        a[i] = 1e6;
        b[i] = 1e6;
    }
    
    for (int i = 0; i < 1010101; i++) {
        for (int j = 0; j < p4.size(); j++) {
            int t = i + p4[j];
            if (t > 1010101) break;
            a[t] = min(a[t], a[i]+1);
            if (p4[j]&1) b[t] = min(b[t], b[i]+1);
        }
    }
    int n;
    while (cin>>n && n) {
        cout << a[n] << " " << b[n] << endl;
    }
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  int tmp = 1;
  vi a, b;
  while(1){
    int x = tmp * (tmp + 1) * (tmp + 2) / 6;
    if(x >= 1000000) break;
    a.pb(x);
    if(x & 1) b.pb(x);
    tmp++;
  }
  dump(a,b);
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    vi dpa(n+1,inf),dpb(n+1,inf);
    dpa[0] = 0;
    dpb[0] = 0;
    rep(i,n){
      for(int j = 0; a[j] <= i + 1; ++j)
	for(int k = 1; a[j] * k <=  i + 1; ++k)
	  dpa[i+1] = min(dpa[i+1], dpa[i + 1 - k * a[j]] + k);
      for(int j = 0; b[j] <= i + 1; ++j)
	for(int k = 1; b[j] * k <= i + 1; ++k)
	  dpb[i+1] = min(dpb[i+1], dpb[i + 1 - k * b[j]] + k);
    }
    cout << dpa[n] << " " << dpb[n] << endl;
  }
}