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 <cmath>
#include <algorithm>
#include <queue>

using namespace std;

#define INF 100000000


int main(){
	int table1[201]={};
	vector<int> table2;
	for(int i=1;i<201;i++){
		table1[i-1]=i*(i+1)*(i+2)/6;
		if(table1[i-1]%2!=0){
			table2.push_back(table1[i-1]);
		}
	}
	int count1[100001];
	int count2[100001];
	for(int i=0;i<100001;i++){
		count1[i]=INF;
		count2[i]=INF;
	}
	count1[0]=0;
	count2[0]=0;
	count1[1]=1;
	count2[1]=1;
	for(int i=2;i<100001;i++){
		for(int j=0;j<201;j++){
			if(table1[j]>i)break;
			count1[i] = min(count1[i],count1[i-table1[j]]+1);
		}
	}
	for(int i=2;i<100001;i++){
		for(int j=0;j<201;j++){
			if(table2[j]>i)break;
			count2[i] = min(count2[i],count2[i-table2[j]]+1);
		}
	}
	int n;
	while(cin>>n&&n!=0){
		cout << count1[n] << " " << count2[n] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

#define INF 1000000;

Vi odd;

int t(int x) { return x*(x+1)*(x+2)/6; }

int dfs(int i, int rest) {
  if (rest == 0) return 0;
  if (rest < 0) return INF;
  if (i == 0) return rest;

  return min(dfs(i-1, rest), dfs(i, rest-odd[i]) + 1);
}  

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

  Vi one, two;
  for (int i = 1; t(i) <= 1000000; i++) {
    one.push_back(t(i));
    if (t(i)%2) odd.push_back(t(i));
  }

  for (int a : one) {
    for (int b : one) {
      two.push_back(a+b);
    }
  }
  sort(ALL(two));

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

    if (n == *lower_bound(ALL(one), n)) {
      cout << 1;
    } else if (n == *lower_bound(ALL(two), n)) {
      cout << 2;
    } else {
      bool flag = false;
      for (int a : one) {
	if (n - a == *lower_bound(ALL(two), n - a)) {
	  flag = true;
	  break;
	}
      }
      if (flag) {
	cout << 3;
      } else {
	for (int a : two) {
	  if (n - a == *lower_bound(ALL(two), n - a)) {
	    flag = true;
	    break;
	  }
	}
	cout << (flag ? 4 : 5);
      }
    }

    cout << ' ' << dfs(lower_bound(ALL(odd), n) - odd.begin(), n) << endl;
  }    
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

const int lim = 300;
const int lim_ = 1000001;
int tri[lim];
int tetra[lim];
int n;
int table[lim_];
int odd[lim_];
int main() {
    tri[1] = 1;
    rrep(i, 2, lim) {
        tri[i] = tri[i - 1];
        tri[i] += i;
    }
    //cout << tri[lim - 1] << endl;
    tetra[1] = 1;
    rrep(i, 2, lim) {
        tetra[i] = tetra[i - 1];
        tetra[i] += tri[i];
    }
    //rep(i, 5) cout << tetra[i] << " "; cout << endl;
    //cout << tetra[lim - 1] << endl;
    rep(i, lim_) table[i] = odd[i] = inf;
    table[0] = odd[0] = 0;
    rep(i, lim) {
        rep(j, lim_) {
            if (table[j] != inf && j + tetra[i] < lim_) {
                chmin(table[j + tetra[i]], table[j] + 1);
            }
        }
        if (tetra[i] % 2 == 0) continue;
        rep(j, lim_) {
            if (odd[j] != inf && j + tetra[i] < lim_) {
                chmin(odd[j + tetra[i]], odd[j] + 1);
            }
        }
    }
    
    while (cin >> n && n) {
        cout << table[n] << " " << odd[n] << endl;
    }
    
}

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

int main(){
	int num[100010];
	for(int i=0; i< 100010; i++) num[i] = 10e8;
	num[0] = 0;
	for(int j=0; j< 100010; j++){
		for(int i=0; i < 1000; i++){
			int m = i*(i+1)*(i+2)/6;
			if(10010 <= i*(i+1)*(i+2)/6+j) continue;
			num[j+m] = min(num[j]+1, num[j+m]);
		}
	}
	int num2[100010];
	for(int i=0; i< 100010; i++) num2[i] = 10e8;
	num2[0] = 0;
	for(int j=0; j< 100010; j++){
		for(int i=0; i < 1010; i++){
			int m = i*(i+1)*(i+2)/6;
			if(m%2 == 0) continue;
			if(10010 <= i*(i+1)*(i+2)/6+j) continue;
			num2[j+m] = min(num2[j]+1, num2[j+m]);
		}
	}
	int n;
	while(cin >> n, n){
		cout << num[n] << " " << num2[n] << endl;
	}
}