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;n<=p[n] && i<181;i++) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=1;n<=p[n] && i<181;i++) if(p[i]&1) 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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

int dp[1000010];
int dpodd[1000010];

signed main() {
	vector<int> v, vo;

	for (int i = 1; i <= 1000000; i++) {
		dp[i] = INT_MAX;
		dpodd[i] = INT_MAX;
	}
	
	for (int i = 1; true; i++) {
		int num = i * (i + 1) * (i + 2) / 6;
		if (num > 1000000) break;
		
		v.push_back(num);
		if (num % 2) vo.push_back(num);
	}

	for (int i = 1; i <= 1000000; i++) {
		for (int num : v) {
			if (num > i) break;
			dp[i] = min(dp[i], dp[i - num] + 1);
		}
		for (int num : vo) {
			if (num > i) break;
			dpodd[i] = min(dpodd[i], dpodd[i - num] + 1);
		}
	}

	int input;
	cin >> input;

	while (input) {
		cout << dp[input] << ' ' << dpodd[input] << endl;

		cin >> input;
	}

    return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

#define MAX 1000000

void makelist(int *list, int x) {
  for (int i = x; i < MAX; i++) {
    list[i] = min(list[i], list[i-x]+1);
  }
}

int main() {
  int list1[MAX], list2[MAX], x, n;
  for (int i = 1; i < MAX; i++) {
    list1[i] = list2[i] = INF;
  }
  for (int i = 1; ; i++) {
    x = i*(i+1)*(i+2)/6;
    if (x >= MAX) break;
    makelist(list1, x);
    if (x & 1) makelist(list2, x);
  }
  while (cin >> n, n) {
    cout << list1[n] << " " << list2[n] << el;
  }
}

C++: #include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  vector<ll>dp1(1000001,INT_MAX);
  vector<ll>dp2(1000001,INT_MAX);
  dp1[0]=0;
  dp2[0]=0;
  for(int i=1;i<=1000;i++){
    ll w=i*(i+1)*(i+2)/6;
    if(w>1000000)break;
    for(int j=0;j<=1000000;j++){
      if(j-w>=0)dp1[j]=min(dp1[j],dp1[j-w]+1);
      if(j-w>=0&&w%2)dp2[j]=min(dp2[j],dp2[j-w]+1);
    }
  }
  int x;
  while(cin>>x){
    if(x==0)break;
    cout<<dp1[x]<<" "<<dp2[x]<<endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int dp[1000000];
int dp_odd[1000000];
int main(void){
  vector <int> nums;
  for(int i = 1; i * (i + 1) * (i + 2) / 6 < 1000000; i++){
    nums.push_back(i * (i + 1) * (i + 2) / 6);
  }
  for(int i = 0; i < 1000000; i++){
    dp[i] = INT_MAX;
    dp_odd[i] = INT_MAX;
  }
  dp[0] = 0;
  dp_odd[0] = 0;
  for(int i = 1; i < 1000000; i++){
    for(int j = 0; j < nums.size(); j++){
      if(i - nums[j] >= 0){
        dp[i] = min(dp[i], 1 + dp[i - nums[j]]);
        if(nums[j] % 2 == 1){
          dp_odd[i] = min(dp_odd[i], 1 + dp_odd[i - nums[j]]);
        }
      } else {
        break;
      }
    }
  }
  int n;
  while(true){
    cin >> n;
    if(n == 0){
      break;
    }
    cout << dp[n] << " " << dp_odd[n] << endl;
  }
  return 0;
}