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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 1000000;
const int INF = 1000100100;

int main()
{
    int ans = -1;
    int n = 0;
    int n_odd = 0;
    vector<int> pol;
    vector<int> pol_odd;
    while(true){
        n++;
        ans = n*(n+1)*(n+2)/6;
        if(ans <= 1000000){
            pol.push_back(ans);
            if(ans % 2 == 1){
                pol_odd.push_back(ans);
                n_odd++;
            }
        }else{
            n--;
            break;
        }
    }

    /*
    vector<vector<int> > dp(n, vector<int>(MAX_N+1));
    rep(i,n) rep(j,MAX_N+1) dp[i][j] = INF;
    rep(j,MAX_N+1) dp[0][j] = j;
    */

    vector<int> dp(MAX_N+1);
    rep(i,MAX_N+1) dp[i] = i;

    for(int i=1; i<n; i++){
        rep(j,MAX_N+1){
            if(j<pol[i]) continue;
            else{
                // dp[i][j] = min(min(dp[i-1][j], dp[i-1][j-pol[i]] + 1), dp[i][j-pol[i]]+1);
                dp[j] = min(dp[j-pol[i]]+1, dp[j]);
            }
        }
    }

    /*
    vector<vector<int> > dp_odd(n_odd, vector<int>(MAX_N+1));
    rep(i,n_odd) rep(j,MAX_N+1) dp_odd[i][j] = INF;
    rep(j,MAX_N+1) dp_odd[0][j] = j;
    */

    vector<int> dp_odd(MAX_N+1);
    rep(i,MAX_N+1) dp_odd[i] = i;

    for(int i=1; i<n_odd; i++){
        rep(j,MAX_N+1){
            if(j<pol_odd[i]) continue;
            else{
                dp_odd[j] = min(dp_odd[j-pol_odd[i]]+1, dp_odd[j]);
            }
        }
    }    
    

    
    while(true){
        int N; cin >> N;

        if(N == 0) break;

        printf("%d %d\n", dp[N], dp_odd[N]);
    }
    
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600
#define MAX 1000000

int  dp[MAX+1];
int dp2[MAX+1];

int main(){
  vector<int> nums,odds;

  int tmp=0, n=1;
  while(tmp<=MAX){
    tmp+=n*(n+1)/2;
    nums.pb(tmp);
    if(tmp%2==1) odds.pb(tmp);
    n++;
  }

  fill(dp, dp+MAX+1, INF);
  fill(dp2, dp2+MAX+1, INF);
  dp[0]=0; dp2[0]=0;

  repl(i,1,MAX+1){
    for(int nxt : nums){
        if(i<nxt) continue;
        dp[i] = min(dp[i], dp[i-nxt]+1);
    }
    for(int nxt : odds){
        if(i<nxt) continue;
        dp2[i] = min(dp2[i], dp2[i-nxt]+1);
    }
  }

  while(scanf("%d", &n), n){
    printf("%d %d\n", dp[n], dp2[n]);
  }

  return 0;
}

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

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp
#define pb push_back

#define fi
#define se

#define each

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int f(int n, int m, vi a){
	vi t(n+1,INF);
	t[0] = 0;
	rep(i,m){
		REP(j,a[i],n+1){
			t[j] = min(t[j],t[j-a[i]]+1);
		}
	}
	return t[n];
}

int main(){
	vi a;
	vi ao;
	REP(i,1,200){
		a.pb(i*(i+1)*(i+2)/6);
	}
	rep(i,a.size()){
		if(a[i]%2==1) ao.pb(a[i]);
	}

	// rep(i,a.size()) cout<<a[i]<<endl;
	// cout<<"=--"<<endl;
	// rep(i,ao.size()) cout<<ao[i]<<endl;

	while(1){
		int n; cin>>n;
		if(n==0) break;
		cout<<f(n,a.size(),a)<<" "<<f(n,ao.size(),ao)<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int lim = 1e6 + 100;
const int inf = 1e9;

int dp[lim];
int dp_odd[lim];

int main(){
    //init dp talbe
    for(int i=0; i<lim; i++){
        dp[i] = inf;
        dp_odd[i] = inf;
    }
    dp[0] = 0;
    dp_odd[0] = 0;

    for(int n=1; n<lim; n++){
        int num = n * (n+1) * (n+2) / 6;
        if(num >= lim) break;

        for(int i=num; i<lim; i++){
            dp[i] = min(dp[i], dp[i - num] + 1);
            if(num%2 == 1) dp_odd[i] = min(dp_odd[i], dp_odd[i - num] + 1);
        }
    }

    while(true){
        int N;
        cin >> N;
        if(N == 0) return 0;
        cout << dp[N] << " " << dp_odd[N] << endl;
    }
}