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>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, INF))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n = 1000000;
  int INF = 1e9;
  vec dp1(n+1, INF), dp2(n+1, INF);
  vec simen, simen_odd;
  REP(i,1,200){
    int tmp = i*(i+1)*(i+2)/6;
    if(tmp>1000000) break;
    simen.pb(tmp);
    if(tmp%2==1) simen_odd.pb(tmp);
  }
  dp1[0]=0;
  dp2[0]=0;

  REP(i,1,1000000){
    rep(j,simen.size()){
      if(i-simen[j]>= 0) chmin(dp1[i], dp1[i-simen[j]]+1);
    }
    rep(j,simen_odd.size()){
      if(i-simen_odd[j]>= 0) chmin(dp2[i], dp2[i-simen_odd[j]]+1);
    }
  }

  while(1){
    int q;
    cin >> q;
    if(q==0) break;

    prt2(dp1[q], dp2[q]);
  }
}

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

using usize = ::std::size_t;
using u64 = ::std::uint_least64_t;

#define v(n) n*(n+1)*(n+2)/6

int main(int argc, char *argv[])
{
    // input from txt （提出時にこの箇所は削除すること）
    //ifstream in("in.txt");
    //cin.rdbuf(in.rdbuf());
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;
    
    vector<u64> dp(1000001, Inf);
    vector<u64> dp2(1000001, Inf);
    dp[0] = 0;
    dp2[0] = 0;
    //int ti = clock();
    
    for (int i = 1; i <= 600; i++) {
        for (int j = v(i); j <= 1000000; j++) {
            for (int k = 1; j - k*v(i) >= 0 && k <= 5; k++) {
                dp[j] = min(dp[j], dp[j - k * v(i)] + k);
            }
        }
    }
    
    for (int i = 1; i <= 600; i += 4) {
        for (int j = v(i); j <= 1000000; j++) {
            for (int k = 1; j - k*v(i) >= 0; k++) {
                if (dp2[j] <= dp2[j - k * v(i)] + k) {
                    break;
                }
                dp2[j] = min(dp2[j], dp2[j - k * v(i)] + k);
            }
        }
    }
    
    //cout << (1.0 * (clock() - ti) / CLOCKS_PER_SEC) << endl;
    
    u64 N;
    while (cin >> N, N) {
        cout << dp[N]  << " " << dp2[N] << endl;
    }
    
    
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <queue>

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

using namespace std;

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

const int INF = 0x3fffffff;

int vx[] = {1,0,-1,0}, vy[] = {0,1,0,-1};

int main(){
	int N;
	int sq[300];
	rep(i, 300){
		sq[i] = (ll)i*(i+1)*(i+2)/6;
	}
	sq[0] = INF;
	int memo[1000006]={};
	int modd[1000006]={};
	memo[1] = 1;
	modd[1] = 1;
	for(int n=1; n<1000002; n++){
		int mn = INF, mn_o = INF;
		rep(i,300){
			if( sq[i] > n ) continue;
			mn = min(mn, memo[ n-sq[i] ] + 1);
			if( sq[i]%2 == 1 ){
				mn_o = min(mn_o, modd[ n-sq[i] ] + 1);
			}
		}
		memo[n] = mn;
		modd[n] = mn_o;
	}
	//rep(i,20) cout << modd[i] << endl;
	while(cin >> N, N){
		cout << memo[N] << " " << modd[N] << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;

const int N = 1000000;
int dp[2][N+1],n;

int main(){
  for(int i=0;i<=N;i++)dp[0][i] = dp[1][i] = N;
  dp[0][0] = dp[1][0] = 0;

  int val = 1;
  for(int i=1;val<=N;i++){
    for(int j=0;j+val<=N;j++){
      int nxt = j+val;
      dp[0][nxt] = min(dp[0][nxt],dp[0][j] + 1);
      if(val&1)dp[1][nxt] = min(dp[1][nxt],dp[1][j] + 1);
    }
    val = i*(i+1)*(i+2)/6;
  }

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