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 <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
long long int N,M,sum=0,a[1005],b[1005],c[1005][30],dp[2000500]={},four[1000]={},dp2[2000500]={};
pll key[1005];
string S[6];
int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 1; i <= 400; i++){
        four[i]=i*(i+1)*(i+2)/6;
    }
    for(long long int i = 1; i <= 1000000; i++){
        dp[i]=INF;
        dp2[i]=INF;
    }
    
    
    for(long long int i = 0; i <= 999999; i++){
        for(long long int j = 1; j <=200; j++){
            if(i+four[j]<=1000000)dp[i+four[j]]=min(dp[i+four[j]],dp[i]+1);
        }
        for(long long int j = 1; j <=200; j++){
            
            if(four[j]%2==0){continue;}
            if(i+four[j]<=1000000)dp2[i+four[j]]=min(dp2[i+four[j]],dp2[i]+1);
        }
    }
    
    while(N!=0){
        cout<<dp[N]<<" "<<dp2[N]<<endl;
        cin>>N;
    }

}

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

using namespace std;

int main(){
    int n;
    vector<int>v;
    int m=0;
    for(int i=1;(i*(i+1)*(i+2))/6 < 1e6;++i){
        v.push_back((i*(i+1)*(i+2))/6);
        m++;
    }
    while(cin>>n,n){
        vector<int>dp(1e6,1e9);
        vector<int>dp1(1e6,1e9);
        dp[0]=0;
        dp1[0]=0;
        for(int i=0;i<=n;++i){
            for(int j=0;j<m;++j){
                if(i+v[j]>=1e6){
                    m=j;
                    break;
                }
                dp[i+v[j]]=min(dp[i]+1,dp[i+v[j]]);
                if(v[j]%2==0)continue;
                dp1[i+v[j]]=min(dp1[i]+1,dp1[i+v[j]]);
            }
        }
        cout<<dp[n]<<" "<<dp1[n]<<endl;
    }
}

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

using namespace std;

int dp1[100010]={0};
int dp2[100010]={0};
int List[100];

void setpolloc(){
	int i,j,li;
	for(i=1;i*(i+1)*(i+2)/6<=100000;i++){
		List[i]=i*(i+1)*(i+2)/6;
		dp1[i*(i+1)*(i+2)/6]=1;
		if((i*(i+1)*(i+2)/6)%2) dp2[i*(i+1)*(i+2)/6]=1;
	}
	List[i]=i*(i+1)*(i+2)/6;
	for(i=1;i<=100000;i++){
		if(dp2[i]) continue;
		for(j=1;List[j]<=i-1;j+=2)if(!dp2[i] || dp2[List[j]]+dp2[i-List[j]] < dp2[i]) dp2[i]=dp2[List[j]]+dp2[i-List[j]];
		if(dp1[i]) continue;
		for(j=1;List[j]<=i-1;j++) if(!dp1[i] || dp1[List[j]]+dp1[i-List[j]] < dp1[i]) dp1[i]=dp1[List[j]]+dp1[i-List[j]];
	}
}


int main(){
	int n;
	setpolloc();
	while(cin>>n,n){
		cout << dp1[n] << ' ' << dp2[n] << endl;
	}
	return 0;
}