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>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    vl v,w;
    rep(i,200){
        ll x=(i+1)*(i+2)*(i+3)/6;
        if(x>1000000)break;
        v.pb(x);
        if(x%2==1)w.pb(x);
    }
    ll sz=v.size();
    vl dp(1000001,inf);
    dp[0]=0;
    rep(i,sz){
        rep(j,1000001){
            if(j<v[i])continue;
            chmin(dp[j],dp[j-v[i]]+1);
        }
    }
    ll ssz=w.size();
    vl ddp(1000001,inf);
    ddp[0]=0;
    rep(i,ssz){
        rep(j,1000001){
            if(j<w[i])continue;
            chmin(ddp[j],ddp[j-w[i]]+1);
        }
    }
    while(true){
        ll a;cin >> a;
        if(a==0)break;
        cout << dp[a] << " " <<ddp[a] << endl;
    }
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

const int MAX_NUM=1000001;


vector<int> dp(MAX_NUM,MAX_NUM);//?§????????????£?????¢?????°????????°
vector<int> dp_odd(MAX_NUM,MAX_NUM);

int main(){

  vector<int> numbers;
  
  int cnt=1,sum=0;
  while (1) {
    sum=(cnt*(cnt+1)*(cnt+2))/6;
    if(sum>MAX_NUM) break;
    numbers.push_back(sum); 
    dp[sum]=1;
    if(sum%2==1)dp_odd[sum]=1;
    cnt++;  
  }

  for(int i=1;i<MAX_NUM;i++){
    rep(j,numbers.size()){
      if(i-numbers[j] <= 0) break;
      dp[i]=min(dp[i],dp[i-numbers[j]] + 1);
      if(numbers[j]%2==1) dp_odd[i]=min(dp_odd[i],dp_odd[i-numbers[j]] + 1);
    }
  }


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

}

C++: #include <iostream>
using namespace std;
int main(void){
    int i;
    long long n;
    int j = 0;
    long long a[84];
    long long b[22];
    int t[100010];
    for(i = 0; i < 83; i++){
        a[i] = (i+1)*(i+2)*(i+3)/6;
        if(a[i] % 2 == 1){
            b[j] = a[i];
            j++;
        }
    }
    //cout << a[82] << b[20] << endl;
    /*for(i = 0; i < 83; i++){
        cout << "a[i] = " << a[i] << endl;
    }
    for(i = 0; i < 21; i++){
        cout << "b[i] = " << b[i] << endl;
    }*/
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        for(i = 0; i <= n; i++){
            t[i] = i;
        }
        t[0] = 0;

        for(i = 0; i <= 82; i++){
            for(j = a[i]; j <= n; j++){
                if(t[j] > t[j - a[i]] + 1){
                    t[j] = t[j -a[i]] + 1;
                }
            }
            
        }
        cout << t[n] << " ";        

        for(i = 0; i <= n; i++){
            t[i] = i;
        }
        t[0] = 0;
        for(i = 0; i <= 20; i++){
            for(j = b[i]; j <= n; j++){
                if(t[j] > t[j - b[i]] + 1){
                    t[j] = t[j - b[i]] + 1;
                }
            }
        }
        cout << t[n] << endl;
    }
    return 0;
}