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>
using namespace std;
int main(){
  int n,i,j,k,t=0,a[200]={},b[200]={},c[1000005]={1000000},d[1000005]={1000000};
  for(i=1;i<201;i++) {
    a[i-1]=i*(i+1)*(i+2)/6;
    if(a[i-1]%2==1)b[t++]=a[i-1];
  }
  for(i=c[0]=d[0]=0;i<200;i++) {
    for(j=a[i];j<1000005;j++){
      c[j]=min(c[j],c[j-a[i]]+1);
    }
  }
  for(i=0;i<t;i++) {
    for(j=b[i];j<1000005;j++){
      d[j]=min(d[j],d[j-b[i]]+1);
    }
  }
  while(cin>>n,n)cout<<c[n]<<" "<<b[n]<<endl;
return 0;
}

C++: #include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int NMAX = 1e6 + 8;
const int INF = 1e6 + 8;

int dp1[NMAX], dp2[NMAX];

void solve(int n) {
  REP(i, n) {
    dp1[i] = dp2[i] = i;
  }

  for (int base = 100; base > 2; base--) {
    int q = base * (base - 1) * (base - 2) / 6;
    for (int i = q; i < n; i++) {
      dp1[i] = min(dp1[i], dp1[i - q] + 1);
    }
  }

  for (int base = 100; base > 2; base--) {
    int q = base * (base - 1) * (base - 2) / 6;
    if (q % 2 == 0) continue;
    for (int i = q; i < n; i++) {
      dp2[i] = min(dp2[i], dp2[i - q] + 1);
    }
  }
}

int main() {
  solve(1e6 + 1);

  int n;
  while (cin >> n and n) {
    cout << dp1[n] << " " << dp2[n] << endl;
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll f(ll n) {
    return n * (n+1) * (n+2) / 6;
}
vector<ll> make_dp(const vector<ll>& v, ll n) {
    vector<ll> dp(n+1, linf);
    dp[0] = 0;
    rep(i, v.size()) rep(j, n+1) {
        ll nj = j + v[i];
        if (nj <= n) chmin(dp[nj], dp[j]+1);
    }
    return dp;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    vector<ll> v1, v2;
    for (ll i = 1; f(i) <= ll(1e6); ++i) {
        v1.pb(f(i));
        if (f(i) % 2 == 1) v2.pb(f(i));
    }
    vector<ll> dp1 = make_dp(v1, ll(1e6));
    vector<ll> dp2 = make_dp(v2, ll(1e6));
    while (cin >> n, n) {
        cout << dp1[n] << " " << dp2[n] << endl;
    }
}

C++: #include<stdio.h>
#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<queue>
#define pi 3.14159
#define Inf (int)pow(2., 12.)

using namespace std;
typedef std::pair<int, int> mypair;
queue<mypair> qu;
#define M 1000000
 
int odd[M], all[M];
 
void update(int *ar, int x){
    for(int i = x; i <= M; ++i){
        ar[i] = min(ar[i], ar[i - x] + 1);
    }
}
 
int main(){
	odd[0] = all[0] = 0;
    for(int i = 1; i <= M; ++i){
        odd[i] = all[i] = 10000000;
    }
 
    for(int i = 1; ; ++i){
        int x = i * (i + 1) * (i + 2) / 6;
        if(x > M) break;
        update(all, x);
        if(x % 2 == 1) update(odd, x); 
    }
     
    int n;
    while(1) {
		cin >> n;
		if(n == 0) break;
		cout << all[n] << " " << odd[n] <<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k,t=0,a[250]={},b[200]={},c[1000005]={2000000},d[1000005]={1000000};
  for(i=1;i<250;i++) {
    a[i-1]=i*(i+1)*(i+2)/6;
    if(a[i-1]%2==1)b[t++]=a[i-1];
  }
  for(i=c[0]=d[0]=0;i<250;i++) {
    for(j=a[i];j<1000005;j++){
      c[j]=min(c[j],c[j-a[i]]+1);
    }
  }
  for(i=0;i<t-1;i++) {
    for(j=b[i];j<1000005;j++){
      d[j]=min(d[j],d[j-b[i]]+1);
    }
  }
  while(cin>>n,n)cout<<c[n]<<" "<<d[n]<<endl;
return 0;
}