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 dp[1000001];
int dpOdd[1000001];

int main() {
	int i, j;
	
	for (i = 0; i < 1000001; i++) dp[i] = 1145141919;
	for (i = 0; i < 1000001; i++) dpOdd[i] = 1145141919;
	dp[0] = 0;
	dpOdd[0] = 0;
	
	for (i = 0; i < 1000001; i++) {
		for (j = 1; i + j * (j + 1) * (j + 2) / 6 < 1000001; j++) {
			int num = j * (j + 1) * (j + 2) / 6;
			dp[i + num] = min(dp[i + num], dp[i] + 1);
			if (num % 2 == 1) {
				dpOdd[i + num] = min(dpOdd[i + num], dpOdd[i] + 1);
			}
		}
	}
	
	int n;
	while (cin >> n) {
		if (n == 0) break;
		cout << dp[n] << " " << dpOdd[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

int n;

int f[205];
vector<int>dp,dp2;

void calc(){
  for(int i=1;i<=200;++i){
    f[i]=(i*(i+1)*(i+2))/6;
  }
}

void solve(){
  //個数制限なしナップサック1dver
  dp.resize(1e6+5,1e6),dp2.resize(1e6+5,1e6);
  dp[0]=0;dp2[0]=0;
  rep(i,200){
    rep(j,1e6+5){
      if(j-f[i]>=0)chmin(dp[j],dp[j-f[i]]+1);
    }
  }
  rep(i,200){
    rep(j,1e6+5){
      if(f[i]%2==1){
        if(j-f[i]>=0)chmin(dp2[j],dp2[j-f[i]]+1);
      }
    }
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  calc();
  solve();
  while(1){
    cin>>n;
    if(n==0)return 0;
    cout<<dp[n]<<" "<<dp2[n]<<"\n";
  }
	return 0;
}

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

int main(){
	int num[1000010], num2[1000010];
	for(int i=0; i< 1000010; i++) num[i] = num2[i] = 10e8;
	num[0] = num2[0] = 0;
	for(int j=0; j< 1000010; j++){
		for(int i=0; i < 1500; i++){
			int m = i*(i+1)*(i+2)/6;
			if(1000010 <= m+j) continue;
			num[j+m] = min(num[j]+1, num[j+m]);

			if(m == 0) continue;
			if(m%2 == 0) continue;
			num2[j+m] = min(num2[j]+1, num2[j+m]);
		}
	}
	int n;
	while(cin >> n, n){
		cout << num[n] << " " << num2[n] << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)	
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
Def inf = sizeof(Def) == sizeof(ll) ? 2e18 : 1e9+10;
int main(){
	vi w;
	loop(i,1,200)if(i*(i+1)*(i+2)/6<1000100)w.pb(i*(i+1)*(i+2)/6);

	int n;
	while(cin>>n,n){
		vi dp(n+1,inf),dp2(n+1,inf);
		dp[0]=dp2[0]=0;
		rep(i,w.size())rep(j,n){
			int t=j+w[i];
			if(t<n+1)dp[t]=min(dp[t],dp[j]+1);
			if(t<n+1&&w[i]%2)dp2[t]=min(dp2[t],dp2[j]+1);
		}
		cout<<dp[n]<<" "<<dp2[n]<<endl;
	}
}