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 main()
{
  int N,S[1000],SS[1000],SSS[1000],P[1000001],OP[1000001],a=0;
  S[0]=0;P[0]=0;OP[0]=0;
  for(int i=1;i<1000001;i++){
    OP[i]=P[i]=10000001;
  }
  for(int i=1;i<300;i++){
    S[i]=S[i-1]+i;
  }
  SS[0]=0;
  for(int i=1;i<300;i++){
    SS[i]=SS[i-1]+S[i];
    if(SS[i]%2==1)SSS[a++]=SS[i];
  }
  for(int i=0;i<a;i++){
    for(int j=SSS[i];j<1000001;j++){
      OP[j]=min(OP[j],OP[j-SSS[i]]+1);
    }
  }
  for(int i=1;i<300;i++){
    for(int j=SS[i];j<1000001;j++){
      P[j]=min(P[j],P[j-SS[i]]+1);
    }
  }
  while(1){
    cin>>N;
    if(N==0)break;
    cout<<P[N]<<" "<<OP[N]<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int ans1[MAX+10],ans2[MAX+10],box[200];
void tab_make(){
	for(int i=1;i*(i+1)*(i+2)/6<=MAX;i++)
		box[i]=(i*(i+1)*(i+2)/6);
}
void ans_make(){
	ans1[0]=ans2[0]=0;
	for(int i=1;i<=MAX;i++){
		ans1[i]=ans2[i]=i;
		for(int j=1;i-box[j]>=0;j++){
			ans1[i]=min(ans1[i],ans1[i-box[j]]+1);
			if(box[j]%2==1)
			ans2[i]=min(ans2[i],ans2[i-box[j]]+1);
		}
	}
}
int main(){
	int x;
	tab_make();
	ans_make();
	while(cin>>x,x){
		cout<<ans1[x]<<' '<<ans2[x]<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define POL_MAX 200
#define N_MAX 1000000
using namespace std;

int N;
int dp[N_MAX+1];
const int INF = INT_MAX / 3;

int solve(vector<int> &my_pol) {
	rep(j, N+1) { dp[j] = j; }

	int m = my_pol.size(); 
	int ans=INF;	
	REP(j, 1, N+1) {
		REP(i, 1, m) {
			if(j<my_pol[i]) break;
			dp[j] = min(dp[j], dp[j-my_pol[i]] + 1);
		}
	}
	
	return dp[N];
}

int main(){

	int n=1;
	int value=0;
	vector<int> pol, kisu_pol;
	while(true) {
		value = n*(n+1)*(n+2) / 6;
		if (value >= N_MAX) { break; }
		pol.push_back(value);
		if (value % 2 != 0) { kisu_pol.push_back(value); }
		n++;
	}

	while(cin >> N) {
		if (N == 0) { break; }
		cout << solve(pol) << " " << solve(kisu_pol) << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int tetra[200];
int dp[1000010];
int dp2[1000010];


signed main(){
    rep(i, 0, 200) tetra[i] = (i+1)*(i+2)*(i+3)/6;
    fill(dp, dp+1000010, INF);
    fill(dp2, dp2+1000010, INF);
    dp[0] = dp2[0] = 0;
    rep(i, 0, 1000010) rep(j, 0, 200){
        if(i+tetra[j] > 1000010) break;
        chmin(dp[i+tetra[j]], dp[i]+1);
        if(tetra[j]%2 == 1) chmin(dp2[i+tetra[j]], dp2[i]+1);
    }
    int n;
    while(cin >> n, n) cout << dp[n] << ' ' << dp2[n] << endl;

    return 0;
}

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

int dp1[1000001];
int dp2[1000001];

int main() {
	int N = 1000000;

	vector<int> v1,v2;
	int n = 1;
	while(n*(n+1)*(n+2)/6<=N) {
		int p = n*(n+1)*(n+2) / 6;
		v1.push_back(p);
		if(p%2==1)
			v2.push_back(p);
		n++;
	}

	for(int i = 0;i < N+1;i++) {
		dp1[i] = i;
		dp2[i] = i;
	}
	//cout << v1.size() << " " << v2.size() << endl;
	for(auto v : v1) {
		for(int j = v;j < N + 1;j++) {
			dp1[j] = min(dp1[j],dp1[j - v] + 1);
		}
	}
	for(auto v : v2) {
		for(int j = v;j < N + 1;j++) {
			dp2[j] = min(dp2[j],dp2[j - v] + 1);
		}
	}

	while(true) {
		int m;
		cin >> m;
		if(m == 0)
			break;
		cout << dp1[m] << " " << dp2[m] << endl;
	}
	return 0;
	
}

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

int main(){
  int s[200], dp1[MAX], dp2[MAX];
  for(int i=1;i<200;i++) s[i]=i*(i+1)*(i+2)/6;
  for(int i=0;i<MAX;i++){
    dp1[i] = dp2[i] = i;
    for(int j=1;i>=s[j];j++){
      dp1[i] = min(dp1[i], dp1[i-s[j]]+1);
      if(s[j]%2==1){
        dp2[i] = min(dp2[i], dp2[i-s[j]]+1);
      }
    }
  }
  int n;
  while(true){
    cin >> n;
    if(n==0) break;
    cout << dp1[n] << " " << dp2[n] << endl;
  }
}