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 <algorithm>
using namespace std;

#define MAX (1000000)
#define INF (1<<30)

int main() {
  
  int dp_all[MAX+2], dp_odd[MAX+2];
  
  fill(dp_all, dp_all+MAX+1, INF);
  fill(dp_odd, dp_odd+MAX+1, INF);
  
  dp_all[0] = dp_odd[0] = 0;
  
  for(int i=1; ; i++) {
    int num = i*(i+1)*(i+2) / 6;
    if(num > MAX) break;
    for(int j=num; j<=MAX; j++) {
      dp_all[j] = min(dp_all[j], dp_all[j-num]+1);
      if(num % 2)
	dp_odd[j] = min(dp_odd[j], dp_odd[j-num]+1);
    }
  }
  
  int n;
  while(cin >> n && n) {
    cout << dp_all[n] << " " << dp_odd[n] << endl;
  }
  
  return 0;
}

C++: #include<stdio.h>
#define N 1000000

int min(int a,int b){return (a>b)?b:a;}

int dp[N],dp_odd[N];

int main(){
  int i,j,n,tmp;
  int plc[1000],num;

  for(i=0;i<N;i++)dp[i] = dp_odd[i] = N+1;
  dp[0] = dp_odd[0] = 0;

  tmp = 1;
  for(num=1;;num++){
    plc[num] = tmp;
    tmp *= num+3; tmp /= num;
    if(tmp>=N)break;
  }
  
  for(i=0;i<N;i++){
    for(j=1;j<num;j++){
      if(i<plc[j])break;
      dp[i] = min(dp[i],dp[i-plc[j]]+1);
      if(plc[j]&1)dp_odd[i] = min(dp_odd[i],dp_odd[i-plc[j]]+1);
    }
  }

  //while(scanf("%d",&n) && n)printf("%d %d\n",dp[n],dp_odd[n]);
  while(scanf("%d",&n) && n)printf("%d %d\n",n,n);
}

C++: #include <iostream>
#include <cstring>

using namespace std;

const int INF = 1 << 30;
const int SIZE = 300;
const int N = 1000002;
int p[SIZE+1];
int dp1[N], dp2[N];

void make_pollock (void )
{
	for (int i = 0; i <= SIZE; i++ )
		p[i] = i*(i+1LL)*(i+2LL)/6LL;
}

void make_dp (void )
{
	dp1[0] = 0;
	for (int i = 1; i <= SIZE; i++ ){
		int m = p[i];
		for (int j = m; j <= N; j++ )
			dp1[j] = min (dp1[j], dp1[j-m]+1 );
	} // end for

	dp2[0] = 0;
	for (int i = 1; i <= SIZE; i++ ){
		if (p[i] % 2 == 0 ) continue;
		int m = p[i];
		for (int j = m; j <= N; j++ )
			dp2[j] = min (dp2[j], dp2[j-m]+1 );
	} // end for	
}
	
int main()
{
	memset (p, 0, sizeof (p ) );
	fill (dp1, dp1+N, INF );
	fill (dp2, dp2+N, INF );

	make_pollock();
	make_dp ();

	int n;
	while (cin >> n, n )
		cout << dp1[n] << ' ' << dp2[n] << endl;
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1000001];
int memo2[1000001];
 
int solve(int n){

  if(!n) return 0;
  if(memo[n]) return memo[n];
   
  int ans = INF;
  for(int i=1;p[i]<=n; i++) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(memo2[n]) return memo2[n];
   
  int ans = INF;
  for(int i=1;p[i]<=n;i++){
    if(p[i]&1) ans = min(ans, solve2(n-p[i])+1);
  }
   
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  for(int i=0;i<=181;i++) p[i] = i*(i+1)*(i+2)/6;
  //for(int i=1;i<=1000000;i++) solve(i), solve2(i);
   
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
}

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

using namespace std;

char ans1[1000001],ans2[1000001];

int main(){
    int t[181];
    
    for(int i = 1;i <= 180;++i)
        t[i] = i * (i + 1) * (i + 2) / 6;
    
    ans1[0] = ans2[0] = 0;
    
    for(int i = 1;i <= 1000000;++i){
        ans1[i] = 5;
        ans2[i] = 40;
    }
    
    for(int i = 1;i <= 180;++i)
        for(int j = i;j <= 180 && t[i] + t[j] <= 1000000;++j)
            for(int k = j;k <= 180 && t[i] + t[j] + t[k] <= 1000000;++k)
                ans1[ t[i] + t[j] + t[k] ] = 3;
    
    for(int i = 1;i <= 180;++i)
        for(int j = i;j <= 180 && t[i] + t[j] <= 1000000;++j)
            ans1[ t[i] + t[j] ] = 2;
    
    for(int i = 1;i <= 180;++i)
        ans1[ t[i] ] = 1;
    
    for(int i = 1;i <= 1000000;++i){
        if(ans1[i] == 3){
            for(int j = 1;j <= 180 && i + t[j] <= 1000000;++j)
                if(ans1[i + t[j]] == 5) ans1[i + t[j]] = 4;
        }
    }
    
    for(int i = 1;i <= 180;++i){
        int x = t[i];
        
        if(x & 1)
            for(int j = x;j <= 1000000;++j)
                if(1 + ans2[j - x] < ans2[j]) ans2[j] = 1 + ans2[j - x];
    }
    
    int n;
    
    while(true){
        scanf("%d",&n);
        
        if(n == 0) break;
        
        printf("%d %d\n",ans1[n],ans2[n]);
    }
    
    return 0;
}

C++: ///
// File:  1167.cpp
// Author: ymiyamoto
//
// Created on Sat Dec  2 18:27:58 2017
//

#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

uint32_t polloc(uint32_t n)
{
  return n * (n + 1) * (n + 2) / 6;
}

static array<int32_t, 1000001> dp;
static array<int32_t, 1000001> odddp;

int32_t main()
{
  for (uint32_t i = 0; i < dp.size(); i++) {
    dp[i] = odddp[i] = i;
  }

  vector<int64_t> pollocs;
  for (uint32_t i = 0; i <= 85; i++) {
    pollocs.push_back(polloc(i));
  }

  for (int64_t i = 0; i < (int64_t)dp.size(); i++) {
    for (int64_t j = 0; j < (int64_t)pollocs.size(); j++) {
      if (i - pollocs[j] >= 0) {
        dp[i] = min(dp[i], dp[i - pollocs[j]] + 1);
        if (pollocs[j] % 2 == 1) {
          odddp[i] = min(odddp[i], odddp[i - pollocs[j]] + 1);
        }
      }
    }
  }

  while (true) {
    uint32_t n;
    cin >> n;
    if (n == 0) break;
    cout << dp[n] << " " << odddp[n] << endl;
  }

  return 0;
}