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<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 1000005;
const int MOD = 1000000007;

ll dp[2][MAX];
// dp[i][j] は i番目までで jを作れる時の必要最小個数
ll odp[2][MAX];

int main(){
  vector<ll> a;
  while(1){
    ll c; cin >> c;
    if(c == 0) break;
    else a.pb(c);
  }
  // dp table初期化
  rep(i,2) rep(j,MAX) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,2) rep(j,MAX) odp[i][j] = INF;
  odp[0][0] = 0;
  // dp 作成
  repn(i,200){
    ll num = i * (i + 1) * (i + 2) / 6;
    if(num > MAX) break;
    rep(j,MAX){
      if(j < num) dp[1][j] = dp[0][j];
      else dp[1][j] = min(dp[0][j] ,dp[1][j - num] + 1);
    }
    rep(j,MAX) dp[0][j] = dp[1][j];
    if(num % 2 == 1){
      rep(j,MAX){
        if(j < num) odp[1][j] = odp[0][j];
        else odp[1][j] = min(odp[0][j] ,odp[1][j - num] + 1);
      }
      rep(j,MAX) odp[0][j] = odp[1][j];
    }
  }

  rep(i,a.size()){
    cout << dp[0][a[i]] << " " << odp[0][a[i]] << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int x;

  VI array;
  VI oddArray;

  FOR(i,1,200){
    if(i*(i+1)*(i+2)/6 <= 1e6){
      array.push_back(i*(i+1)*(i+2)/6);
      if((i*(i+1)*(i+2)/6) % 2 == 1) oddArray.push_back(i*(i+1)*(i+2)/6);
    }


    else break;
  }
  VI dp(1000010,0);
  VI dpOdd(1000010,0);
  rep(i,array.size()){
    dp[array[i]] ++;
  }
  rep(i,oddArray.size()){
    dpOdd[oddArray[i]] ++;
  }
  rep(j,array.size()){
    rep(k,1e6+1){
      if(dp[k] == 0) continue;
      if(array[j]+k >= 1e6) continue;
      if(dp[array[j]+k] >= 1) dp[array[j]+k] = min(dp[k] + 1,dp[array[j]+k]);
      else dp[array[j]+k] = dp[k] + 1;
    }
  }
  rep(j,oddArray.size()){
    rep(k,1e6+1){
      if(dpOdd[k] == 0) continue;
      if(oddArray[j]+k >= 1e6) continue;
      if(dpOdd[oddArray[j]+k] >= 1) dpOdd[oddArray[j]+k] = min(dpOdd[k] + 1,dpOdd[oddArray[j]+k]);
      else dpOdd[oddArray[j]+k] = dpOdd[k] + 1;
    }
  }

  // rep(i,10){
  //   rep(j,array.size()){
  //     int cnt = 0;
  //     if(array[j] % 2 == 0) continue;
  //     FOR(k,1,1e6+1){
  //       if(dp[k].second == 0) continue;
  //       cnt++;
  //       if(array[j]+k >= 1e6) continue;
  //       if(dp[array[j]].first == 0) continue;
  //       if(dp[array[j]+k].first >= 1) continue;
  //       dp[array[j]+k].first += dp[array[j]].first + 1;
  //     }
  //   }
  //}
  while(true){
    cin >> x;
    if(x == 0) return 0;
    cout << dp[x] << ' ' << dpOdd[x] << endl;
    //printf("%d %d\n",dp[x].first,dp[x].second);
  }
  return 0;
}

C++: #include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;

int main(){
  vll w(200);vvll dp(1000001,vll(2,MOD));
  rep(i,0,200){
    w[i]=((i+1)*(i+2)*(i+3))/6;
    
  }
  dp[0][0]=dp[0][1]=0;
  rep(i,1,1000001){
    rep(j,0,200){
      if(i>=w[j]&&dp[i-w[j]][0]!=MOD){
        dp[i][0]=min(dp[i-w[j]][0]+1,dp[i][0]);
        if(w[j]%2&&dp[i-w[j]][1]!=MOD){dp[i][1]=min(dp[i-w[j]][1]+1,dp[i][1]);}
      }
    }
  }
  ll n=1;
  while(n!=0){
    cin>>n;
    if(n==0)break;
    cout<<dp[n][0]<<" "<<dp[n][1]<<endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[200]={0},b[150]={0},c[1500001]={0,1,2,3},d[1500001],k=0,i,j,n;
  for(i=1;i<190;i++)a[k++]=i*(i+1)*(i+2)/6;
  for(j=k=0;j<i;j++)if(a[j]%2)b[k++]=a[j];
  for(i=1;i<188;i++)for(j=a[i];j<a[i+1];j++)c[j]=c[j-a[i]]+1;
  for(i=0;i<36;i++)d[i]=i;
  for(i=1;i<k-2;i++)for(j=b[i];j<b[i+1];j++)d[j]=d[j-b[i]]+1;
  while(cin>>n,n)cout<<c[n]<<' '<<d[n]<<endl;
}