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 INF 1 << 25

int dp[1500000];
int dp2[1500000];

int main()
{
  int n;
  int tetra[200];
  for(int i = 0; i < 200; i++) tetra[i] = (i+1)*(i+2)*(i+3)/6;
  while(cin >> n, n){
    for(int i = 0; i < 1500000; i++) dp[i] = dp2[i] = INF;
    dp[0] = dp2[0] = 0;
    for(int i = 0; i < 200; i++){
      dp[tetra[i]] = 1;
      if(tetra[i]%2 == 1) dp2[tetra[i]] = 1;
    }
    for(int i = 2; i <= n; i++){
      for(int j = 1; j < i; j++){
	dp[i] = min(dp[i], dp[i-j] + dp[j]);
	dp2[i] = min(dp2[i], dp2[i-j] + dp2[j]);
      }
    }
    cout << dp[n] << " " << dp2[n] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmin(T &a, T b) {a = min(a, b);}
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
vector<int> dp(1e6+1,INF),DP(1e6+1,INF);
signed main(){
  vector<int> a,odd;
  loop(i,1,1e6+1){
    int tmp=i*(i+1)*(i+2)/6;
    if(1e6<tmp)break;
    a.push_back(tmp);
    if(tmp%2)odd.push_back(tmp);
  }
  dp[0]=DP[0]=0;
  rep(i,1e6+1){
    rep(j,a.size())if(i+a[j]<=1e6)cmin(dp[i+a[j]],dp[i]+1);
    rep(j,odd.size())if(i+odd[j]<=1e6)cmin(DP[i+odd[j]],DP[i]+1);
  }

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

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i <(n); ++i)
using namespace std;

const int N = 1010101, M = 200;

int main() {
    vector<int> A(M + 1, 1);
    rep(_, 3) rep(i, M) A[i + 1] += A[i];
    vector<int> dp(N, N), ep(N, N);
    dp[0] = 0;
    ep[0] = 0;
    for(auto &n : A) rep(i, N) {
        if(i + n < N) {
            dp[i + n] = min(dp[i + n], dp[i] + 1);
            if(n % 2) ep[i + n] = min(ep[i + n], ep[i] + 1);
        }
    }
    int N;
    while(cin >> N) {
        if(!N) break;
        cout << dp[N] << " " << ep[N] << '\n';
    }
    return 0;
}

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

const int INF = 1 << 29;
const int LIM = 1000000;

int dp1[LIM], dp2[LIM];

int main(){
    fill(dp1, dp1 + LIM, INF);
    fill(dp2, dp2 + LIM, INF);
    dp1[0] = dp2[0] = 0;
    for(int i = 1; i * (i + 1) * (i + 2) / 6 < LIM; i++){
        int num = i * (i + 1) * (i + 2) / 6;
        for(int j = num; j < LIM; j++){
            dp1[j] = min(dp1[j], dp1[j-num] + 1);
        }
        if(num % 2 == 0) continue;
        for(int j = num; j < LIM; j++){
            dp2[j] = min(dp2[j], dp2[j-num] + 1);
        }
    }
    int N;
    while(true){
        scanf("%d", &N);
        if(N == 0) break;
        printf("%d %d\n", dp1[N], dp2[N]);
    }
    return 0;
}

C++: #include<stdio.h>
#include<algorithm>

int dp[100000];
int dp_odd[100000];
int main(){
    dp[0] = 0;
    dp_odd[0] = 0;
    for(int i=1; i<100000; i++){
        dp[i] = -1;
        dp_odd[i] = -1;
    }
    for(int n=1; n*(n+1)*(n+2)/6 < 100000; n++){
        bool isodd = false;
        int p = n*(n+1)*(n+2)/6;
        if(p%2 == 1) isodd = true;
        for(int k=1; p*k < 100000; k++){
            for(int i=0; i+p*k < 100000; i++){
                if(dp[i] != -1){
                    if(dp[i+p*k] != -1){
                        dp[i+p*k] = std::min(dp[i+p*k], dp[i] + k);
                        if(isodd) dp_odd[i+p*k] = std::min(dp_odd[i+p*k], dp_odd[i] + k);
                    }else{
                        dp[i+p*k] = dp[i] + k;
                        if(isodd) dp_odd[i+p*k] = dp_odd[i] + k;
                    }
                }
            }
        }
    }
    int x;
    scanf("%d",&x);
    while(x!=0){
        printf("%d %d\n", dp[x], dp_odd[x]);
        scanf("%d",&x);
    }
}

C++: #include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9 + 7;
const ll LINF = 1LL << 60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

const int MAX = 1000100;
int dp1[MAX], dp2[MAX];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  rep(i,MAX) dp1[i] = INF, dp2[i] = INF;
  dp1[0] = dp2[0] = 0;
  vector<int> s1, s2;
  ll t = 1;
  while(t*(t+1)*(t+2)/6 < 1000000) {
    ll s = t*(t+1)*(t+2)/6;
    s1.push_back(s);
    if(s%2) s2.push_back(s);
    t++;
  }
  // チノガキbot "because t^3 is included, the size won't be over 10^3!!!"
  rep(i,MAX-50) {
    rep(j,s1.size()) {
      if(i+s1[j] >= MAX-50) break;
      chmin(dp1[i+s1[j]], dp1[i]+1);
    }
    rep(j,s2.size()) {
      if(i+s2[j] >= MAX-50) break;
      chmin(dp2[i+s2[j]], dp2[i]+1);
    }
  }
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    cout << dp1[n] << " " << dp2[n] << '\n';
  }
  return 0;
}