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 <string>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0; i < (n); i++)

const int MAX_N = 1000000;
const int INF = 10000000;

int main() {
  vector<int> simen, odd_simen;

  int n = 1, nv = 1;
  while (nv <= MAX_N) {
    simen.push_back(nv);
    if (nv % 2 == 1) odd_simen.push_back(nv);
    n++;
    nv = n*(n+1)*(n+2) / 6;
  }
  vector<int> dp(MAX_N + 1, INF);
  vector<int> odd_dp(MAX_N + 1, INF);
  dp[0] = odd_dp[0] = 0;

  for (int i = 1; i <= MAX_N; i++) {
    for(int j = 0; j < simen.size(); j++) {
      if (i < simen[j]) break;
      dp[i] = min(dp[i], dp[i - simen[j]] + 1);
    }
    for(int j = 0; j < odd_simen.size(); j++) {
      if (i < odd_simen[j]) break;
      odd_dp[i] = min(odd_dp[i], odd_dp[i - odd_simen[j]] + 1);
    }
  }

  while (true) {
    int m;
    cin >> m;
    if (m == 0) break;

    cout << dp[m] << " " << odd_dp[m] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){

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

}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

class Solver {
};

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

		vector<long>vals;
		long now = 1;
		while (true) {
			long val = (now * (now + 1) * (now + 2)) / 6;
			if (val > n)break;
			vals.emplace_back(val);
			now++;
		}
		vector<int> cnts(n + 1, 1e9);
		vector<int> oddCnts(n + 1, 1e9);
		cnts[0] = 0;
		oddCnts[0] = 0;
		for (int i = 0; i < vals.size(); i++) {
			for (int j = 0; j <= n; j++) {
				if (j + vals[i] <= n) {
					cnts[j + vals[i]] = min(cnts[j + vals[i]], cnts[j] + 1);
				}
				if (vals[i] % 2 == 1 && j + vals[i] <= n) {
					oddCnts[j + vals[i]]
						= min(oddCnts[j + vals[i]], oddCnts[j] + 1);
				}
			}
		}
		cout << cnts[n] << ' ' << oddCnts[n] << endl;
	}
}

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

int main(){
  int i,j,n,three[1000],four[1000],four_2[1000],c[1000],c_2[1000];

  three[0] = 1;
  four[0] = 1;
  for( i = 1; i < 1000; i++ )three[i] = i+1 + three[i-1];
  for( i = 1; i < 1000; i++ )four[i] = three[i] + four[i-1];
  
  int k = 0;
  for( i = 0; i < 1000; i++ ){
    if(four[i] %2 == 1 ){
      four_2[k] = four[i];
      k++;
    }
  }
  
  while(1){
    int n; cin >> n;
    if(n==0)break;
    for( i = 0; i <= n; i++ ){
      c[i] = 2000000;
      c_2[i] = 2000000;
    }

    c[0] = 0;
    for( i = 0; i*i < n; i++ ){
      for( j = four[i]; j <= n; j++ ){
	c[j] = min( c[j],c[j-four[i]] + 1 );
      }
    }

    c_2[0] = 0;
    for( i = 0; i < n; i++ ){
      for ( j = four_2[i]; j <= n; j++ ){
	c_2[j] = min( c_2[j],c_2[j-four_2[i]] + 1 );
      }
    }
    cout << c[n] << " " << c_2[n] << endl;
  }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#define V_MAX 3
//#define V_MAX 1000
using namespace std;


int main(){
  int n;
  vector<int> v(V_MAX);
  int i=0,mx=0;
  int p[200],size;

  while( cin>>n && n ){
    if( i<V_MAX ) v[i]=n;
    else          v.push_back(n);
    i++;
    mx=max(mx,n);
  }
  int vSize=i;

  p[0]=0;
  for( size=1; ; size++ ){
    p[size]= size*(size+1)*(size+2)/6;
    if( p[size]>mx ) break;
  }

  int dMAX = p[size-1] + 1;
  int dp1[dMAX],dp2[dMAX];
  int m,j ;
  fill( dp1,dp1+dMAX,INT_MAX );
  fill( dp2,dp2+dMAX,INT_MAX );

  dp1[0]=0;
  for( i=1;i<size;i++){
    m=p[i];
    for( j=m;j<dMAX;j++ )
      dp1[j] = min( dp1[j],dp1[j-m]+1 );
  }

  dp2[0]=0;
  for( i=1;i<size;i++){
    if( p[i]%2==0 ) continue;
    m=p[i];
    for( j=m;j<dMAX;j++ )
      dp2[j] = min( dp2[j],dp2[j-m]+1 );
  }


  
  for( i=0;i<vSize;i++ )
    cout << dp1[ v[i] ] << " " << dp2[ v[i] ] << endl;

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

vvi tetra(2);
vvi dp(2, vi(1e6, 1e6));

void preset() {
    int n;
    for (int i=0; (n = i*(i+1)*(i+2)/6) < 1e6; i++) {
        tetra[0].push_back(n);
        if (n % 2 == 1) tetra[1].push_back(n);
    }

    for (int i=0; i<2; i++) {
        dp[i][0] = 0;
        for (int k : tetra[i]) {
            for (int j=k; j<1e6; j++) {
                dp[i][j] = min(dp[i][j], dp[i][j-k]+1);
            }
        }
    }
}

int main() {
    preset();

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

    return 0;
}