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 <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i, a) for(i = 0; i < (a); i++)
#define FORM(i, a) for(i = (a) i >= 0; i--)
#define INF 100000
using namespace std;
int c[1000], odd[1000];
int mini[200];

int main(){
int i, j, W, minimumc, minimumodd, l;
 

   for(i = 1; i <= 200; i++){
	   c[i] = (i*(i+1)*(i+2))/6;
   }
   j = 1;
   for(i = 1; i <= 200; i++){
	   if(c[i] % 2 == 1){
		   odd[j] = c[i];
		   j += 1;
	   }
   }


   cin >> W;

   while(W != 0){
	   minimumc = 10000000;
	   minimumodd = 10000000;
	   for(i = 1; i <= 200; i++){
		   l = W;
		   if(c[i] > W){
			   break;
		   }
		 for(j = i; j > 0; j--){
			 mini[i] += l / c[j];
			 l %= c[j];
			
		 }

		  minimumc = min(minimumc, mini[i]);
	   }

	   
	
	   FOR(i, 200){
		   mini[i] = 0;
	   }
	      for(i = 1; i <= 200; i++){
			  l = W;
		   if(odd[i] > W){
			   break;
		   }
		 for(j = i; j > 0; j--){
			 mini[i] += l/odd[j];
			 l %= odd[j];
			
		 }

		  minimumodd = min(minimumodd, mini[i]);
	   }
		  
     cout << minimumc << " " << minimumodd << endl;
	   FOR(i, 200){
		   mini[i] = 0;
	   }
       
	   cin >> W;

   }
   

return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)

const int MAX = 1000000;

int dp[MAX + 1];
int dp2[MAX + 1];

void solve(int n)
{
  vector<int> v;
  for(int i = 0; ; i++){
    int t = i * (i + 1) * (i + 2) / 6;
    if(t <= MAX)
      v.push_back(t);
    else
      break;
  }
  for(int i = 0; i <= n; i++){
    for(int j = 0; j < v.size(); j++){
      if(i + v[j] <= n){
        if(v[j] & 1)
          dp2[i + v[j]] = min(dp2[i + v[j]], dp2[i] + 1);
        dp[i + v[j]] = min(dp[i + v[j]], dp[i] + 1);
      }
    }
  }
}
    
int main()
{
  int n;
  while(1){
    cin >> n;
    if(n == 0){
      break;
    }else{
      fill(dp, dp + n + 1, MAX);
      fill(dp2, dp2 + n + 1, MAX);
      solve(n);
      cout << dp[n] << " " << dp2[n] << endl;
    }
  }
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    vector<int> list;
    int tmp=1;int cnt=1;
    while(tmp<=1000000){
        list.push_back(tmp);
        cnt++;
        tmp=cnt*(cnt+1)*(cnt+2)/6;
    }
    int len = list.size();
    vector<int> dp(1000001,0);vector<int> oddsdp(1000001,0);
    REP(i,1000001){
        dp[i]=i;oddsdp[i]=i;
    }
    REP(i,len){
        REP(j,1000001){
            if(j - list[i]>=0)dp[j] = min(dp[j-list[i]]+1,dp[j]);
        }
        //printf("%d\n",list[i]);
    }
    REP(i,len){
        if(list[i]%2 == 0)continue;
        REP(j,1000001){
            if(j-list[i]>=0)oddsdp[j]=min(oddsdp[j-list[i]]+1,oddsdp[j]);
        }
        //printf("%d\n",oddsdp[40]);
    }
    int n;scanf("%d",&n);
    while(n){
        int ans1,ans2;
        ans1 =dp[n];ans2=oddsdp[n];
        printf("%d %d\n",ans1,ans2);
        scanf("%d",&n);
    }
}

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+10], list2[MAX+10], 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;
  }
}