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<bits/stdc++.h>
using namespace std;

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 1020304050
#define n_max 1000000

int main()
{
  int n;cin>>n;
  int i,j;
  vector<int> dp(n_max+1,INF);
  vector<int> dp2(n_max+1,INF);
  vector<int> ss(300,0);
  dp[0]=0;
  dp2[0]=0;
  rep(i,300)
  {
    ss[i]=(i+1)*(i+2)*(i+3)/6;
  }
  for(i=1;i<=n_max;i++)
  {
    rep(j,300)
    {
      if(i-ss[j]<0)break;
      dp[i]=min(dp[i],dp[i-ss[j]]+1);
      if(ss[j]%2==1)
      {
        dp2[i]=min(dp2[i],dp2[i-ss[j]]+1);
      }
    }
  }
  while(n!=0)
  {
    cout<<dp[n]<<' '<<dp2[n]<<endl;
    cin>>n;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

struct State{
    int lower,size,rest;
    State(int lower,int size,int rest) : lower(lower),size(size),rest(rest) {};
};

int main(){
    vector<int> v;
    vector<int> odd;
    for(int i=1;;i++){
        int c = i*(i+1)*(i+2)/6;
        if(c > 1000000) break;
        v.push_back(c);
        if(c % 2 == 1) odd.push_back(c);
    }
    int M = 1000010;
    vector<int> answer(M,1 << 30);
    vector<int> answer_odd(M,1 << 30);
    answer[0] = 0;
    answer_odd[0] = 0;
    for(int i=0;i<M;i++){
        int nex;
        for(int j=0;j<v.size() && (nex=i+v[j]) < M;j++){
            answer[nex] = min(answer[i] + 1,answer[nex]);
        }
        for(int j=0;j<odd.size() && (nex=i+odd[j]) < M;j++){
            answer_odd[nex] = min(answer_odd[i] + 1,answer_odd[nex]);
        }
    }

    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << answer[n] << " " << answer_odd[n] << endl;
    }
    return 0;
}

C++: #include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;

using namespace std;

int dp[1000001],dpodd[1000001];

int main(){

  long ii,jj,kk;
  vector<int> ret;

  //ポロック予想
  int n;
  n = -1;



  for(ii=0;ii<1000001;ii++){
    dp[ii] = INF;
    dpodd[ii] = INF;
  }
      
  dp[0] = 0;
  dpodd[0] = 0;

  int y;

  for(ii=1;;ii++){
    y = ii*(ii+1)*(ii+2)/6;

    if(y>=1e6){
    //if(y>=21){
      break;
    }

    for(jj=y;jj<1000001;jj++){
      //for(jj=y;jj<=40;jj++){
    
      dp[jj] = min(dp[jj],dp[jj-y] + 1);
    
      if(y%2 == 1){
        dpodd[jj] = min(dpodd[jj],dpodd[jj-y] + 1);
      }
    
    }
    //for(jj=1;jj<=40;jj++){
    //  cout << dp[jj] << "\t";
    //}
    //cout << endl;
  }

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

  }


  return 0;
}

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

int main()
{
  for(;;){
    int x;
    cin >> x;

    if(x==0)
      break;

    int count=0;
    int count_ki=0;
    int tmp;
    /*for(int i=1;i<=x;i++){
      tmp=i*(i+1)*(i+2)/6;
      if(tmp>x)
	break;
      count++;
      if(tmp%2==1)
	count_ki++;
	}*/

    int coin[x];
    int coin_ki[x];
    //fill(coin,coin + x + 1,-1);
    //fill(coin_ki,coin_ki + x + 1,-1);
    int tmp2=0;
  
    for(int i=1;i<x;i++){
      coin[i-1]=i*(i+1)*(i+2)/6;
      count++;
      if(coin[i-1]%2==1){
	coin_ki[tmp2++]=coin[i-1];
	count_ki++;
      }
      if(coin[i-1]>x)break;
    }

    int dp[x+1];
    fill(dp,dp + x + 1,100000);
  

    /*for(int i=0;i<=x;i++)
      printf("dp[%d]=%d\n",i,dp[i]);
    */
    dp[0]=0;
    for(int i = 0;i<x+1;i++){
      for(int j=0;j<count;j++){
	if(i+coin[j]<=x){
	  dp[i+coin[j]]=min(dp[i+coin[j]],dp[i]+1);
	}
      }
    }

    cout << dp[x] << " ";
    fill(dp,dp + x + 1,100000);
  
    //printf("%d\n",count_ki);
    dp[0]=0;
    for(int i = 0;i<x+1;i++){
      for(int j=0;j<count_ki;j++){
	if(i+coin_ki[j]<=x){
	  dp[i+coin_ki[j]]=min(dp[i+coin_ki[j]],dp[i]+1);
	}
      }
    }
   
    cout << dp[x] << endl;
  
    ///*/
  }
}