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<stdio.h>
#include<iostream>
#include<utility>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int n;
    while(1==1)
    {
        scanf("%d\n",&n);
        if(n==0)return 0;
        int dp[1000005]={};
        for(int i=1;i<1000005;i++)dp[i]=-1;
        long long int he[250]={};
        long long int ohe[63]={};
        REP(i,250)he[i]=i*(i+1)*(i+2)/6;
        REP(i,63)ohe[i]=he[i*4+1];
        for(int i=1;i<=5;i++)
        {
            REP(j,n)
            {
                if(dp[j]==i-1)
                {
                    REP(k,250)
                    {
                        if(j+he[k]<=n&&dp[j+he[k]]==-1)
                        {
                            dp[j+he[k]]=i;
                        }
                    }
                }
            }
            if(dp[n]!=-1)break;
        }
        printf("%d ",dp[n]);
        REP(i,1000005)dp[i]=-1;
        dp[0]=0;
        for(int i=1;i<=55;i++)
        {
            REP(j,n)
            {
                if(dp[j]==i-1)
                {
                    REP(k,63)
                    {
                        if(j+ohe[k]<=n&&dp[j+ohe[k]]==-1)
                        {
                            dp[j+ohe[k]]=i;
                        }
                    }
                }
            }
            if(dp[n]!=-1)break;
        }
        printf("%d\n",dp[n]);
    }
    return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iterator>

using namespace std;

int N;

int L[200];
int M[200];
int M_max;
int dp[1000001];

void init() {
    for (int i = 1; i <= 200; i++) {
        L[i - 1] = (i * (i + 1) * (i + 2)) / 6;
    }

    int j = 0;
    for (int i = 0; i < 200 && L[i] <= 1000000; i++) {
        if (L[i] % 2 == 1) {
            M[j++] = L[i];
        }
    }
    M_max = j;

    for (int i = 0; i <= 1000000; i++) {
        dp[i] = 10000000;
    }
    dp[0] = 0;
    for (int i = 1; i <= 1000000; i++) {
        for (int j = 0; j < M_max && M[j] <= i; j++) {
            dp[i] = min(dp[i], dp[i - M[j]] + 1);
        }
    }
}

int f(int nth, int s) {
    int r = N - s;
    int start = distance(L, upper_bound(L, L + 200, r)) - 1;

    int m = 100;
    for (int i = start; i >= 0 && r <= (5 - nth) * L[i]; i--) {
        if (r == L[i]) {
            return nth + 1;
        }

        m = min(m, f(nth + 1, s + L[i]));
    }

    return m;
}

void solve() {
    printf("%d %d\n", f(0, 0), dp[N]);
}

int main() {
    init();
    while (true) {
        scanf("%d", &N);
        if (!N) {
            break;
        }
        solve();
    }
    return 0;
}

C++: #include<vector>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<list>
#include<stack>

using namespace std;

using ll = long long int;
const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<ll> allNum;
    vector<ll> oddNum;

    ll n = 1;

    while(true){
        ll tmp = (n*(n+1)*(n+2))/6;
        if(tmp > 1000000){
            break;
        }
        allNum.push_back(tmp);
        if(tmp&1){
            oddNum.push_back(tmp);
        }
        ++n;
    }

    vector<ll> allDP(1000001,-1);
    vector<ll> oddDP(1000001,-1);

    allDP[0] = 0;
    oddDP[0] = 0;

    for(int i = 0; i < allNum.size(); i++){
        for(int j = 0; j < 1000001; j++) {
            if (j - allNum[i] >= 0 && allDP[j - allNum[i]] >= 0) {
                if (allDP[j] >= 0) {
                    allDP[j] = min(allDP[j], allDP[j - allNum[i]] + 1);
                } else {
                    allDP[j] = allDP[j - allNum[i]] + 1;
                }
            }
        }
    }

    for(int i = 0; i < oddNum.size(); i++){
        for(int j = 0; j < 1000001; j++) {
            if (j - oddNum[i] >= 0 && oddDP[j - oddNum[i]] >= 0) {
                if (oddDP[j] >= 0) {
                    oddDP[j] = min(oddDP[j], oddDP[j - oddNum[i]] + 1);
                } else {
                    oddDP[j] = oddDP[j - oddNum[i]] + 1;
                }
            }
        }
    }

    while(true){
        ll a;
        cin >> a;
        if(a == 0){
            break;
        }
        cout << allDP[a] << " ";
        cout << oddDP[a] << endl;
    }
    return 0;
}