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;

int	main()
{
	vector<int>	q_vec;
	int	q, max_q = 0;
	while (cin >> q) {
		if (q == 0) break;
		if (max_q < q)
			max_q = q;
		q_vec.push_back(q);
	}
	vector<int>	cost(max_q + 1, -1);
	vector<int>	odd_cost(max_q + 1, -1);
	cost[0] = 0;
	odd_cost[0] = 0;
	int	num;
	for (int i = 1; (num = i * (i + 1) * (i + 2) / 6) <= max_q; ++i) {
		for (int j = 0; j <= max_q; ++j) {
			if (cost[j] == -1) continue;
			int	k = j + num;
			if (k > max_q) continue;
			int	cost_k = cost[j] + 1;
			if (cost[k] == -1 || cost[k] > cost_k)
				cost[k] = cost_k;
		}
		if (num % 2 == 0) continue;
		for (int j = 0; j <= max_q; ++j) {
			if (odd_cost[j] == -1) continue;
			int	k = j + num;
			if (k > max_q) continue;
			int odd_cost_k = odd_cost[j] + 1;
			if (odd_cost[k] == -1 || odd_cost[k] > odd_cost_k)
				odd_cost[k] = odd_cost_k;
		}
	}
	for (int q : q_vec) {
		cout << cost[q] << " " << odd_cost[q] << endl;
	}
}

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

const int inf = 1000000009;

int main() {
    vector<int> memo(1000000, inf);     memo[0] = 0;
    vector<int> odd_memo(1000000, inf); odd_memo[0] = 0;

    for (int i=0; i<1000000; i++) {
        memo[i]     = i;
        odd_memo[i] = i;
    }

    for (int l=2; l<200; l++) {
        const int n = (l*(l+1)*(l+2))/6;
        for (int i=0; i<1000000; i++) {
            if (i-n >= 0) {
                memo[i] = min(memo[i-n]+1, memo[i]);
                if (n%2==1) {
                    odd_memo[i] = min(odd_memo[i-n]+1, odd_memo[i]);
                }
            }
        }
    }

    int n; 
    while (cin >> n, n!=0) {
        cout << memo[n] << " " << odd_memo[n] << endl;
    }
}

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

int main(){
    int N;
    int tri[200];
    static int ansA[1000000], ansB[1000000];
    /* ??£?????¢?????°?¨???? */
    for(int i=0;i<200;i++) tri[i] = i*(i+1)*(i+2)/6;
    
    /* ??????1,000,000?????§?????????????¨???????????????? */
    ansA[0] = ansB[0] = 0;
    for(int i=1;i<1000000;i++){
        ansA[i] = ansB[i] = i;  /* ????????????i???????????? */
        for(int j=1;i-tri[j]>=0;j++){
            /* ???????¨?????????§???????????£?????¢????????°????????????????¢???????????????? */
            ansA[i] = min(ansA[i], ansA[i-tri[j]]+1);
            /* ?\???°???????????´??? */
            if(tri[j]%2==1)
                ansB[i] = min(ansB[i], ansB[i-tri[j]]+1);
        }
    }
    
    /* input?????????????????????????????? */
    while(cin >> N, N)
        cout << ansA[N] << " " << ansB[N] << endl;
}

C++: #include<iostream>

using namespace std;
#define MAX 1000000
#define INF 1000000000

int dp1[MAX+1],dp2[MAX+2];

int main(){
    for(int i = 1;i <= MAX;i++){
        dp1[i] = INF;
        dp2[i] = INF;
    }

    for(int n = 1;n * (n + 1) * (n + 2) / 6 <= MAX;n++){
        int a = n * (n + 1) * (n + 2) / 6;
        for(int i = a;i <= MAX;i++){
            dp1[i] = min(dp1[i],dp1[i - a] + 1);
        }
        if(a % 2 == 0)continue;
        for(int i = a;i <= MAX;i++){
            dp2[i] = min(dp2[i],dp2[i - a] + 1);
        }
    }

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

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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)


const int MAX = 1000000;

int dp[MAX + 1];
int dp2[MAX + 1];

void solve(int n)
{
  vector<int> v;
  for(int i = 0; ; i++){
    int t = i * (i + 1) * (i + 2) / 6;
    if(t <= MAX)
      v.push_back(t);
    else
      break;
  }
  for(int i = 1; v[i] <= n; i++){
    if(v[i] & 1)
      dp2[v[i]] = 1;
    dp[v[i]] = 1;
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; i + v[j] <= n; j++){
      if(v[j] & 1)
        dp2[i + v[j]] = min(dp2[i + v[j]], dp2[i] + 1);
      dp[i + v[j]] = min(dp[i + v[j]], dp[i] + 1);
    }
  }
}


    
int main()
{
  int n;
  while(1){
    cin >> n;
    if(n == 0){
      break;
    }else{
      fill(dp, dp + n + 1, MAX);
      fill(dp2, dp2 + n + 1, MAX);
      solve(n);
      cout << dp[n] << " " << dp2[n] << endl;
    }
  }
}

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

int d[182] = {} ;
int D[182] = {} ; // 10^6 越え → 181
int dp_map[2][1000002] = {} ;

void t(){
	for( int i=1 ; i<182 ; i++ ){
		d[i] = d[i-1] + i ;
		D[i] = D[i-1] + d[i] ;
	}
}

int cal_2( int x , int c ){
	if( x==0 ) return 0 ;
	else return x/D[c] + cal_2( x%D[c] , c-1 ) ;
}

int cal( int m , int q ){
	int ans = m ;
	for( int j=q ; j>1 ; j-- ){
		ans = min( ans , cal_2( m , j ) ) ;
	}
	return ans ;
}

int cal_odd( int x , int c ){
	if( x==0 ) return 0 ;
	else{
		if( D[c]%2 == 0 ) return cal_odd( x , c-1 ) ;
		else return x/D[c] + cal_odd( x%D[c] , c-1 ) ;
	}
}

void dp(){
	int p = 1 ;
	
	for( int i=1 ; i<=1000000 ; i++ ){
		if( i < 182 && i >= D[p] ) p++ ;
		dp_map[0][i] = cal(i,p) ;
		dp_map[1][i] = cal_odd(i,p) ;
	}
}

int main(){
	
	t() ;
	dp() ;
	
	int n ;
	
	while( cin >> n , n ){
		cout << dp_map[0][n] << ' ' ;
		cout << dp_map[1][n] << endl ;
	}
	
return 0 ;
}