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>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int a, b, c, ans;


int solve( int now, int many, int p ) {
	if ( now == b ) {
		return many == c;
	}
	int res = 0;
	for ( int i = p + 1; i <= a; i++ ) {
		res += solve( now + 1, many + i, i );
	}
	return res;
}


int main() {
	while ( ~scanf( "%d %d %d", &a, &b, &c ) && a && b && c ) {
		ans = solve(0, 0, 0);
		printf( "%d\n", ans );
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  int n, k, s;
  while(cin >> n >> k >> s, n){
    int sum = 0;
    for(int i = 0; i < 1<<n; i++){
      int tmp = 0, cnt = 0;
      for(int k = 0; k < n; k++){
        if(i >> k & 1) tmp++;
      }
      if(tmp != k) continue;
      for(int j = 0; j < n; j++){
        if(i >> j & 1) cnt += j + 1;
      }
      if(cnt == s) sum++;
    }
    cout << sum << endl;
  }
  return 0;
}

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

int dp[11][156][21];	//dp[????????§????????°][????????§???????¨?][????????§????????§???] = ????????????

int main() {
	int i, j, k, l;
	int m, n, s;	//max, num, sum
	
	while (cin >> m >> n >> s) {
		if (!n) break;
		for (i = 0; i <= n; i++) for (j = 0; j <= s; j++) for (k = 0; k <= m; k++) dp[i][j][k] = 0;
		dp[0][0][0] = 1;
		for (i = 0; i < n; i++) {
			for (j = 0; j <= s; j++) {
				for (k = 0; k <= m; k++) {
					for (l = k + 1; j + l <= s && l <= m; l++) {
						dp[i + 1][j + l][l] += dp[i][j][k];
					}
				}
			}
		}
		
		int ans = 0;
		for (i = 0; i <= m; i++) ans += dp[n][s][i];
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
using namespace std;
int dp[23][13][166];
int main()
{
    int n,k,s;
    memset(dp,0,sizeof dp);
    dp[0][0][0]=1;
    for(int j=0;j<=10;j++)
        for(int i=0;i<=20;i++)
            for(int s=155;s>=0;s--)
            if(dp[i][j][s])
                for(int e=i+1;e<=20&&s+e<=155;e++)
                dp[e][j+1][s+e]+=dp[i][j][s];
    for(int s=155;s>=0;s--)
    for(int j=0;j<=10;j++)
        for(int i=1;i<=20;i++)
            dp[i][j][s]+=dp[i-1][j][s];
    while(scanf("%d%d%d",&n,&k,&s)&&n)
    {
        printf("%d\n",dp[n][k][s]);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int dfs(int k, int last, int rest){
    if(k == 0 && rest == 0) return 1;
    if(k == 0) return 0;
    int res = 0;
    for(int i = last - 1; i > 0; i--){
        if(rest - i >= 0){
            res += dfs(k - 1, i, rest - i);
        }
    }
    return res;
} 
int main(){
    int N, K, S;
    while(cin >> N >> K >> S && N){
        cout << dfs(K, N + 1, S) << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int n,int k, int s){
	int dp[k+1][n+1][s+1];
	for(int a = 0; a < k+1; a++){
		for(int b = 0; b < n+1; b++){
			for(int c = 0; c < s+1; c++)dp[a][b][c] = 0;
		}
	}

	for(int i = 1; i <= n; i++){
		dp[1][i][i] = 1;
	}

	for(int i = 2; i <= k; i++){
		for(int k = 1; k <= n; k++){
			for(int a = 1; a <= k-1; a++){
				for(int p = k; p <= s; p++){
					dp[i][k][p] += dp[i-1][a][p-k];
				}
			}
		}
	}

	int ans;

	ans = 0;
	for(int i = 0; i <= n; i++)ans += dp[k][i][s];

	printf("%d\n",ans);

}

int main(){

	int n,k,s;

	while(true){
		scanf("%d %d %d",&n,&k,&s);
		if(n == 0 && k == 0 && s == 0)break;

		func(n,k,s);
	}

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int a[21][11][156];

int f(int n, int k, int s){
	if(n <= 0 || k <= 0 || s <= 0)
		return 0;
	if(a[n][k][s] == -1){
		if(k == 1){
			if(n >= s) a[n][k][s] = 1;
			else a[n][k][s] = 0;
		}else{
			a[n][k][s] = 0;
			for(int i=2; i<=n; ++i)
				a[n][k][s] += f(i-1, k-1, s-i);
		}
	}
/*	if(a[n][k][s] != 0){
		cout << n << " " << k << " " << s << "\n";
		cout << a[n][k][s] << "\n";
	}
*/	return a[n][k][s];
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	memset(a, -1, sizeof(a));
	while(1){
		int n, k, s;
		cin >> n >> k >> s;
		if(n+k+s==0) return 0;
		cout << f(n, k, s) << "\n";
	}
}