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<algorithm>

using namespace std;
vector<int> P;
vector<int> oddP;
int memo[1001001];
int mome[1001001];

void hoge(){

    for(int i=1; ; i++){
        int p=i*(i+1)*(i+2)/6;
        if(p>=1001001) break;
        P.push_back(p);
    }
    for(int i=0; i<P.size(); i++){
        memo[P[i]]=1;
        if(P[i]%2) mome[P[i]]=1;
    }
}

int rec(int n, bool odd){

    if(odd){
        if(mome[n]!=0) return mome[n];
    }else{
        if(memo[n]!=0) return memo[n];
    }
    int ret=1001001;
    for(int i=0; n-P[i]>0; i++){
        if(odd&&(P[i]%2==0)) continue;
        ret=min(ret, rec(n-P[i], odd)+1);
    }
    if(odd){
        return mome[n]=ret;
    }else{
        return memo[n]=ret;
    }

}

int main(){

    hoge();
    bool odd=true;
    while(1){
        int N;
        cin>> N;
        if(!N) break;

        cout<< rec(N, !odd)<<" ";
        cout<< rec(N, odd)<< endl;
    }

    return 0;
}

C++: #include <iostream>
#include <fstream>

using namespace std;

int z1[1000000] = { 0 };
int z2[1000000] = { 0 };

void pollock(int n) {
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= n; i++) {
		z1[i*(i + 1)*(i + 2) / 6] = 1;
		if ((i*(i + 1)*(i + 2) / 6) % 2 == 1) z2[i*(i + 1)*(i + 2) / 6] = 1;
	}

	for (int i = 2; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			if (z1[i] == 0 || (z1[i] != 0 && z1[j] + z1[i - j] < z1[i])) z1[i] = z1[j] + z1[i - j];
			if (z2[i] == 0 || (z2[i] != 0 && z2[j] + z2[i - j] < z2[i])) z2[i] = z2[j] + z2[i - j];
		}
	}

	cout << z1[n] << " " << z2[n] << endl;
}

int main() {
	ifstream fin("C");
	int n;
	fin >> n;
	pollock(n);
	
	return 0;
}

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

int main() {
    vector<long long> poloc;
    vector<long long> odd_poloc;
    for (long long i = 1; i * (i + 1) * (i + 2) / 6LL <= 1000000LL; ++i) {
        long long pl = i * (i + 1) * (i + 2) / 6LL;
        poloc.push_back(pl);
        if (pl % 2) odd_poloc.push_back(pl);
    }

    vector<int> dp(1000000LL + 100, INT_MAX);
    vector<int> odd_dp(1000000LL + 100, INT_MAX);
    dp[0] = odd_dp[0] = 0;
    for (int i = 0; i <= 1000000LL; ++i) {
        if (dp[i] != INT_MAX) {
            for (long long pl : poloc) {
                if (i + pl > 1000000LL) break;
                dp[i + pl] = min(dp[i + pl], dp[i] + 1);
            }
        }
        if (odd_dp[i] != INT_MAX) {
            for (long long pl : odd_poloc) {
                if (i + pl > 1000000LL) break;
                odd_dp[i + pl] = min(odd_dp[i + pl], odd_dp[i] + 1);
            }
        }
    }
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        cout << dp[n] << " " << odd_dp[n] << endl;
    }
    return 0;
}

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

enum{ALL, ODD, SIZE};
vector<int> seq;

inline bool toOdd(int &nowId, int nowN){
    while((seq[nowId] & 1) == 0){
        nowId--;
    }
    return nowId < 0;
}

int main(int argc, const char * argv[]) {
    for(int i = 1; i < 400; i++){
        seq.push_back(i*(i+1)*(i+2)/6);
    }
    
    while(1){
        int n; cin >> n;
        if(!n) break;
        
        int id = int(distance(seq.begin(), lower_bound(seq.begin(), seq.end(), n)));
        
        int minimum[2] = {5,1000};
        for(; id >= 0; id--){
            int cnt[2] = {0, 0};
            
            for(int i = 0; i < SIZE; i++){
                int nowId = id, nowN = n;
                
                while(nowN > 0 && nowId >= 0){
                    if(i&1 && toOdd(nowId,nowN)) break;
                    
                    if(nowN >= seq[nowId]){
                        nowN -= seq[nowId];
                        cnt[i]++;
                    } else {
                        while(nowId > 0 && nowN < seq[nowId]){
                            nowId--;
                        }
                        if(i&1 && toOdd(nowId,nowN)) break;
                        
                        if(nowId >= 0){
                            nowN -= seq[nowId];
                            cnt[i]++;
                        }
                    }
                }
                if(nowN == 0) minimum[i] = min(minimum[i], cnt[i]);
            }

        }
        cout << minimum[0] << " " << minimum[1] << endl;
    }
}