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<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int dp1[2000050];
int dp2[2000050];

void solve(){
    vector<int> va;
    vector<int> vb;
    for(int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000000; i++){
        int a = i * (i + 1) * (i + 2) / 6;
        va.push_back(a);
        if(a % 2 == 1) vb.push_back(a);
    }
    rep(i,1000005){
        dp1[i] = INF;
        dp2[i] = INF;
    }
    dp1[0] = dp2[0] = 0;

    for(int j = va.size() - 1; j >= 0; j--){
        rep(i, 1000000){
            if(dp1[i] != INF && dp1[i + va[j]] == INF){
                dp1[i + va[j]] = dp1[i] + 1;
            }
        }
    }
    for(int j = vb.size() - 1; j >= 0; j--){
        rep(i, 1000000){
            if(dp2[i] != INF && dp2[i + vb[j]] == INF){
                dp2[i + vb[j]] = dp2[i] + 1;
            }
        }
    }
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 100000000;

const int tetra_size = 185;
int tetra[tetra_size];
int tri[tetra_size];
void settetra(){
	tetra[0] = 0;
	tri[0] = 0;
	for(int i = 1; i < tetra_size; i++){
		tri[i] = tri[i-1] + i;
		tetra[i] = tetra[i-1] + tri[i];
	}
}

int dp[1000001];
int dpodd[1000001];
void setdp(){
	fill(dp, dp+1000001, INF);
	dp[0] = 0;
	fill(dpodd, dpodd+1000001, INF);
	dpodd[0] = 0;
	for(int i = tetra_size ; i >= 1; i--){
		for(int j = 0; j + tetra[i] < 1000001; j++ ){
			if(dp[j] == INF) continue;
			dp[j+tetra[i]] = min(dp[j]+1, dp[j+tetra[i]]);
			if(tetra[i]%2 == 1) dpodd[j+tetra[i]] = min(dpodd[j]+1, dpodd[j+tetra[i]]);
		}
	}
}

int main(){
	settetra();
	setdp();
	int n;
	while(cin >> n){
		//cout << tetra[n]  << endl;
		cout << dp[n] << ' ' <<  dpodd[n]  << endl;
	}

	return 0;
}

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

const int MAXN = 1000006;
const int INF = 1<<28;
vector<int> V;
int dp1[MAXN], dp2[MAXN];

int main() {
  for(int i = 1; ; ++i) {
    int k = i * (i + 1) * (i + 2) / 6;
    if(k >= MAXN) break;
    V.push_back(k);
  }
  fill(dp1, dp1 + MAXN, INF);
  fill(dp2, dp2 + MAXN, INF);
  dp1[0] = dp2[0] = 0;
  for(int i = 0; i < V.size(); ++i) {
    for(int j = V[i]; j < MAXN; ++j) {
      dp1[j] = min(dp1[j], dp1[j - V[i]] + 1);
      if(V[i] & 1) dp2[j] = min(dp2[j], dp2[j - V[i]] + 1);
    }
  }
  for(int n; cin >> n && n; ) {
    cout << dp1[n] << " " << dp2[n] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std ;

int d[182] = {} ;
int D[182] = {} ; // 10^6 越え → 181
int dp_map[2][1000002] = {} ;

void t(){
	for( int i=1 ; i<182 ; i++ ){
		d[i] = d[i-1] + i ;
		D[i] = D[i-1] + d[i] ;
	}
}

int cal_2( int x , int c ){
	if( x==0 ) return 0 ;
	else{
		if( dp_map[0][x] != 0 ) return dp_map[0][x] ;
		else return x/D[c] + cal_2( x%D[c] , c-1 ) ;
	}
}

int cal( int m , int q ){
	int ans = m ;
	for( int j=q ; j>1 ; j-- ){
		ans = min( ans , cal_2( m , j ) ) ;
	}
	return ans ;
}

int cal_odd_2( int x , int c ){
	if( x==0 ) return 0 ;
	else{
		if( D[c]%2 == 0 ) return cal_odd_2( x , c-1 ) ;
		else{
			if( dp_map[1][x] != 0 ) return dp_map[1][x] ;
			else return x/D[c] + cal_odd_2( x%D[c] , c-1 ) ;
		}
	}
}

int cal_odd( int m , int q ){
	int ans_2 = m ;
	for( int j=q ; j>1 ; j-- ){
		ans_2 = min( ans_2 , cal_odd_2( m , j ) ) ;
	}
	return ans_2 ;
}

void dp(){
	int p = 1 ;
	for( int i=1 ; i<=1000000 ; i++ ){
		if( i < 182 && i >= D[p] ) p++ ;
		dp_map[0][i] = cal(i,p) ;
		dp_map[1][i] = cal_odd(i,p) ;
	}
}

int main(){
	
	t() ;
	dp() ;
	
	int n ;
	
	while( cin >> n , n ){
		cout << dp_map[0][n] << ' ' ;
		cout << dp_map[1][n] << endl ;
	}
	
return 0 ;
}

C++: #include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define from_to(from, to, i) for(int i=from;i<=to;i++)

using namespace std;
typedef long long ll;
const int MAX = 1000010;
const int INF = 1<<29;

int main(int argc, char const* argv[])
{
    vector<int> V;
    for (int i = 1; i*(i+1)*(i+2)/6 < MAX; i++) {
        V.push_back(i*(i+1)*(i+2)/6);
    }

    int all[MAX], odd[MAX];
    fill(all, all+MAX, INF);
    fill(odd, odd+MAX, INF);

    all[0] = odd[0] = 0;
    for (int v : V) {
        loop (v, i) {
            for (int j = 1; i+v*j < MAX; j++) {
                all[i+v*j] = min(all[i+v*j], all[i+v*(j-1)] + 1);

                if (v%2) {
                    odd[i+v*j] = min(odd[i+v*j], odd[i+v*(j-1)] + 1);
                }
            }
        }
    }

    while (1) {
        int n; cin >> n;
        if (!n) break;
        printf("%d %d\n", all[n], odd[n]);
    }

    return 0;
}