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 all(v) (v).begin(), (v).end()
#define P pair<int,int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define ll long long

#define INF 1e9;
#define N 1001000

vector<int> A, B, odd;
int dp1[N], dp2[N];

void init(){
    A.push_back(1);
    B.push_back(1);
    odd.push_back(1);

    for(int i = 1;; i++){
        int x = A[i-1] + (i + 1);
        if(x > N) break;
        else A.push_back(x);
    }
    for(int i = 1;; i++){
        int x = B[i-1] + A[i];
        if(x > N) break;
        else B.push_back(x);
        if(x % 2 == 1) odd.push_back(x);
    }

    rep(i,N) dp1[i] = INF;
    rep(i,N) dp2[i] = INF;
    dp1[0] = 0, dp2[0] = 0;
    for(int i = 0; i < B.size(); i++){
        for(int j = 1; j < N; j++){
            if(j - B[i] >= 0){
                dp1[j] = min(dp1[j],dp1[j - B[i]] + 1);
            }
        }
    }
    for(int i = 0; i < odd.size(); i++){
        for(int j = 1; j < N; j++){
            if(j - odd[i] >= 0){
                dp2[j] = min(dp2[j],dp2[j - odd[i]] + 1);
            }
        }
    }
}

int main() {
    init();
    while(true){
        int n;
        cin >> n;
        if(n == 0) return 0;

        cout << dp1[n] << " " << dp2[n] << endl;
    }
}

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

using namespace std;

int main(){
	vector<int> dp1(1000000,1000000);
	dp1[0] = 0;
	vector<int> dp2(1000000,1000000);
	dp2[0] = 0;
	for(int i=1;i*(i+1)*(i+2)/6<1000000;i++){
		int x = i*(i+1)*(i+2)/6;
		for(int j=0;j<1000000-x;j++){
			dp1[j+x] = min(dp1[j+x],dp1[j] + 1);
			if(x%2 == 1) dp2[j+x] = min(dp2[j+x],dp2[j] + 1);
		}
	}
	
	int a;
	while(cin >> a,a > 0){
		cout << dp1[a] << " " << dp2[a] << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int INF = 100000000;
int main(){
  int n, M = 1000000;
  vector<int> A(M,INF), A_odd(M,INF);
  int t = 1, k = 3;
  A[0] = 0;
  A_odd[0] = 0;
  while(t < 1000000){
    for(int k = 0; k+t < M; ++k){
      A[k+t] = min(A[k]+1,A[k+t]);
      if(t%2) A_odd[k+t] = min(A_odd[k]+1,A_odd[k+t]);
    }
    ++k;
    t *= k;
    t /= (k-3);
  }
  while(cin >> n, n){
    cout << A[n] << " " << A_odd[n] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
const int INF = 1e9;
 
int main()
{
	cin.sync_with_stdio(false);
    vector<int> dp(MAX, INF), res(MAX, INF), four, odd;
    for (int i = 1; i * (i + 1) * (i + 2) / 6 < MAX; i++) {
        four.push_back(i * (i + 1) * (i + 2) / 6);
        if (i * (i + 1) * (i + 2) / 6 % 2)
            odd.push_back(i * (i + 1) * (i + 2) / 6);
    }
    dp[0] = res[0] = 0;
    for (int j = 0; j < MAX; j++) {
        if (dp[j] != INF) {
            for (int k = 0; k < (int)four.size() && j + four[k] < MAX;k++) {
                dp[j + four[k]] = min(dp[j + four[k]], dp[j] + 1);
            }
        }
    }
    for (int j = 0; j < MAX; j++) {
        if (res[j] != INF) {
            for (int k = 0; k < (int)odd.size() && j + odd[k] < MAX; k++) {
                res[j + odd[k]] = min(res[j + odd[k]], res[j] + 1);
            }
        }
    }
    int n;
    while (cin >> n, n) {
        printf("%d %d\n", dp[n], res[n]);
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<int> V,W;
int MAX_NUM = 1000000;
vector<int> table(MAX_NUM);
P dp(int N){
    P ans;
    table.assign(N+1,INF);
    table[0] = 0;
    rep(i,0,V.size()){
        rep(j,0,N+1){
            if(j + V[i] > N)break;
            table[j + V[i]] = min(table[j + V[i]], table[j] + 1);
        }
    }
    ans.first = table[N]; 
    table.assign(N+1,INF);
    table[0] = 0;
    rep(i,0,W.size()){
        rep(j,0,N+1){
            if(j - W[i] >= 0)table[j] = min(table[j], table[j - W[i]] + 1);
        }
    }
    ans.second = table[N];
    return ans;
}
main(){
    for(int i = 1;i * (i + 1) * (i + 2) / 6 <= MAX_NUM;i++){
        int num = i * (i + 1) * (i + 2) / 6; 
        V.push_back(num);
        if(i % 4 == 1)W.push_back(num);
    }

    int N;
    cin >> N;
    while(N){
        auto ans = dp(N);
        cout << ans.first << " " << ans.second << endl;
        cin >> N;
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000100

int dp[SIZE], dp_o[SIZE];

int main(){
  for(int i=0;i<SIZE;i++) dp[i] = dp_o[i] = i;

  for(int i=2;(ll)i*(i+1)*(i+2)<SIZE*6;i++){
    int num = (ll)i*(i+1)*(i+2)/6;

    for(int j=0;j<SIZE-num;j++){
      dp[j+num] = min(dp[j+num], dp[j] + 1);
      if(num%2)
        dp_o[j+num] = min(dp_o[j+num], dp_o[j] + 1);
    }
  }

  int n;

  while(1){
    scanf("%d", &n);
    if(!n) break;

    printf("%d %d\n", dp[n], dp_o[n]);
  }
  
  return 0;
}