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 <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) {rep(j, m) {cout<<a[i][j]<<' ';} cout<<endl;}

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
//const int INF = 10000;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 1000000;

int main() {
//	cout << fixed << setprecision(15);
	vi v[2];
	int n = 1, m;
	while(true) {
		m = n * (n + 1) * (n + 2) / 6;
		if(m > N) break;
		v[0].push_back(m);
		if(m % 2 == 1) v[1].push_back(m);
		n++;
	}

	vi in;
	while(true) {
		int n;
		cin >> n;
		if(n == 0) break;
		in.push_back(n);
	}

	vi dp(N+1), ans[2];
	rep(i, 2) {
		fill(dp.begin(), dp.end(), INF);
		dp[0] = 0;
		for(int j = 0; j < v[i].size(); j++) {
			for(int k = v[i][j]; k <= N; k++) {
				dp[k] = min(dp[k - v[i][j]] + 1, dp[k]);
			}
		}
		for(auto j : in) ans[i].push_back(dp[j]);
	}
	rep(i, in.size()) cout << ans[0][i] << ' ' << ans[1][i] << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll cnt = 2;
    ll sum = 1;
    vector<ll> suzu;
    suzu.push_back(1);
    while(suzu.back() <= 1000000){
        sum += cnt;
        int now = suzu.back() + sum;
        suzu.push_back(now);
        cnt++;
    }
    reverse(suzu.begin(),suzu.end());
    int N;
    int M = suzu.size();
    vector<ll> dp(1000100,inf);
    vector<ll> dp_odd(1000100,inf);
    dp[0] = 0;
    dp_odd[0] = 0;
    for(int i=0; i<M; i++){
        for(int j=0; j<=1000000; j++){
            if(j+suzu[i]<=1000000){
                chmin(dp[j+suzu[i]],dp[j]+1);
                if(suzu[i]%2){
                    chmin(dp_odd[j+suzu[i]],dp_odd[j]+1);
                }
            }
        }
    }
    while(cin >> N){
        if(N == 0) break;
        cout << dp[N] << " " << dp_odd[N] << enld;
    }
    return 0;
}

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

const int MAX = 1e6+5;
int dp1[MAX];
int dp2[MAX];

void init(int n){
    int INF = 1e9;
    for(int j=0;j<=n;j++){
        dp1[j] = INF;
        dp2[j] = INF;
    }
    dp1[0] = 0;
    dp2[0] = 0;
}

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    vector<int> a;
    vector<int> b;
    for(int i=1;i<100000;i++){
        int ret = i*(i+1)*(i+2)/6;
        if(ret > 1e6) break;
        a.push_back(ret);
        if(ret %2 == 1) b.push_back(ret);

    }
    init(1e6);
    for(int i=0;i<180;i++){
        if(a[i] > 1e6) break;
        for(int j=0;j<=1e6;j++){
            int p = j+a[i];
            if(p > 1e6) break;
            dp1[p] = min(dp1[p], dp1[j]+1);
        }
    }
    for(int i=0;i<b.size();i++){
        if(b[i] > 1e6) break;
        for(int j=0;j<=1e6;j++){
            int p = j+b[i];
            if(p > 1e6) break;
            dp2[p] = min(dp2[p], dp2[j]+1);
        }
    }





    int n;
    while(cin>>n){
        if(n==0) break;
        cout << dp1[n] << " ";
        cout << dp2[n] << "\n";
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[190]={0},b[50]={0},c[1000001]={0,1,2,3},d[10001],k=0,i,j,n;

  for(i=1;i<191;i++)a[k++]=i*(i+1)*(i+2)/6;

  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];

  for(i=1;i<189;i++)for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;

  for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-1;i++)for(j=b[i];j<b[i+1];j++)d[j]=c[j-b[i]]+1;

  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}