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 <stdio.h>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<ll> v(1e6,10);
  vector<ll> seisi;
  ll a=0;
  seisi.push_back(a);
  a++;
  while(a<200){
    seisi.push_back(a+seisi[a-1]);
    a++;
  }
  FOR(i,1,seisi.size()){
    seisi[i]+=seisi[i-1];
  }
  //coutv(seisi,0,100);
  vector<ll> dp1(1e6,10);
  vector<ll> dp2(1e6,1e6);
  dp1[0]=0;
  dp2[0]=0;
  dp2[1]=1;
  FOR(i,1,seisi.size()){
    FOR(j,seisi[i],1e6){
      dp1[j]=min(dp1[j-seisi[i]]+1,dp1[j]);
      if(seisi[i]%2==1)dp2[j]=min(dp2[j],dp2[j-seisi[i]]+1);
    }
  }
  while(true){
    ll n;
    cin>>n;
    if(n==0)break;
    cout<<dp1[n]<<" "<<dp2[n]<<endl;
  }
}

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

int dpt1[1000001];
int dpt2[1000001];
bool dpb1[1000001];
bool dpb2[1000001];
int tr[1000];
int sq[1000];

int dp1(int s) {
  if(dpb1[s])
    return dpt1[s];

  int m = 1000111000;
  int r;
  for(int i=1; i < 1000; i++) {
    if(s-sq[i] < 0) break;
    r = dp1(s-sq[i]);
    if(r < m) m = r;
  }

  dpt1[s] = m + 1;
  dpb1[s] = true;
  return m + 1;
}

int dp2(int s) {
  if(dpb2[s])
    return dpt2[s];

  int m = 1000111000;
  int r;
  for(int i=1; i < 1000; i++) {
    if(s-sq[i] < 0) break;
    if(sq[i]%2 == 0)
      continue;
    r = dp2(s-sq[i]);
    if(r < m) m = r;
  }

  dpt2[s] = m + 1;
  dpb2[s] = true;
  return m + 1;
}

int main() {

  for(int i=1; i < 1000; i++) {
    tr[i] = tr[i-1] + i;
    sq[i] = sq[i-1] + tr[i];
  }
  dpt1[0] = 0;
  dpb1[0] = true;
  dpt2[0] = 0;
  dpb2[0] = true;
  int n;
  while(cin >> n, n) {
    cout << dp1(n) << " " << dp2(n) << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n;
  int res[200] = {};
  res[1] = 1;
  rep(i,2,200){
    res[i] = (res[i-1]*(i+2))/(i-1);
    //cout << i  << "  " << res[i] << endl;
  }
  
  //cout << (180/120*179*178*177*176)/(3*2*1) << endl;
  int dp[2000000] = {};
  int dps[2000000] = {};
  REP(i,1e6+1){
    dp[i] = 100;
    dps[i] = 10000000;
  }
  rep(i,1,181){
    dp[res[i]] = 1;
    if(res[i]%2 == 1){
      dps[res[i]] = 1;
    }
  }
  //cout << dps[5] << endl;
  REP(i,1e6+1){
    for(int j = 1;j < 181;j++){
      if(dp[i] != 0){
	dp[i+res[j]] = min(dp[i+res[j]],dp[i]+1);
	
      }
      if(dps[i] != 0){
	if(res[j]%2 == 1)
	  dps[i+res[j]] = min(dps[i+res[j]], dps[i]+1);
	
      }
      
    }
    
  }
  while(cin >> n, n){

    cout << dp[n] << " " << dps[n] << endl; 

  }
  return 0;
}

C++: #include <iostream>

using namespace std;

void append(int t, int n, int table[]) {
    table[t] = 1;
    for (int i=0; i<=n-t; i++) {
        if (table[i] < 0) {
            continue;
        }
        if (table[i+t] < 0) {
            table[i+t] = table[i]+1;
        }
        else {
            table[i+t] = min(table[i]+1, table[i+t]);
        }
    }
}

int main() {
    int n;
    int dp[1000000];
    int dp_odd[1000000];
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i=0; i<=n; i++) {
            dp[i] = -1;
            dp_odd[i] = -1;
        }
        for (int i=0; true; i++) {
            int t = i*(i+1)*(i+2)/6;
            if (t > n) {
                break;
            }
            append(t, n, dp);
            if (t%2 == 1) {
                append(t, n, dp_odd);
            }
        }
        cout << dp[n] << ' ' << dp_odd[n] << endl;
    }
}