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 <vector>
#include <algorithm>
#include <climits>
#define V_MAX 10000
using namespace std;

int n;
vector<int> v(V_MAX);
int i=0,mx=0;
int p[200],size;
int vSize,dMAX;
int *dp1;
int *dp2;
int m,j;


int main(){
  while( cin>>n && n ){
    if( i<V_MAX ) v[i]=n;
    else          v.push_back(n);
    i++;
    mx=max(mx,n);
  }
  vSize=i;

  p[0]=0;
  for( size=1; ; size++ ){
    p[size]= size*(size+1)*(size+2)/6;
    if( p[size]>mx ) break;
  }


  dMAX = p[size-1] + 1;
  dp1 = new int[dMAX];
  dp2 = new int[dMAX];
  fill( dp1,dp1+dMAX,INT_MAX );
  fill( dp2,dp2+dMAX,INT_MAX );

  dp1[0]=0;
  for( i=1;i<size;i++){
    m=p[i];
    for( j=m;j<dMAX;j++ )
      dp1[j] = min( dp1[j],dp1[j-m]+1 );
  }

  dp2[0]=0;
  for( i=1;i<size;i++){
    if( p[i]%2==0 ) continue;
    m=p[i];
    for( j=m;j<dMAX;j++ )
      dp2[j] = min( dp2[j],dp2[j-m]+1 );
  }

  for( i=0;i<vSize;i++ )
    cout << dp1[ v[i] ] << " " << dp2[ v[i] ] << endl;

  return 0;
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

std::vector<int> num;

struct State {
  int num;
  int depth;
  State(int a, int b) {
    num   = a;
    depth = b;
  }
};

int Solve_all(int n) {
  bool visited[1000001] = {};
  std::queue<State> bfs;
  for (auto x : num) {
    if (x > n) break;
    bfs.push(State(x, 1));
    visited[x] = true;
  }
  while (!bfs.empty()) {
    State newstate = bfs.front();
    bfs.pop();
    if (newstate.num == n) {
      return newstate.depth;
    }
    for (auto x : num) {
      if (newstate.num + x > n) break;
      if (visited[newstate.num + x]) continue;
      bfs.push(State(newstate.num + x, newstate.depth + 1));
      visited[newstate.num + x] = true;
    }
  }
}

int Solve_odd(int n) {
  bool visited[1000001] = {};
  std::queue<State> bfs;
  for (auto x : num) {
    if (x % 2 == 0) continue;
    if (x > n) break;
    bfs.push(State(x, 1));
    visited[x] = true;
  }
  while (!bfs.empty()) {
    State newstate = bfs.front();
    bfs.pop();
    if (newstate.num == n) {
      return newstate.depth;
    }
    for (auto x : num) {
      if (x % 2 == 0) continue;
      if (newstate.num + x > n) break;
      if (visited[newstate.num + x]) continue;
      bfs.push(State(newstate.num + x, newstate.depth + 1));
      visited[newstate.num + x] = true;
    }
  }
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  for (int n = 1; n < 1000; n++) {
    int push = n * (n + 1) * (n + 2) / 6;
    if (n > 1000000) break;
    num.push_back(push);
  }

  while (1) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    cout << Solve_all(n) << " " << Solve_odd(n) << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<complex>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define NEXT(i,n) ((i+1)%(n))
const int N = 1000001;
int dp1[N],dp2[N];  
main(){
  vector<int> simen;
  REP(i,1,N+1){
    simen.push_back(i*(i+1)*(i+2)/6);
    if (simen[i-1] > N+1)break;
  }
  
  cout << simen.size() << endl;
  dp1[0]=0;
  dp2[0]=0;
  REP(i,1,N){
    dp1[i]=10000000;
    dp2[i]=10000000;
    rep(j,simen.size()){
      if (i-simen[j] < 0)break;
      dp1[i]=min(dp1[i],dp1[i-simen[j]]+1);
      if (simen[j]%2 == 1){
	dp2[i]=min(dp2[i],dp2[i-simen[j]]+1);
      }
    }
  }
  
  int n;
  while(cin>>n && n){
    cout << dp1[n] <<" " << dp2[n] << endl;
  }

}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

#define INF 1e9

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n;
  while(cin >> n && n){
    vector<int> dp_a(n+1, INF), dp_b(n+1, INF);
    dp_a[0] = 0, dp_b[0] = 0;
    for(int i = 0; i <= 200; i++){
      int tetra = i * (i+1) * (i+2) / 6;
      for(int j = tetra; j <= n; j++){
        dp_a[j] = min(dp_a[j], dp_a[j-tetra] + 1);
        if(tetra%2 != 0) dp_b[j] = min(dp_b[j], dp_b[j-tetra] + 1);
      }
    }
    cout << dp_a[n] << ' ' << dp_b[n] << endl;
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}

C++: #include<iostream>
using namespace std;
int main(){
  int num[201],log[1000001],logo[1000001];
  for(int i=1; i<200; i++){
    num[i] = i*(i+1)*(i+2)/6;
  }
  for(int i= 0; i<1000001; i++){
    log[i] = logo[i] = i;
    for(int j=1; j<201; j++){
      if(num[j]>i){break;}
      if(log[i]>log[i-num[j]]){log[i] = log[i-num[j]]+1;}
      if(num[j]%2){
	if(logo[i]>logo[i-num[j]]){logo[i] = logo[i-num[j]]+1;}
      }
    }
  }
  int n;
  while(cin >>n,n){
    cout <<log[n]<<" "<<logo[n]<<endl;
  }
  return 0;
}