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<cstring>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1111111];
int memo2[1111111];
 
int solve(int n){
   
  if(!n) return 0;
  if(~memo[n]) return memo[n];
 
  int ans = INF;
  for(int i=1;i<181;i++) if(n>=p[i]) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(n<0) return INF;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=1;i<181;i++) if(p[i]&1 && n>=p[i]) ans = min(ans, solve2(n-p[i])+1);
 
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));
 
  for(int i=0;i<181;i++) p[i] = i*(i+1)*(i+2)/6;
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
 
}

C++: #include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>

#define ll long long
#define inf  1000000007
#define mod 1000000007
#define pa pair<int,int>
#define pal pair<ll,ll>
#define ppa pair<int,pa>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y) {}
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(x*a,y*a);}
  Point operator / (double a) {return Point(x/a,y/a);}
  double absv() {return sqrt(norm());}
  double norm() {return x*x+y*y;}
  bool operator < (const Point &p) const{
    return x != p.x ? x<p.x: y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};

double hen(Vector a){
if(fabs(a.x)<EPS && a.y>0) return acos(0);
else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
else if(fabs(a.y)<EPS && a.x>0) return 0.0;
else if(a.y>0) return acos(a.x/a.absv());
else return 2*acos(0)+acos(-a.x/a.absv());

}

double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ru[11]={1,2,4,8,16,32,64,128,256,512,1024};

ll frac[100010];
ll inv[100010];

ll saikif(ll a,int n){
  if(n==1) return a%mod;
  else if(n%2==0){
    ll q=saikif(a,n/2);
    return (q*q)%mod;
  }
  else return (a*saikif(a,n-1))%mod;
}

void gyakugen(){
  frac[0]=1;
  for(int i=1;i<=100000;i++) frac[i]=(frac[i-1]*i)%mod;
  for(int i=0;i<=100000;i++) inv[i]=saikif(frac[i],mod-2);
}


//----------------kokomade temple------------
int dp[100002];
int dp2[100002];
vector<int> ve;
vector<int> ve2;
int num,num2;

int dfs(int n){
if(dp[n]<inf) return dp[n];
else{
//  cout<<n<<endl;
  int ans=inf;
for(int j=0;j<num;j++){
  if(ve[j]>=n) break;

  ans=min(ans,1+dfs(n-ve[j]));
}
  dp[n]=ans;
  return ans;
}

}

int dfs2(int n){
if(dp2[n]<inf) return dp2[n];
else{
//  cout<<n<<endl;
  int ans=inf;
for(int j=0;j<num2;j++){
  if(ve2[j]>=n) break;

  ans=min(ans,1+dfs2(n-ve2[j]));
}
  dp2[n]=ans;
  return ans;
}

}



int main(){
  fill(dp,dp+100002,inf);
  fill(dp2,dp2+100002,inf);
int z=1,w;
while(1){
  w=z*(z+1)*(z+2)/6;
  //cout<<w<<endl;
  if(w>100000) break;
  else{
    ve.push_back(w);
    if(w%2==1){
      ve2.push_back(w);
      dp2[w]=1;
    }
    z++;
    dp[w]=1;

  }
}
num=ve.size();
num2=ve2.size();
for(int i=1;i<100001;i++){
  dfs(i);
  dfs2(i);
}

int n;

while(cin>>n){
  if(n==0) break;
  cout<<dp[n]<<" "<<dp2[n]<<endl;
}


return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
int dp[1000010];
int dp2[1000010];

int main(){
	int a = 1, b;
	vi v;
	vi u;
	while((b = a*(a+1)*(a+2)/6)<1e6){
		v.pb(b);
		if(b%2 == 1){
			u.pb(b);
		}
		a++;
	}
	//cout<<v.size()<<endl;
	for(int i = 0; i < 1000010; i++){
		dp[i] = INF;
		dp2[i] = INF;
	}
	dp[0] = 0;
	dp2[0] = 0;
	for(int i = 0; i < v.size(); i++){
		for(int j = v[i]; j < 1000010; j++){
			dp[j] = min(dp[j], dp[j-v[i]]+1);
			if(j < u.size()){
				dp2[j] = min(dp2[j], dp2[j-v[i]]+1);
			}
		}
	}
	//cout<<"OK"<<endl;
	int n;
	while(cin>>n && n > 0){
		cout<<dp[n]<<" "<<dp2[n]<<endl;
	}
}