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 <algorithm>
#include <iostream>

using namespace std;

int dp1[1000010]={0};
int dp2[1000010]={0};
int List[200];

void setpolloc(){
	int i,j,li;
	for(i=1;i*(i+1)*(i+2)/6<=1000000;i++){
		List[i]=i*(i+1)*(i+2)/6;
		dp1[i*(i+1)*(i+2)/6]=1;
		if((i*(i+1)*(i+2)/6)%2) dp2[i*(i+1)*(i+2)/6]=1;
	}
	List[i]=i*(i+1)*(i+2)/6;
	for(i=1;i<=1000000;i++){
		if(dp2[i]) continue;
		for(j=1;List[j]<=i-1;j+=2)if(!dp2[i] || dp2[List[j]]+dp2[i-List[j]] < dp2[i]) dp2[i]=dp2[List[j]]+dp2[i-List[j]];
		if(dp1[i]) continue;
		for(j=1;List[j]<=i-1;j++) if(!dp1[i] || dp1[List[j]]+dp1[i-List[j]] < dp1[i]) dp1[i]=dp1[List[j]]+dp1[i-List[j]];
	}
}


int main(){
	int n;
	setpolloc();
	while(cin>>n,n){
		cout << dp1[n] << ' ' << dp2[n] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)n; ++i)

ll table[1000000];
ll pollock[1000001];
ll dp[1000001];

int main() {
	//freopen("Text.txt", "r", stdin);
	
	ll size = 0;
	{
		ll i = 0;
		table[0] = 0;
		while (1000001 > table[i]) {
			i++;
			table[i] = i*(i + 1)*(i + 2) / 6;
		}
		size = i;
	}

	{
		pollock[0] = 0;
		ll current_i = 0;
		REP(i, 1000001) {
			if (i == 0) continue;
			if (table[current_i + 1] == i) {
				pollock[i] = 1; current_i++;
				continue;
			}

			ll minimum = 1000001;
			for (ll j = 1; j <= current_i; j += 1) {
				minimum = min(pollock[i - table[j]] + 1, minimum);
			}
			pollock[i] = minimum;
		}
	}

	{
		dp[0] = 0;
		ll current_i = -3;
		REP(i, 1000001) {
			if (i == 0) continue;
			if (table[current_i + 4] == i) {
				current_i += 4; dp[i] = 1;
				continue;
			}

			ll minimum = 1000001;
			for(ll j=1; j<=current_i; j+=4) {
				minimum = min(dp[i - table[j]]+1, minimum);
			}
			dp[i] = minimum;
		}
	}

	while (true) {
		int n;
		cin >> n;
		if (n==0) break;
		
		cout << pollock[n] << " " << dp[n] << endl;
	}

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int dp[300][1000001];

int odd(int n,int w){
  for(int i=0;i<=w;i++)
    for(int j=0;j<=n;j++){
      dp[i][j]=99999999;
      if(i==0)dp[i][j]=j;
      if(j==0)dp[i][j]=0;
    }

    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if((i*(i+1)*(i+2)/6)%2==0){
	  dp[i][j]=dp[i-1][j];
	}else if(j<i*(i+1)*(i+2)/6){
	  dp[i][j]=dp[i-1][j];
	}else{
	  dp[i][j]=min(dp[i-1][j],dp[i][j-i*(i+1)*(i+2)/6]+1);
	}
	//cout << "dp[" << i << "][" << j <<"]:"<< dp[i][j] << endl;
      }
    }
    return dp[w][n];
}

int main(){
  int n;
  while(cin>>n,n){
    int w=0;
    while(w*(w+1)*(w+2)/6 < n){
      w++;
    }
    for(int i=0;i<=w;i++)
      for(int j=0;j<=n;j++){
	dp[i][j]=99999999;
	if(i==0)dp[i][j]=j;
	if(j==0)dp[i][j]=0;
      }
    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if(j<i*(i+1)*(i+2)/6){
	  dp[i][j]=dp[i-1][j];
	}else{
	  dp[i][j]=min(dp[i-1][j],dp[i][j-i*(i+1)*(i+2)/6]+1);
	}
	//cout << "dp[" << i << "][" << j <<"]:"<< dp[i][j] << endl;
      }
    }
    cout << dp[w][n] << " " << odd(n,w) << endl;
  }
  return 0;
}

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

//#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
//const int INF = 1107110711071107;

int dp[1000001];
int dp_odd[1000001];
int four[210];
int x;

signed main() {
  Rep(i, 210) four[i] = i * (i+1) * (i+2) / 6;
  
  Rep(i, 1000001) dp[i] = i;
  Rrep(i, 2, 200) {
    Rep(j, 1000001) {
      if ( j+four[i] <= 1000000 ) {
	dp[j+four[i]] = min(dp[j+four[i]], dp[j]+1);
      }
    }
  }

  Rep(i, 1000001) dp_odd[i] = i;
  Rrep(i, 2, 40) {
    Rep(j, 1000001) {
      dp_odd[j] = min(dp_odd[j], dp_odd[j]);
      if ( j+four[(i-1)*4+1] <= 1000000 ) {
	dp_odd[j+four[(i-1)*4+1]] = min(dp_odd[j+four[(i-1)*4+1]], dp_odd[j]+1);
      }
    }
  }
 
  while ( cin >> x, x ) {
    cout << dp[x] << " " << dp_odd[x] << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pint pair<int,int>

const int MAX_N = 2e6;
const int inf = 1LL << 60;

vector<int> candi;
vector<int> odd;

int DPA[MAX_N],DPB[MAX_N];

void chmin(int &a, int b){ 
  if( a > b ){ swap(a,b);} return;
}

void init(){
  
  for(int i = 1; (i*(i+1)*(i+2))/6 < MAX_N; i++){
    int num = i*(i+1)*(i+2);
    num /= 6;
    candi.push_back(num);
    if(num%2){
      odd.push_back(num);
    }
  }
  
  
  int a = candi.size();
  int b = odd.size();
  
  
  for(int i = 0; i < MAX_N; i++){
    DPA[i] = inf; DPB[i] = inf;
  }
  
  for(int i = 0; i < a; i++){
    DPA[candi[i]] = 1;
  }
  
  for(int i = 0; i < b; i++){
    DPB[odd[i]] = 1;
  }
   
  DPA[0] = 0; DPB[0] = 0;
  
  for(int i = 1; i < MAX_N; i++){
   
    for(int j = 0; j < a; j++){ 
      if(i-candi[j] >= 0 ){ 
       chmin(DPA[i],DPA[i-candi[j]]+1);
      }
    }
    
  }
  
  for(int i = 1; i < MAX_N; i++){
    
    for(int j = 0; j < b; j++){
      if(i-odd[j] >= 0 ){
        chmin(DPB[i],DPB[i-odd[j]]+1);
      }
    }
  }
  
  return ;
}
  
    

signed main(void){
  int N; 
  init();
  while(cin >> N){
    if( N == 0 ){ return 0;}
    
    cout << DPA[N] << " " << DPB[N] << endl;
    
  }
  
  return 0;
}