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;

#define MAX 1000000
#define INF 1000000000

int dp1[MAX], dp2[MAX];

int main()
{
    for (int i = 1; i <= MAX; i++)
    {
        dp1[i] = INF;
        dp2[i] = INF;
    }
    for (int n = 1; n * (n + 1) * (n + 2) / 6 <= MAX; n++)
    {
        int a = n * (n + 1) * (n + 2) / 6;
        for (int i = a; i <= MAX; i++)
        {
            dp1[i] = min(dp1[i], dp1[i - a]);
        }
        if (a % 2 == 0)
            continue;
        for (int i = a; i <= MAX; i++)
        {
            dp2[i] = min(dp2[i], dp2[i - a]);
        }
    }
    while (1)
    {
        cin >> n;
        if (n == 0)
            break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}

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

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

using namespace std;

const int MAX_N = 1e6 + 10;
const int INF = 1e9;
int dp1[MAX_N];
int dp2[MAX_N];

int main() {
  vector<int> x, y;
  REP(i, 1, 201) {
    int z = i * (i+1) * (i+2) / 6;
    x.push_back(z);
    if(z&1) y.push_back(z);
  }
  
  rep(i, MAX_N) dp1[i] = dp2[i] = INF;
  dp1[0] = 0;
  dp2[0] = 0;
  for(const auto& a : x) {
    for(int i = 0; i + a < MAX_N; ++i) {
      dp1[i+a] = min(dp1[i+a], dp1[i]+1); 
    }
  }
  for(const auto& a : y) {
    for(int i = 0; i + a < MAX_N; ++i) {
      dp2[i+a] = min(dp2[i+a], dp2[i]+1); 
    }
  }
  int n;
  while(cin >> n) {
    if(n == 0) break;
    cout << dp1[n] << " " << dp2[n] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
static const int INFTY = (1 << 29);

int main()
{
    vector<int> v;
    int i = 1;
    int sum = i*(i+1)*(i+2) / 6;
    v.push_back(0);
    while(sum <= 10000000) {
        v.push_back(sum);
        i++;
        sum = i*(i+1)*(i+2) / 6;
    }

    int N, m, resa, resb;

    for(; ;) {
        scanf("%d", &N);
        if (N == 0) break;
        resa = resb = INFTY;
        m = upper_bound(v.begin(), v.end(), N)-v.begin()-1;
        if (v[m] == N) resa = 1;
        if (v[m] == N && v[m] % 2 != 0) resb = 1;

        int T[N+1];
        if (resa == INFTY) {
            for(i = 0; i <= N; i++) T[i] = INFTY;
            T[0] = 0;
            for (i = 1; i <= m; i++) {
                for (int j = 0; j + v[i] <= N; j++) {
                    T[j+v[i]] = min(T[j+v[i]], T[j]+1);
                }
            }
            resa = T[N];
        }
        if (resb == INFTY) {
            for(i = 0; i <= N; i++) T[i] = INFTY;
            T[0] = 0;

            for (i = 1; i <= m; i++) {
                if (v[i] % 2 == 0) continue;
                for (int j = 0; j + v[i] <= N; j++) {
                    T[j+v[i]] = min(T[j+v[i]], T[j]+1);
                }
            }
            resb = T[N];
        }
        printf("%d %d\n", resa, resb);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30
#define M_MAX 1000001

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

vector<int>r;
int dp[M_MAX], odp[M_MAX];

int main(){
  fill(dp, dp+M_MAX, INF);
  //  fprintf(stderr, "error\n");
  fill(odp, odp+M_MAX, INF);

  int n = 0;
  while(++n){
    int x = n*(n+1)*(n+2)/6;
    if(x > 1000000) break;
    r.push_back(x);
    //    printf("%d %d\n", n, x);
  }

  dp[0] = odp[0] = 0;

  REP(i, 0, r.size()){
    int m = r[i];
    REP(j, m, M_MAX+1)
      dp[j] = min(dp[j], dp[j-m]+1);
    if(m%2)
      REP(j, m, M_MAX+1)
	odp[j] = min(odp[j], odp[j-m]+1);
  }

  //  printf("end\n");
  while(scanf("%d", &n) && n)
    printf("%d %d\n", dp[n], odp[n]);

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main(int argc, char *argv[])
{
  const int N = 100001;
  vector<int> full(N);
  vector<int> odd(N);
  for(int i = 0; i < N; i++) full[i] = i;
  for(int i = 0; i < N; i++) odd[i] = i;
  for(int n = 2; ; n++) {
    const int t = (n * (n+1) * (n+2))/6;
    if(t >= N) break;
    for(int i = 0; i + t < N; i++) {
      const int k = i + t;
      if(full[i] + 1 < full[k]) full[k] = full[i] + 1;
      if(t & 1) {
        if(odd[i] + 1 < odd[k]) odd[k] = odd[i] + 1;
      }
    }
  }
  
  for(int t = 1;; t++) {
    int n;
    cin >> n;
    if(n == 0) break;
    cout << full[n] << " " << odd[n] << endl;
  }
  return 0;
}