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<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

int dp[10000001];
int dp2[10000001];

int func(int v){
	if(dp[v]!=11451419)return dp[v];
	if(v==0)return 0;
	int cnt=11451419;
	for(int i=1;i*(i+1)*(i+2)/6<=1000000;i++){
		if(v-i*(i+1)*(i+2)/6>=0)cnt=min(cnt,func(v-i*(i+1)*(i+2)/6));
	}
	return (dp[v]=cnt+1);
}

int func2(int v){
	if(dp2[v]!=11451419)return dp2[v];
	if(v==0)return 0;
	int cnt=11451419;
	for(int i=1;i*(i+1)*(i+2)/6<=1000000;i++){
		if(i*(i+1)*(i+2)/6%2!=1)continue;
		if(v-i*(i+1)*(i+2)/6>=0)cnt=min(cnt,func2(v-i*(i+1)*(i+2)/6));
	}
	return dp2[v]=cnt+1;
}

int main(void){
	int n;
	for(int i=1;i<=1000000;i++)dp[i]=dp2[i]=11451419;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		printf("%d %d\n",func(n),func2(n));
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
int main(void){
  std::vector<int>lis = {1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495, 4960, 5456, 5984, 6545, 7140, 7770, 8436, 9139, 9880, 10660, 11480, 12341, 13244, 14190, 15180, 16215, 17296, 18424, 19600, 20825, 22100, 23426, 24804, 26235, 27720, 29260, 30856, 32509, 34220, 35990, 37820, 39711, 41664, 43680, 45760, 47905, 50116, 52394, 54740, 57155, 59640, 62196, 64824, 67525, 70300, 73150, 76076, 79079, 82160, 85320, 88560, 91881, 95284, 98770, 102340, 105995, 109736, 113564, 117480, 121485, 125580, 129766, 134044, 138415, 142880, 147440, 152096, 156849, 161700, 166650, 171700, 176851, 182104, 187460, 192920, 198485, 204156, 209934, 215820, 221815, 227920, 234136, 240464, 246905, 253460, 260130, 266916, 273819, 280840, 287980, 295240, 302621, 310124, 317750, 325500, 333375, 341376, 349504, 357760, 366145, 374660, 383306, 392084, 400995, 410040, 419220, 428536, 437989, 447580, 457310, 467180, 477191, 487344, 497640, 508080, 518665, 529396, 540274, 551300, 562475, 573800, 585276, 596904, 608685, 620620, 632710, 644956, 657359, 669920, 682640, 695520, 708561, 721764, 735130, 748660, 762355, 776216, 790244, 804440, 818805, 833340, 848046, 862924, 877975, 893200, 908600, 924176, 939929, 955860, 971970};
  std::vector<int>lis_1 = {1, 35, 165, 455, 969, 1771, 2925, 4495, 6545, 9139, 12341, 16215, 20825, 26235, 32509, 39711, 47905, 57155, 67525, 79079, 91881, 105995, 121485, 138415, 156849, 176851, 198485, 221815, 246905, 273819, 302621, 333375, 366145, 400995, 437989, 477191, 518665, 562475, 608685, 657359, 708561, 762355, 818805, 877975, 939929};
  std::vector<int>dp(1000001);
  std::vector<int>dp_1(1000001);
  for (int i = 0; i < 1000001; i++){
    dp[i] = 1000;
    dp_1[i] = 1000;
  }
  dp[0] = 0;
  dp_1[0] = 0;
  for (int i = 0; i < 1000001; i++){
    for (int j = 0; j < lis.size(); j++){
      if (i+lis[j] <= 1000000){
        dp[i+lis[j]] = std::min(dp[i]+1, dp[i+lis[j]]);
      }
    }
  }
  for (int i = 0; i < 1000001; i++){
    for (int j = 0; j < lis_1.size(); j++){
      if (i+lis_1[j] <= 1000000){
        dp_1[i+lis_1[j]] = std::min(dp_1[i]+1, dp_1[i+lis_1[j]]);
      }
    }
  }

  while (1){
    int n;
    std::cin >> n;
    if (n == 0) break;
    std::cout << dp[n] << " " << dp_1[n] << std::endl;
  }
  return 0;
}

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 <iomanip>
#include <vector>
using namespace std;

const int inf = 1000000009;

int main() {
    vector<vector<int>> memo(85, vector<int>(1000000, inf));
    vector<vector<int>> odd_memo(85, vector<int>(1000000, inf));
    for (int i=0; i<1000000; i++) {
        memo[0][i] = 0;
        odd_memo[0][i] = 0;
    }

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

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

            if (l%2==1) {
                if(i-n == 0) {
                    odd_memo[l][i] = 1;
                } else if(i-n > 0) {
                    odd_memo[l][i] = min(odd_memo[l][i-n]+1, odd_memo[l-1][i]);
                } else {
                    odd_memo[l][i] = odd_memo[l-1][i];
                }
            } else {
                odd_memo[l][i] = odd_memo[l-1][i];
            }
        }
    }

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