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<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 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 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>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int e[1048576],o[1048576];
int main(void)
{
  REP(i,1048576) e[i]=1048576;
  REP(i,1048576) o[i]=1048576;
  e[0]=0;
  o[0]=0;
  REP(i,1024){
    int gap=i*(i+1)*(i+2)/6;
    for(int j=0;j+gap<1048576;++j) e[j+gap]=min(e[j+gap],e[j]+1);
    if(gap%2==1) for(int j=0;j+gap<1048576;++j) o[j+gap]=min(o[j+gap],o[j]+1);
  }    
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    cout << e[n] << ' ' << o[n] << endl;
  }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for(int i=0; i<(n); ++i)

const int size = 200;
const int limit = 1000001;
int dp[limit], dp_odd[limit];
int tetra[size], odd[size];

int main(void){
    int size_odd = 0;
    for(int i=1; i<size+1; ++i) {
        ll t = i*(i+1)*(i+2)/6;
        tetra[i-1] = t;
        if(t%2==1) {odd[size_odd]=t; size_odd++;}
    }
    int inf = numeric_limits<int>::max();
    rep(i, limit) dp[i] = dp_odd[i] = inf;
    dp[0] = 0;
    dp_odd[0] = 0;
    rep(i, size) {
        for(int j=tetra[i]; j<limit; ++j)
            dp[j] = min(dp[j-tetra[i]]+1, dp[j]);
    }
    rep(i, size_odd) {
        for(int j=odd[i]; j<limit; ++j)
            dp_odd[j] = min(dp_odd[j-odd[i]]+1, dp_odd[j]);
    }

    int n;
    while(cin >> n && n) {
        cout << dp[n] << " ";
        cout << dp_odd[n] << endl;
    }
}

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

int dpt1[1000001];
int dpt2[1000001];
bool dpb1[1000001];
bool dpb2[1000001];
int tr[1000];
int sq[1000];

int dp1(int s) {
  if(dpb1[s])
    return dpt1[s];

  int m = 1000111000;
  int r;
  for(int i=1; i < 1000; i++) {
    if(s-sq[i] < 0) break;
    r = dp1(s-sq[i]);
    if(r < m) m = r;
  }

  dpt1[s] = m + 1;
  dpb1[s] = true;
  return m + 1;
}

int dp2(int s) {
  if(dpb2[s])
    return dpt2[s];

  int m = 1000111000;
  int r;
  for(int i=1; i < 1000; i++) {
    if(s-sq[i] < 0) break;
    if(sq[i]%2 == 0)
      continue;
    r = dp2(s-sq[i]);
    if(r < m) m = r;
  }

  dpt2[s] = m + 1;
  dpb2[s] = true;
  return m + 1;
}

int main() {

  for(int i=1; i < 1000; i++) {
    tr[i] = tr[i-1] + i;
    sq[i] = sq[i-1] + tr[i];
  }
  dpt1[0] = 0;
  dpb1[0] = true;
  dpt2[0] = 0;
  dpb2[0] = true;
  int n;
  while(cin >> n, n) {
    cout << dp1(n) << " " << dp2(n) << endl;
  }

  return 0;
}

C++: #include "bits/stdc++.h"
#define int long long
#define REP(i, s, n) for (signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()


const int INF = 1 << 29;

using namespace std;

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

int dr[] = { -1, 0, 1, 0 };
int dc[] = { 0, -1, 0, 1 };
const int MOD = 1000000007;

signed main() {

	const int Maxnum = 1000000;
	vector<int> seisi = { 1 };
	int num = 2;
	while (seisi.back() <= Maxnum)
	{
		seisi.push_back(num * (num + 1) * (num + 2) / 6);
		num++;
	}

	vector<int> dp(Maxnum + 1, INF), kidp(Maxnum + 1, INF);
	dp[0] = 0;
	kidp[0] = 0;
	rep(i, Maxnum) {

		rep(j, seisi.size()) {
			if (i + seisi[j] > Maxnum) break;
			dp[i + seisi[j]] = min(dp[i + seisi[j]], dp[i] + 1);

			if (seisi[j] % 2) {
				kidp[i + seisi[j]] = min(kidp[i + seisi[j]], kidp[i] + 1);
			}
		}
	}

	int n;
	while (cin >> n && n) {

		cout << dp[n] << " " << kidp[n] << endl;
	}

}