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 <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

template<typename T>
void dump(T a, int n) { for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? '\n' : ' '); }

template<typename T>
void dump(T a) { dump<T>(a, a.size()); }

const int LIM = 1000000;
const int INF = INT_MAX;

int main(void) {
	VI nums;
	VI evens;
	for (int i= 1; i <= LIM; i++) {
		int num = i * (i + 1) * (i + 2) / 6;
		if (num > LIM) {
			break;
		}

		nums.push_back(num);

		if (num % 2) {
			evens.push_back(num);
		}
	}

	VI dpa(LIM + 1, INF);
	VI dpb(LIM + 1, INF);
	dpa[0] = 0;
	dpb[0] = 0;
	
	for (int i = 0; i < LIM; i++) {
		if (dpa[i] != INF) {
			for (auto a : nums) {
				int n = i + a;
				if (n <= LIM) {
					dpa[n] = min(dpa[n], dpa[i] + 1);
				}
			}
		}

		if (dpb[i] != INF) {
			for (auto b : evens) {
				int n = i + b;
				if (n <= LIM) {
					dpb[n] = min(dpb[n], dpb[i] + 1);
				}
			}
		}
	}

	for (int N; cin >> N, N;) {
		cout << dpa[N] << " " << dpb[N] << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
const int R = 1000000+1;
int dp1[R],dp2[R],T[144];

void solve(void) {
    for (int i = 1; i < R; i++) dp1[i] = dp2[i] = R;
    for (int i = 1; i < 145; i++) T[i-1] = i*(i+1)*(i+2)/6;
    for (int i = 0; i < 144; i++) {
        int t = T[i];
        for (int j = t; j < R; j++) {
            if (dp1[j-t] < R) dp1[j] = min(dp1[j], dp1[j-t]+1);
            if (t%2 == 0) continue;
            if (dp2[j-t] < R) dp2[j] = min(dp2[j], dp2[j-t]+1);
        }
    }
}

int main(void){
    solve();
    while (1) {
        int N;
        cin >> N;
        if (N == 0) break;
        printf("%d %d\n",dp1[N],dp2[N]);
    }
    return 0;    
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[190]={0},b[60]={0},c[200001]={0,1,2,3},d[200001],k=0,i,j,n;
  for(i=1;i<100;i++)a[k++]=i*(i+1)*(i+2)/6;
  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];
  for(i=1;i<99;i++)for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;
  for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-2;i++)for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;
  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

vector<int> tetra;
vector<int> oddTetra;
int dp[1000000];
int oddDp[1000000];
int N;

const int MAX = 1000000;

void initialize() {
  for (int i = 1;;i++) {
    int n = i * (i + 1) * (i + 2) / 6;
    if (n > MAX) {
      break;
    }
    tetra.push_back(n);
    if (n % 2 == 1) {
      oddTetra.push_back(n);
    }
  }
  fill(dp, dp + 1000000, MAX);
  fill(oddDp, oddDp + 1000000, MAX);
  /*
  for (int i = 0; i < tetra.size(); i++) {
    printf("%d\n", tetra[i]);
  }
  */
}

void solve() {
  dp[0] = oddDp[0] = 0;
  for (int i = 1; i < MAX; i++) {
    for (int j = 0; j < tetra.size(); j++) {
      if (tetra[j] > i) {
        break;
      }
      dp[i] = min(dp[i], 1 + dp[i - tetra[j]]);
    }
    for (int j = 0; j < oddTetra.size(); j++) {
      if (oddTetra[j] > i) {
        break;
      }
      oddDp[i] = min(oddDp[i], 1 + oddDp[i - oddTetra[j]]);
    }
  }
}

int main() {
  initialize();
  solve();
  while (true) {
    scanf("%d ", &N);
    if (N == 0) {
      break;
    }
    printf("%d %d\n", dp[N], oddDp[N]);
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const int INF = 1e8;
const int MAX_N = 1e6;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> sum(201, 0);
    for (int i = 1; i <= 200; ++i) {
        sum.at(i) = i * (i + 1) * (i + 2) / 6;
    }

    vector<vector<int> > dp(2, vector<int>(MAX_N, INF));
    dp.at(0).at(0) = 0;
    dp.at(1).at(0) = 0;
    dp.at(0).at(1) = 1;
    dp.at(1).at(1) = 1;
    for (int i = 0; i < MAX_N; ++i) {
        for (auto &x : sum) {
            if (i + x >= MAX_N) break;
            dp.at(0).at(i + x) = min(dp.at(0).at(i + x), dp.at(0).at(i) + 1);
            if (x % 2 == 0) continue;
            dp.at(1).at(i + x) = min(dp.at(1).at(i + x), dp.at(1).at(i) + 1);
        }
    }

    while (true) {
        int N;
        cin >> N;
        if (N == 0) break;
        cout << dp.at(0).at(N) << ' ' << dp.at(1).at(N) << endl;
    }

    return 0;
}