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>

using namespace std;

int p(int i){
  return i * (i + 1) * (i + 2) / 6;
}

int main(void){
  int n = 1000000;
  /* ???????¨??????? */
  int ans1[n+1];
  int ans2[n+1];
  for(int i = 1 ; i < n + 1 ; i++){
    ans1[i+1] = -1;
    ans2[i+1] = -1;
  }

  for(int i = 1 ; p(i) < n + 1 ; i++){
    ans1[p(i)] = 1;
    if(p(i) % 2 == 1){ ans2[p(i)] = 1; }
  }

  for(int i = 2 ; i <= n ; i++){
    if(ans1[i] == 1){
    }else{
      int min = 10000;
      for(int j = 1 ; p(j) < i ; j++){
        if(min > 2 && ans1[i - p(j)] + 1 < min){
          min = ans1[i - p(j)] + 1;
        }
      }
      ans1[i] = min;
    }
  }

  for(int i = 2 ; i <= n ; i++){
    if(ans2[i] == 1){
    }else{
      int min = 10000;
      for(int j = 1 ; p(j) < i ; j++){
        if(min > 2 && p(j) % 2 == 1 && ans2[i - p(j)] + 1 < min){
          min = ans2[i - p(j)] + 1;
        }
      }
      ans2[i] = min;
    }
  }

  while(1){
    cin >> n;
    if(n == 0){return 0;}
    cout << ans1[n] << " " << ans2[n] << endl;
  }
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i, a) for(i = 0; i < (a); i++)
#define FORM(i, a) for(i = (a) i >= 0; i--)
#define INF 100000
using namespace std;
int c[1000], odd[1000];
int mini[200];

int main(){
int i, j, W, minimum, l;
 

   for(i = 1; i <= 200; i++){
	   c[i] = (i*(i+1)*(i+2))/6;
   }
   j = 1;
   for(i = 1; i <= 200; i++){
	   if(c[i] % 2 == 1){
		   odd[j] = c[i];
		   j += 1;
	   }
   }


   cin >> W;

   while(W != 0){
	   minimum = 10000000;
	   for(i = 1; i <= 200; i++){
		   l = W;
		   if(c[i] > W){
			   break;
		   }
		 for(j = i; j > 0; j--){
			 mini[i] += l / c[j];
			 l %= c[j];
			
		 }

		  minimum = min(minimum, mini[i]);
	   }

	   cout << minimum << " ";
	   minimum = 100000000;
	   FOR(i, 200){
		   mini[i] = 0;
	   }
	      for(i = 1; i <= 200; i++){
			  l = W;
		   if(odd[i] > W){
			   break;
		   }
		 for(j = i; j > 0; j--){
			 mini[i] += l/odd[j];
			 l %= odd[j];
			
		 }

		  minimum = min(minimum, mini[i]);
	   }
		  
     cout << minimum << endl;
	   FOR(i, 200){
		   mini[i] = 0;
	   }
       
	   cin >> W;

   }
   

return 0;
}

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

typedef long long ll;

#define arrsize 500000

ll memo[arrsize];
ll memo2[arrsize];

ll calc(int n) {
  return n * (n + 1) * (n + 2) / 6;
}

int dfs(int depth, int n) {
  int ans = 9999;
  if (n < arrsize && memo[n] != 0) return memo[n];
  for (int i = sqrt(n); i >= 1; i--) {
    
    ll t = calc(i);
    if (n - t < 0) continue;
    if (n - t == 0) {
      if (n < arrsize) {
	memo[n] = depth;
      }
      return depth;
    }
    ans = min(ans, dfs(depth + 1, n - t));
  }
  if (n < arrsize)
    memo[n] = ans;
  return ans;
}

int dfs_odd(int depth, int n) {
  int ans = 9999;
  if (n < arrsize && memo2[n] != 0) return memo2[n];
  for (int i = sqrt(n); i >= 1; i--) {
    if (i % 2 == 0) continue;
    ll t = calc(i);
    if (t % 2 == 0) continue;
    if (n - t < 0) continue;
    if (n - t == 0) {
      if (n < arrsize)
	memo2[n] = depth;
      return depth;
    }
    ans = min(ans, dfs_odd(depth + 1, n - t));
  }
  if (n < arrsize)
    memo2[n] = ans;
  return ans;
}
  
int main() {
  int N;
  while (cin >> N, N != 0) {
    for (int i = 0; i < arrsize; i++) {
      memo[i] = 0;
      memo2[i] = 0;
   }
    cout << dfs(1, N) << " " << dfs_odd(1, N) << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int a[1000010],b[1000010];
int main(){
	a[0]=0;b[0]=0;
	for(int i=1;i<=1000010;i++){
		a[i]=i;b[i]=i;
		int j=1;
		while(j++){
			int p=j*(j+1)*(j+2)/6;
			if(i<p)break;
			a[i]=min(a[i],a[i-p]+1);
			if(p%2)b[i]=min(b[i],b[i-p]+1);
		}
	}
	int n;
	while(cin>>n,n){
		cout<<a[n]<<" "<<b[n]<<endl;
	}
	return 0;
}

C++: // AOJ 1167
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef long long int number;

const number NMAX = 10e6 + 8;

int dp[NMAX], odp[NMAX];

int main() {
  REP(i, NMAX) {
    dp[i] = odp[i] = i;
  }
  for (number i = 2; i * (i + 1) * (i + 2) / 6 < NMAX; i++) {
    int tetr = i * (i + 1) * (i + 2) / 6;
    int limit = min(NMAX, (i + 1) * (i + 2) * (i + 3) / 6 + 8);
    for (number j = tetr; j < limit; j++) {
      dp[j] = min(dp[j], dp[j - tetr] + 1);
    }

    if (tetr % 2 != 0) {
      int limit = min(NMAX, (i + 4) * (i + 5) * (i + 6) / 6 + 8);
      for (number j = tetr; j < limit; j++) {
        odp[j] = min(odp[j], odp[j -tetr] + 1);
      }
    }
  }

  int n;
  while (cin >> n and n) {
    cout << dp[n] << " " << odp[n] << endl;
  }
}