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 <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

#define TEST 0
#if TEST
FILE* in = freopen("./Q.txt", "r", stdin);
FILE* out = freopen("./A.txt", "w",stdout);
#endif

#define MAXN 300
#define MAXINPUT 1000001

vector<int> seq;
int normalAns[MAXINPUT];
int oddAns[MAXINPUT];

int main(int argc, const char * argv[]) {
    for(int i = 0; i < MAXN; i++){
        seq.push_back(i*(i + 1)*(i + 2)/6);
    }
    
    for(int i = 0; i < MAXINPUT; i++){
        normalAns[i] = oddAns[i] = i;
        for(int j = 0; i - seq[j] >= 0; j++){
            normalAns[i] = min(normalAns[i], normalAns[i-seq[j]] + 1);
            if(seq[j]&1) oddAns[i] = min(oddAns[i], oddAns[i-seq[j]] + 1);
        }
    }
    
    while(1){
        int n; cin >> n;
        if(!n) break;
        
        cout << normalAns[n] << " " << oddAns[n] << endl;
    }
    
#if TEST
    fclose(in);
    fclose(out);
#endif
}

C++: #include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int dp[1000005];
int dp2[1000005];
int pl[180];

int main() {
	//init
	for (int i = 1; i<=180; i++)pl[i-1] = (i*(i + 1)*(i + 2)) / 6;
	memset(dp, 0x7f, sizeof(dp));
	memset(dp2, 0x7f, sizeof(dp2));
	dp[0] = 0;
	dp2[0] = 0;
	for (int i = 0; i < 1000000; i++) {
		for (int j = 0; j < 180; j++) {
			if(i+pl[j] <= 1000000)dp[i + pl[j]] = min(dp[i] + 1, dp[i + pl[j]]);
			if (i + pl[j] <= 1000000 && pl[j]&1)dp2[i + pl[j]] = min(dp2[i] + 1, dp2[i + pl[j]]);
		}
	}
	while (1) {
		int n;
		scanf("%d", &n);
		if (n == 0)break;
		printf("%d %d\n", dp[n], dp2[n]);
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#define INF 1000001

int main(void){
	int i, j, n ,c, small1, small2;
	int dp1[1000000],dp2[1000000];
	scanf("%d",&n);
	while(n != 0){
		for(i = 0;i <= n;i++)
			dp1[i] = dp2[i] = INF;
		dp1[0] = dp2[0] = 0;
		for(i = 0;i < n;i++){
			small1 = dp1[n]; small2 = dp2[n];
			if(small1 > dp1[i] && dp1[i] != INF ||small2 > dp2[i] && dp2[i] != INF){
				for(j = 1,c = j * (j + 1) * (j + 2);c / 6 + i <= n;j++,c = j * (j + 1) * (j + 2)){
					if(dp1[c / 6 + i] > dp1[i] + 1 && dp1[i] != INF)
						dp1[c / 6 + i] = dp1[i] + 1;
					if(dp2[c / 6 + i] > dp2[i] + 1 && (c / 6) % 2 == 1 && dp2[i] != INF)
						dp2[c / 6 + i] = dp2[i] + 1;
				}
			}
		}
		printf("%d %d\n",dp1[n],dp2[n]);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define INF (int)(1e9)
using namespace std;

int sankaku[111];
int simen[111];
int simen2[111];
int maxi,maxj;
int dp[111111];
int dp2[111111];
void solve(){
  int i,j,t;
  int n=111111;
  for(i=0;i<n;i++){
    dp[i]=dp2[i]=INF;
  }
  dp[0]=dp2[0]=0;
  for(i=0;i<=maxj;i++){
    t=simen[i];
    for(j=t;j<=n;j++){
      dp[j]=min(dp[j],dp[j-t]+1);
    }
  }

  for(i=0;i<=maxi;i++){
    t=simen2[i];
    for(j=t;j<=n;j++){
      dp2[j]=min(dp2[j],dp2[j-t]+1);
    }
  }


}


int main(void){
  int n,i,j,t;
  t=i=j=1;
  sankaku[0]=1;
  simen[0]=1;
  simen2[0]=1;
  while(simen[j-1]<111111){
    sankaku[j]=sankaku[j-1]+j+1;
    simen[j]=simen[j-1]+sankaku[j];
    t=simen[j++];
    if(t%2==1) simen2[i++]=t;
  }
  maxi=i;
  maxj=j;
  solve();
  while(scanf("%d",&n),n){
    cout<<dp[n]<<" "<<dp2[n]<<endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
    set<int> se;
    for(int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000100; ++i) {
        se.insert(i * (i + 1) * (i + 2) / 6);
    }
    int dp[1000100], dp1[1000100];
    rep(i, 1000100) dp[i] = dp1[i] = INF;
    dp[0] = dp1[0] = 0;
    for(auto& x: se) {
        rep(i, 1000100) {
            if(i + x < 1000100) chmin(dp[i + x], dp[i] + 1);
            if(i + x < 1000100 && x % 2 == 1) chmin(dp1[i + x], dp1[i] + 1);
        }
    }
	int n;
    while(cin >> n) {
        if(n == 0) break;
        cout << dp[n] << " " << dp1[n] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}