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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;


int main(){
    int C=1e6;
    vector<int> p;
    while(true){
        int x;cin>>x;
        if(!x)break;
        p.push_back(x);
    }
    int n=p.size();
    vector<int> bnum;
    for(int i=1;;++i){
        int x=i*(i+1)*(i+2)/6;
        if(x>=C)break;
        bnum.push_back(x);
    }
    int m=bnum.size();
    int dp[C+1];rep(i,C+1)dp[i]=mod;
    dp[0]=0;
    rep(i,C){
        rep(j,m){
            if(bnum[j]>i+1)break;
            chmin(dp[i+1],dp[i+1-bnum[j]]+1);
        }
    }
    vector<int> onum;
    rep(i,m){
        if(bnum[i]%2)onum.push_back(bnum[i]);
    }
    m=onum.size();
    int odd[C+1];rep(i,C+1)odd[i]=mod;
    odd[0]=0;
    rep(i,C){
        rep(j,m){
            if(onum[j]>i+1)break;
            chmin(odd[i+1],odd[i+1-onum[j]]+1);
        }
    }
    rep(i,n){
        cout<<dp[p[i]]<<" "<<odd[p[i]]<<endl;
    }
}

C++: #include <iostream> 
#include<vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
typedef long long int ll;
const ll INF = (1 << 29);
ll h, m, n; string s;
const int Max = 1000100;
int main() {
    vector<int> dp(Max, INF), odp(Max, INF);
    dp[0] = odp[0] = 0;
    req(i, 175) {
        ll num = i * (i + 1) * (i + 2) / 6;
        if (num >= Max) break;
        for (int j = num; j < Max; j++) {
            dp[j] = min(dp[j], dp[j - num] + 1);
            if (num & 1) odp[j] = min(odp[j], odp[j - num] + 1);
        }
    }while (cin >> n, n) {
        cout << dp[n] << " " << odp[n] << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

vector<ll> table, table2;

ll dp[2][2][1001000];

int main() {
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= 1000000; i++) {
		table.push_back(i*(i + 1)*(i + 2) / 6);
		if ((i*(i + 1)*(i + 2) / 6) % 2 == 1)table2.push_back(i*(i + 1)*(i + 2) / 6);
	}
	cout << table.size() << endl;
	REP(i, 2) {
		REP(j, 2) {
			REP(k, 1001000)dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0;
	dp[1][0][0] = 0;

	REP(i, table.size()) {
		int num = table[i];
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[0][(i + 1) % 2][j] = min(dp[0][(i + 1) % 2][j - num] + 1, dp[0][i % 2][j]);
			}
			else dp[0][(i + 1) % 2][j] = dp[0][i % 2][j];
		}
	}

	for (int i = 0; i < table2.size(); i++) {
		int num = table2[i];
		//cout << num << endl;
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[1][(i + 1) % 2][j] = min(dp[1][(i + 1) % 2][j - num] + 1, dp[1][i % 2][j]);
			}
			else dp[1][(i + 1) % 2][j] = dp[1][i % 2][j];
		}
	}
	
	while (cin >> n&&n) {
		cout << dp[0][table.size() % 2][n] << " "
			<< dp[1][table2.size() % 2][n] << endl;
	}
}

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

int func(int m, int p, vector<int> &q){
	if(p == -1) return 0;
	int d = m / q[p];
	return d + func(m - d * q[p], p-1, q);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a, b;
	for(int i=1; i*(i+1)*(i+2)/6<1e6; ++i){
		int t = i*(i+1)*(i+2)/6;
		a.push_back(t);
		if(t % 2 == 1) b.push_back(t);
	}
//	for(int i=0; i<a.size(); ++i)
//		cout << a[i] << "\n";
//	cout << a.size() << "\n";
//	cout << b.size() << "\n";
//	for(int i=0; i<b.size(); ++i)
//		cout << b[i] << "\n";
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		int x = n, y = n;
		for(int i=0; a[i]<=n; ++i)
			x = min(x, func(n, i, a));
		for(int i=0; b[i]<=n; ++i)
			y = min(y, func(n, i, b));
		cout << x << " " << y << "\n";
	}
}