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 <algorithm>
using namespace std;

int tr[300];
int sq[300];
int dp1[1000000];
int dp2[1000000];

int main() {

  for(int i=1; i < 300; i++) {
    tr[i] = tr[i-1] + i;
    sq[i] = sq[i-1] + tr[i];
  }
  for(int i=1; i < 1000000; i++) {
      dp1[i] = 1000111000;
      dp2[i] = 1000111000;
  }

  for(int i=0; i<1000000; i++) {
    for(int j=1; j < 300; j++) {
      if(i+sq[j] < 1000000) {
        dp1[i+sq[j]] = min(dp1[i] + 1, dp1[i+sq[j]]);
        if(sq[j]%2 == 1) {
          dp2[i+sq[j]] = min(dp2[i] + 1, dp2[i+sq[j]]);
        }
      }
    }
  }

  int n;
  while(cin >> n, n) {
    cout << dp1[n] << " " << dp2[n] << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

const int MAX_N = 1e6;
const int INF = 1e8;
int dp[MAX_N+1],dp2[MAX_N+1];

int main(){
  fill(dp,dp+MAX_N,INF);
  fill(dp2,dp2+MAX_N,INF);
  dp[0] = dp2[0] = 0;

  int n = 1, pil = 1;
  do{
    for(int i=0;i<=MAX_N-pil;i++){
      dp[i+pil] = min(dp[i+pil], dp[i] + 1);
    }
    if(pil % 2){
      for(int i=0;i<=MAX_N-pil;i++){
	dp2[i+pil] = min(dp2[i+pil], dp2[i] + 1);
      }
    }

    n++;
    pil = n*(n+1)*(n+2)/6;
  }while(pil<=MAX_N);

  while(cin >> n, n){
    cout << dp[n] << " " << dp2[n] << endl;
  }
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

constexpr int MAX_VAL = 1e6;

void makePyramidal(vector<int>* pyramidal, vector<int>* odd_pyramidal, const int& max_val) {
    for (int i = 1; ; i++) {
        int val = i * (i+1) * (i+2) / 6;
        if (val > max_val) { break; }
        pyramidal->push_back(val);
        if (val % 2) { odd_pyramidal->push_back(val); }
    }
    reverse(pyramidal->begin(), pyramidal->end());
    reverse(odd_pyramidal->begin(), odd_pyramidal->end());
}

int searchPyramidal(const vector<int>& pyramidal, const int& val, const int& i, const int& n) {
    if (val == 0) { return n; }
    if (val < 0 or i >= pyramidal.size()) { return MAX_VAL; }
    const int a = searchPyramidal(pyramidal, val - pyramidal[i], i, n + 1);
    const int b = searchPyramidal(pyramidal, val - pyramidal[i], i + 1, n + 1);
    const int c = searchPyramidal(pyramidal, val, i + 1, n);
    return min(a, min(b, c));
}

pair<int,int> solve(const vector<int>& pyramidal, const vector<int>& odd_pyramidal, const int& val) {
    int a = searchPyramidal(pyramidal, val, 0, 0);
    int b = searchPyramidal(odd_pyramidal, val, 0, 0);
    return make_pair(a, b);
}

int main() {
    ios::sync_with_stdio(false);

    vector<int> pyramidal;
    vector<int> odd_pyramidal;
    makePyramidal(&pyramidal, &odd_pyramidal, MAX_VAL);

    int val;
    while (true) {
        cin >> val;
        if (val == 0) { break; }
        auto p = solve(pyramidal, odd_pyramidal, val);
        cout << p.first << " " << p.second << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define N 1000000
// #define N 200
int main()
{
    int n;
    vector<int> p, q;
    int k=1;
    while(1){
        int a = k*(k+1)*(k+2)/6;
        if(a>N) break;
        p.push_back(a);
        if(a&1) q.push_back(a);
        k++;
    }
    
    vector<int> dp(N+1), dq(N+1);
    rep(i, N+1){
        dp[i] = i;
        dq[i] = i;
    }
    FOR(i, 1, p.size()){
        // prvec(dp);
        FOR(j, p[i], N+1){
            chmin(dp[j],dp[j-p[i]] + 1);
        }
        // pr(dp[40]);
    }
    
    FOR(i, 1, q.size()){
        FOR(j, q[i], N+1){
            chmin(dq[j], dq[j-q[i]] + 1);
        }
    }
    // prvec(p);
    while(cin >> n){
        if(n==0) break;
        printf("%d %d\n", dp[n], dq[n]);
    }
    return 0;}