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>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    vector<int> queries;
    int q_max = 0;
    while(1){
        int q;
        cin >> q;
        if(q == 0) break;
        queries.push_back(q);
        q_max = max(q_max, q);
    }

    int num = 0;
    vector<int> tetra;
    int x = 1;
    while(num <= q_max){
        num = x * (x+1) * (x+2) / 6;
        tetra.push_back(num);
        ++x;
    }

    int m = tetra.size();

    const int INF = 1001001001;
    vector<vector<int>> dp(2, vector<int>(q_max+1, INF)); // 0: all, 1: odd only
    dp[0][0] = 0;
    dp[1][0] = 0;
    rep1(i, q_max+1){
        rep(j, m){
            if(tetra[j] > i) break;
            dp[0][i] = min(dp[0][i], dp[0][i-tetra[j]] + 1);
            if(tetra[j]%2 == 1) dp[1][i] = min(dp[1][i], dp[1][i-tetra[j]] + 1);
        }
    }

    rep(i, queries.size()) cout << dp[0][queries[i]] << " " << dp[1][queries[i]] << endl;

    return 0;
}

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

int v[200], dp[1000001], dp2[1000001];
vector<int> v2;

int main()
{
  v[0] = 1;
  v2.push_back(1);
  for(int i = 1; i < 200; i++)
  {
    v[i] = v[i - 1];
    for(int j = 0; j <= i; j++)
      v[i] += j + 1;
    if(v[i] % 2)
      v2.push_back(v[i]);
  }
  fill(dp, dp + 1000001, 1000000000);
  fill(dp2, dp2 + 1000001, 1000000000);
  dp[0] = dp2[0] = 0;
  for(int i = 0; i <= 1000000; i++)
  {
    for(int j = 0; j < 200; j++)
    {
      if(v[j] <= i)
        dp[i] = min(dp[i], dp[i - v[j]] + 1);
      if(j < v2.size() && v2[j] <= i)
        dp2[i] = min(dp2[i], dp2[i - v2[j]] + 1);
    }
  }
  while(true)
  {
    int n;
    cin >> n;
    if(!n)
      break;
    cout << dp[n] << " " << dp2[n] << endl; 
  }
}

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

const int INF = 1001001001;

std::vector<int> A, B;
int dp[2][1000001], dp2[2][1000001];

void DP(int (&dp)[2][1000001], std::vector<int> &v){
    for(int i=0;i<=1000000;i++){
        dp[0][i] = INF;
    }
    dp[0][0] = 0;

    int L = v.size();
    int prev = 0, next = 1;
    for(int i=0;i<L;i++){
        for(int j=0;j<=1000000;j++){
            dp[next][j] = dp[prev][j];
            if(j-v[i] >= 0){
                dp[next][j] = std::min(dp[next][j], dp[next][j-v[i]] + 1);
            }
        }

        prev = !prev;
        next = !next;
    }
}

int main(){
    for(int i=1;;i++){
        long long x = 1ll * i * (i+1) * (i+2) / 6;
        if(x <= 1000000ll){
            A.push_back(x);
            if(x & 1){B.push_back(x);}
        }else{
            break;
        }
    }
    
    DP(dp, A);
    DP(dp2, B);
    
    int N;
    while(scanf("%d", &N), N){
        printf("%d %d\n", dp[0][N], dp2[0][N]);
    }
}

C++: #include <iostream>

using namespace std;

int main() {
	int N;
	int v[200];
	static int ansA[1000000], ansB[1000000];
	for (int i = 0; i<=200; i++) v[i] = i * (i + 1)*(i + 2) / 6;
	ansA[0] = ansB[0] = 0;
	for (int i = 1; i<1000000; i++) {
		ansA[i] = ansB[i] = i;
		for (int j = 0; i - v[j] >= 0; j++) {
			ansA[i] = min(ansA[i], A[i - v[j]] + 1);
			if (v[j] % 2 == 1)
				ansB[i] = min(ansB[i], ansB[i - v[j]] + 1);
		}
	}
	while (cin >> N, N)
		cout << ansA[N] << " " << ansB[N] << endl;
}

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

using namespace std;
typedef long long ll;

#define REP_N(i,n,s) for(ll i=0; i<(ll)n; i+=s)
#define REP(i,n) REP_N(i,n,1)

ll table[1000000];
ll pollock[1000001];
ll dp[1000001];

void solution(ll output[1000001], int interval) {
	output[0] = 0;
	ll current_i = 1-interval;
	REP(i, 1000001) if (i != 0) {
		if (table[current_i + interval] == i) current_i += interval;
		ll minimum = 1000001;
		REP_N(j, current_i+1, interval) if(j!=0) minimum = min(output[i - table[j]] + 1, minimum);
		output[i] = minimum;

	}
}

int main() {
	
	{
		ll i = 0;
		table[0] = 0;
		while (1000001 > table[i++]) table[i] = i*(i + 1)*(i + 2) / 6;
	}

	solution(pollock, 1);
	solution(dp, 4);

	while (true) {
		int n;
		cin >> n;
		if (n==0) break;
		
		cout << pollock[n] << " " << dp[n] << endl;
	}

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int dp[2][1000001];
int odd[2][1000001];
int Odd(int n,int w){
  for(int i=0;i<2;i++)
    for(int j=0;j<=n;j++){
      odd[i][j]=99999999;
      if(i==0)odd[i][j]=j;
      if(j==0)odd[i][j]=0;
    }

    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if((i*(i+1)*(i+2)/6)%2==0){
	  odd[i&1][j]=odd[i&1^1][j];
	}else if(j<i*(i+1)*(i+2)/6){
	  odd[i&1][j]=odd[i&1^1][j];
	}else{
	  odd[i&1][j]=min(odd[i&1^1][j],odd[i&1][j-i*(i+1)*(i+2)/6]+1);
	}
      }
    }
    return 1;
}

int main(){
  int n=1000000;
  int w=300;
    for(int i=0;i<2;i++)
      for(int j=0;j<=n;j++){
	dp[i][j]=99999999;
	if(i==0)dp[i][j]=j;
	if(j==0)dp[i][j]=0;
      }
    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if(j<i*(i+1)*(i+2)/6){
	  dp[i&1][j]=dp[i&1^1][j];
	}else{
	  dp[i&1][j]=min(dp[i&1^1][j],dp[i&1][j-i*(i+1)*(i+2)/6]+1);
	}
	//cout << "dp[" << i << "][" << j <<"]:"<< dp[i][j] << endl;
      }
    }
    int a;
    Odd(n,w);
    while(cin>>a,a){
      int b=0;
      while(b*(b+1)*(b+2)/6<a)b++;
      cout << dp[b%2][a] << " " << odd[b%2][a] << endl;
    }
  return 0;
}