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<cstring>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1111111];
int memo2[1111111];
 
int solve(int n){
   
  if(!n) return 0;
  if(~memo[n]) return memo[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(p[i]&1 && n >= p[i]) ans = min(ans, solve2(n-p[i])+1);
 
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));
 
  for(int i=0;i<181;i++) p[i] = i*(i+1)*(i+2)/6;

  for(int i=0;i<1111111;i+=10){ solve(i), solve2(i); }
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
 
}

C++: #include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <list>
#include <stack>
#include <queue>
#define INF 1000000
using namespace std;

typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string,int> M;

int N;
int dp[1000001];
int dp2[1000001];
int tetra[1000];

int main()
{
    for (int i = 0; i <= INF; i++) {dp[i] = INF;dp2[i] = INF;}
    int n = 1;
    int tmp;
    while ((tmp = (n * (n + 1) * (n + 2) / 6)) <= 1000000) {
        tetra[n++] = tmp;
        dp[tmp] = 1;
        if (tmp % 2) dp2[tmp] = 1;
    }
    int max = 1;
    while (cin >> N, N) {
        if (max > N) {
            cout <<  dp[N] << " ";
        } else {
            for (int i = max; i <= N; i++) {
                for (int j = 1; tetra[j] <= i; j++) {
                    dp[i] = min(dp[i], dp[i - tetra[j]] + 1);
                }
            }
            cout << dp[N] << " ";
        }

        if (max > N) {
            cout << dp2[N] << endl;
        } else {
            for (int i = max; i <= N; i++) {
                for (int j = 1; tetra[j] <= i; j++) {
                    if (tetra[j] % 2)
                        dp2[i] = min(dp2[i], dp2[i - tetra[j]] + 1);
                }
            }
            cout << dp2[N] << endl;
            max = N;
        }
    }

    return 0;
}

C++: #include <stdio.h>
#define INF 0x7FFFFFFF

int main(void){
	int i, j, n ,small1, small2;
	int dp1[1000000],dp2[1000000];
	scanf("%d",&n);
	while(n != 0){
		for(i = 0;i <= n;i++)
			dp1[i] = dp2[i] = INF;

		dp1[0] = dp2[0] = 0;
		small1 = small2 = INF;
		for(i = 0;i < n;i++){
			if((small1 > dp1[i] || small2 > dp2[i]) && (dp1[i] != INF || dp2[i] != INF)){
				for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
					if(dp1[(j * (j + 1) * (j + 2)) / 6 + i] > dp1[i] + 1 && dp1[i] != INF)
						dp1[(j * (j + 1) * (j + 2)) / 6 + i] = dp1[i] + 1;
					if(dp2[(j * (j + 1) * (j + 2)) / 6 + i] > dp2[i] + 1 && ((j * (j + 1) * (j + 2)) / 6) % 2 == 1 && dp2[i] != INF)
						dp2[(j * (j + 1) * (j + 2)) / 6 + i] = dp2[i] + 1;
				}
			}
			if(small1 > dp1[n])
				small1 = dp1[n];
			if(small2 > dp2[n])
				small2 = dp2[n];
		}
		printf("%d %d\n",dp1[n],dp2[n]);
		scanf("%d",&n);
	}
	return 0;
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  vector<int> v1;
  vector<int> v2;
  int tn = 1;
  while(1){
      int tmp = tn*(tn+1)*(tn+2)/6;
      if(tmp < 1000000){
        v1.push_back(tmp);
        if(tmp % 2 != 0) v2.push_back(tmp);
      }else{
        break;
      }
      tn++;
  }

  int INF = 1000000000;
  int dp1[1000005], dp2[1000005];

  REP(i,0,1000005) dp1[i] = i, dp2[i] = i;

  REP(i,1,180){
    REP(j,0,1000005){
      if(j-v1[i] >= 0) dp1[j] = min(dp1[j], dp1[j-v1[i]] + 1);
    }
  }
  REP(i,1,45){
    REP(j,0,1000005){
      if(j-v2[i] >= 0) dp2[j] = min(dp2[j], dp2[j-v2[i]] + 1);
    }
  }

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

    cout<<dp1[N]<<" "<<dp2[N]<<endl;

  }

  return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int normal[1001000];
int odd[1001000];

int main() {
  MEMSET(normal, 0x0f);
  MEMSET(odd, 0x0f);
  normal[0] = odd[0] = 0;
  REP(i, 1000001) {
    REP(j, 10000) {
      int plus = j * (j + 1) * (j + 2) / 6;
      if (i + plus > 1000000) { break; }
      normal[i + plus] = min(normal[i + plus], normal[i] + 1);
      if (plus & 1) {
        odd[i + plus] = min(odd[i + plus], odd[i] + 1);
      }
    }
  }
  int n;
  while (scanf("%d", &n), n) {
    printf("%d %d\n", normal[n], odd[n]);
  }
}