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 <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
using namespace std;


vector<int>nums;
vector<int>oddnums;

vector<vector<short>>memo(100001, vector<short>(190,-1));
vector<vector<short>>oddmemo(100001, vector<short>(50,-1));

int getans(const int num, const int used,const int atime) {
	if (memo[num][used] != -1) {
		return memo[num][used];
	}
	else {
		if (num == 0)return memo[num][used] = 0;
		if (atime > 10)return atime;
		int ans = num;
		for (int i = 0; i <= used; ++i) {
			int minusnum = nums[i];
			if (minusnum > num) {
				break;
			}
			else if (num / minusnum > 10) {
				continue;
			}
			ans = min(ans, getans(num - minusnum, i, atime + 1)+1);
		}

		return memo[num][used] = ans;
	}
}
int getoddans(const int num, const int used, const int atime) {
	if (oddmemo[num][used] != -1) {
		return  oddmemo[num][used];
	}
	else {
		if (num == 0)return oddmemo[num][used] = 0;
		if (atime > 100)return atime;
		int ans = num;
		for (int i = 0; i <= min(int(oddnums.size()),used); ++i) {
			int minusnum = oddnums[i];
			if (minusnum > num) {
				break;
			}
			else if (num / minusnum > 100) {
				continue;
			}
			ans = min(ans, getoddans(num - minusnum, i, atime + 1) + 1);
		}

		return  oddmemo[num][used] = ans;
	}
}
int main() {
	for (int i = 1; i < 181; ++i) {
		nums.push_back(i*(i + 1)*(i + 2) / 6);
		if (((i*(i + 1)*(i + 2)) / 6) % 2) {

		
			oddnums.push_back((i*(i + 1)*(i + 2)) / 6);
		}
	}

	while (1) {
		int n; cin >> n;
		if (!n)break;
		int normalans = getans(n, 189, 0);;
		int oddans = getoddans(n, 47, 0);

		cout << normalans << " " << oddans << endl;
	}
	return 0;
}

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[180];

int main(){
int i, j, W, minimum, l;
 

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


   cin >> W;

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

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

	   cout << minimum << " ";
	   minimum = 1000000;
	   FOR(i, 181){
		   mini[i] = 0;
	   }
	      for(i = 1; i <= 180; i++){
			  l = W;
		   if(odd[i] > W){
			   break;
		   }
		 for(j = i; j > 0; j--){
			 mini[i] += l/odd[j];
			 l %= odd[j];
			
		 }

		  minimum = min(minimum, mini[i]);
	   }
		  
     cout << minimum << endl;
	   FOR(i, 181){
		   mini[i] = 0;
	   }
       
	   cin >> W;

   }
   

return 0;
}

C++: #include <iostream>

#include<algorithm>

using namespace std;

int n, a[200], dp[200][1000001] , dp2[200][1000001], m;

void set() {

	for (int i = 0; i < 1000000; i++) {
		a[i] = 1;

		for (int j = 1; j <= 3; j++) {
			a[i] *= (i + j);
		}

		a[i] /= 6;

		if (a[i] > 1000000) {
			m = i;
			break;
		}
	}
}

int main() {

	set();

	while (true) {

		cin >> n;
		if (n == 0)break;
		int b;

		for (int i = 0; i < n; i++) {
			int c = 1;

			for (int j = 1; j <= 3; j++) {
				c *= (i + j);
			}
			c /= 6;

			//cout << "c:" << c << endl;

			if (c <= n) {
				b = i;
			}
			else {
				break;
			}
		}

		for (int i = 0; i <= b+1; i++) {
			for (int j = 0; j <= n; j++) {
				dp[i][j] = INT32_MAX;
				dp2[i][j] = INT32_MAX;
			}
		}

		dp[0][0] = 0;
		dp2[0][0] = 0;
		for (int i = 0; i <= b; i++) {
			for (int j = 0; j <= n; j++) {
				for (int k = 0; k <= n; k++) {
					if (j + k*a[i] <= n) {
						if(dp[i][j] != INT32_MAX)dp[i+1][j + k*a[i]] = min(dp[i+1][j + k*a[i]], dp[i][j] + k);

						if (dp2[i][j] != INT32_MAX) {
							if (a[i] % 2 == 1 || k == 0) {
								dp2[i + 1][j + k*a[i]] = min(dp2[i + 1][j + k*a[i]], dp2[i][j] + k);
							}
						}
						
					}
				}
			}
		}

		/*for (int i = 0; i <= b; i++) {
			for (int j = 0; j <= n; j++) {
				cout << dp2[i][j] << " ";
			}
			cout << endl;
		}*/

		int ans = dp[b + 1][n];
		int ans2 = dp2[b + 1][n];

		cout << ans << " " << ans2 << endl;

	}

}