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 <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
bool isPrime(ll x) {if (x == 2) return true;if (x < 2 || x % 2 == 0) return false;ll i = 3;while (i <= sqrt(x)) {if (x%i == 0) return false;i += 2;}return true;}

vl dd(int max) {
	vl rt;
	int n = 1;
	while (true)
	{
		ll next = n*(n + 1)*(n + 2) / 6;
		if (max  <= next) { rt.pb(next); break; }
		rt.pb(next);
		n++;
	}
	return rt;
}

vl llist;

int bfs(int target) {
	queue<ll> q;
	Foreach(i, llist) {
		if (i == target) { return 1; }
		else if (i < target) q.push(i);
	}
	int cnt = 2;
	while (1){
		queue<ll> next;
		int ss = q.size();
		FOR(i, 0, ss) {
			int x = q.front();
			q.pop();
			Foreach(k, llist) {
				if (k + x > target) break;
				if (k + x == target) return cnt;
				if (k + x < target) next.push(k + x);
			}
		}
		cnt++;
		q = next;
	}
}

int bfs2(int target) {
	queue<ll> q;
	vl oddlist = llist;
	removeAll(oddlist, [](ll x) {return x % 2 == 0; });
	Foreach(i, oddlist) {
		if (i == target) { return 1; }
		else if (i < target) q.push(i);
	}
	int cnt = 2;
	while (1) {
		set<ll> next;
		int ss = q.size();
		FOR(i, 0, ss) {
			int x = q.front();
			q.pop();
			Foreach(k, oddlist) {
				if (k + x > target) break;
				if (k + x == target) return cnt;
				if (k + x < target) next.insert(k + x);
			}
		}
		cnt++;
		queue<ll> nn;
		Foreach(i, next) nn.push(i);
		q = nn;
	}
}

int main() {
	vi query;
	int k;
	while (cin >> k, k)query.pb(k);
	auto mm = max_element(beginend(query));
	llist = dd(*mm);
	//ShowAll(llist);
	Foreach(q, query) {
		cout << bfs(q) << " " << bfs2(q) << endl;
	}
	return 0;
}

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

int main(void){
	int i, j, k, n, min1;
	int dp[1000001];
	scanf("%d",&n);
	while(n != 0){
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		for(k = 0;k < n;k++){
			for(i = n;i >= 0;i--){
				if(dp[i] != INF){
					for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
						if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1)
							dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
					}
				}
			}
			if(dp[n] == 1)
				break;
		}

		min1 = dp[n];
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		for(k = 0;k < n;k++){
			for(i = n;i >= 0;i--){
				if(dp[i] != INF){
					for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
						if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1 && j * (j + 1) * (j + 2) / 6 % 2 == 1)
							dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
					}
				}
			}
			if(dp[n] == 1)
				break;
		}
		printf("%d %d\n",min1,dp[n]);
		scanf("%d",&n);
	}
	return 0;
}