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 <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 1000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int dp[200][MAXN+1];
int dp2[200][MAXN+1];

int main(void) {
    for (int i = 0; i < 200; i++) {
        for (int j = 0; j <= MAXN; j++) {
            dp[i][j] = INF;
            dp2[i][j] = INF;
        }
    }
    dp[0][0] = 0; dp[0][1] = 1;
    dp2[0][0] = 0; dp2[0][1] = 1;
    // DP
    for (int i = 1; i < 200; i++) {
        int plus = i * (i+1) * (i+2) / 6;
        dp[i][0] = 0;
        dp2[i][0] = 0;
        for (int j = 1; j <= MAXN; j++) {
            if (j - plus >= 0) dp[i][j] = min(dp[i-1][j], dp[i][j-plus] + 1);
            else dp[i][j] = dp[i-1][j];
        }
        if (plus % 2 == 1) {
            for (int j = 1; j <= MAXN; j++) {
                if (j - plus >= 0) dp2[i][j] = min(dp2[i-1][j], dp2[i][j-plus] + 1);
                else dp2[i][j] = dp2[i-1][j];
            }
        } else {
            for (int j = 1; j <= MAXN; j++) {
                dp2[i][j] = dp2[i-1][j];
            }
        }
    }
//    for (int i = 1; i < 5; i++) {
//        for (int j = 1; j <= 10; j++) {
//            cout << dp2[i][j] << " ";
//        }
//        cout << endl;
//    }
    int n;
    while (1) {
        cin >> n;
        if (n == 0) break;
        cout << dp[199][n] << " " << dp2[99][n] << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)

const int m = 1000001;

int a[2][200];
int dp[2][1000004];

int main() {

    int c = 0;
    for(int i=1;(i*(i+1)*(i+2))<m;i++) {
        a[0][i-1] = i*(i+1)*(i+2)/6;
        if(a[0][i-1]%2) {
            a[1][c] = a[0][i-1];
            c++;
        }
    }

    rep(i, 2)rep(j, m)dp[i][j] = j;

    rep(i, 2)
        rep(j, 200)
            rep(k, m)
                if((k-a[i][j])>=0 && dp[i][k-a[i][j]] < dp[i][k])dp[i][k] = dp[i][k-a[i][j]] + 1;

    int n;
    while(cin>>n,n)cout<<dp[0][n]<<' '<<dp[1][n]<<endl;

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
static const int MAX =1000001;
static const int INF = 1500000;
int Min[MAX]; //memo for speeding things up
int odd[MAX]; // same

// this is the improved version to 1167.cpp
void memo(){
   /*
     Same as problem 17.1 in the book Algo and Data Struct
     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A

    */

    /*
      Made the program substantially faster by making a memo of two different array with one loop

      

     */
    
    Min[0]=0;
    Min[1]=1;
    odd[0]=0;
    odd[1]=1;
    int i,j;
    for(i=0;i<MAX;i++){
	for(j=1;j<MAX;j++){
	    int b=(j*(j+1)*(j+2))/6;
	    if (i+b>MAX)break;
	    Min[i+b]=min(Min[i+b],Min[i]+1);
	    if(b%2){
		odd[i+b]=min(odd[i+b],odd[i]+1);
	    }
	 }
     }
 }


 int main(){
     int n;

     int i;
     memset(Min,INF,sizeof(Min));
     memset(odd,INF,sizeof(odd));
     memo();
    

    while(1){
	cin >>n;
	if(n==0)break;

	cout << Min[n] << " " << odd[n] << endl;
    }

    return 0;
}

C++: #include<stdio.h>
#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<queue>
#define pi 3.14159
#define Inf (int)pow(2., 12.)

using namespace std;
typedef std::pair<int, int> mypair;
queue<mypair> qu;
#define M 1000000
 
int odd[M+10], all[M+10];
 
void update(int *ar, int x){
    for(int i = x; i <= M; ++i){
        ar[i] = min(ar[i], ar[i - x] + 1);
    }
}
 
int main(){
	odd[0] = all[0] = 0;
    for(int i = 1; i <= M; ++i){
        odd[i] = all[i] = 10000000;
    }
 
    for(int i = 1; ; ++i){
        int x = i * (i + 1) * (i + 2) / 6;
        if(x > M) break;
        update(all, x);
        if(x % 2 == 1) update(odd, x); 
    }
     
    int n;
    while(1) {
		cin >> n;
		if(n == 0) break;
		cout << all[n] << " " << odd[n] <<endl;
	}
}