Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		N, K, S := io.NextInt(), io.NextInt(), io.NextInt()
		if N == 0 {
			break
		}
		dp := [21][11][156]int{}
		for i := 0; i <= N; i++ {
			dp[i][0][0] = 1
		}
		for i := 1; i <= N; i++ {
			for j := 1; j <= K; j++ {
				for k := 1; k <= S; k++ {
					if k-i >= 0 {
						dp[i][j][k] += dp[i-1][j-1][k-i]
					}
					dp[i][j][k] += dp[i-1][j][k]
				}
			}
		}
		io.Println(dp[N][K][S])
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

int dp[15][25][200];

signed main(){
    while(1){
        int n, K, s;
        cin >> n >> K >> s;
        if(n + K + s == 0) break;
        rep(i, 0, 15) rep(j, 0, 25) rep(k, 0, 200) dp[i][j][k] = 0;
        dp[0][0][0] = 1;
        rep(i, 0, K){
            rep(j, 0, n){//pre
                rep(k, j + 1, n + 1){//new
                    rep(l, 0, s + 1){
                        // dp[i + 1][j][l] += dp[i][j][l];
                        // if(dp[i][j][l] == -1) continue;
                        if(l + k > s) continue;
                        // if(dp[i + 1][k][l + k] == -1) dp[i + 1][k][l + k] = 0;
                        dp[i + 1][k][l + k] += dp[i][j][l];
                    }
                }
            }
        }
        int ans = 0;
        // rep(i, 0, K + 1){
        //     rep(j, 0, n){
        //         rep(k, 0, 30){
        //             cout << dp[i][j][k] << " ";
        //         }
        //         cout << endl;
        //     }
        //     cout << endl << endl;
        // }
        rep(i, 0, n + 1){
            ans += dp[K][i][s];
        }
        cout << ans << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

int n, k, s;

int solve(int n, int k, int s)
{
	if (s < 0) return 0;
	if (n < 0) return 0;
	if (k == 0)
	{
		if (s == 0) return 1;
		else return 0;
	}
	return solve(n - 1, k - 1, s - n) + solve(n - 1, k, s);

}

int main()
{
	while (cin >> n >> k >> s, n)
	{
		cout << solve(n, k, s) << endl;
	}
}

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

int main()
{
	while (true) {
		int n, k, s;

		cin >> n >> k >> s;

		if (n == 0 && k == 0 && s == 0) {
			break;
		}

		int ans = 0;

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

			for (int j = 0; j < n; j++) {
				if ((i >> j) % 2 == 1) {
					count++;
				}
			}

			if (count == k) {
				int sum = 0;

				for (int j = 0; j < n; j++) {
					if ((i >> j) % 2 == 1) {
						sum += j + 1;
					}
				}

				if (sum == s) {
					ans++;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

int ans(int sum, int max, int n, int k, int s){
    if(sum > s) return 0;
    if(k==0){
        if(sum==s){
            return 1;
        }else{
            return 0;
        }
    }
    int count=0;
    for(int i=max+1; i+k-1<=n; i++){
        count += ans(sum+i, i, n, k-1, s);
    }
    return count;
}

int main(){
    while(1){
        int n,k,s;
        cin >> n >> k >> s;
        if(n==0) break;

        cout << ans(0,0,n,k,s) << endl;
    }
    return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int n, k, s;
	while (cin >> n >> k >> s, n) {
		vvi dp(k + 1, vi(s + 1));
		dp[0][0] = 1;
		FOR(i, 1, n) {
			for (int j = k; j > 0; j--) {
				FOR(l, i, s) {
					dp[j][l] += dp[j - 1][l - i];
				}
			}
		}
		cout << dp[k][s] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;
static int dp[21][12][200];

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int n, k, s;
		cin >> n >> k >> s;
		if(n == 0 && k == 0 && s == 0){ break; }
		memset(dp, 0, sizeof(dp));
		dp[0][0][0] = 1;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j <= k; ++j){
				for(int t = 0; t <= s; ++t){
					dp[i + 1][j][t] += dp[i][j][t];
					dp[i + 1][j + 1][t + i + 1] += dp[i][j][t];
				}
			}
		}
		cout << dp[n][k][s] << endl;
	}
	return 0;
}

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


main(){
	int n,m,s,dp[21][11][160];
	while(cin >> n >> m >> s, s){
		REP(i, n+1)REP(j, m+1)REP(k, s+1) dp[i][j][k] = !(i+j+k);
		REP(i, n)REP(j, m)REP(k, s+1){
			if(j<m && k+i<s) dp[i+1][j+1][k+i+1] += dp[i][j][k];
			dp[i+1][j][k] += dp[i][j][k];
		}
		int ans=0;
		REP(i, n+1) ans+=dp[i][m][s];
		cout << ans << endl;
	}
	return 0;
}