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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;
a
double A, B, C;
int dp[10][190][21] = {};
// dp[i][j][k] : 
signed main(void)
{
	int i, j, k;
	int j2, k2;
	while (1) {
		int N, K, S;
		cin >> N >> K >> S;
		if (N == 0) return 0;
		rep(i, 10) rep(j, 190) rep(k, 21) dp[i][j][k] = 0;
		REP(i, 1, N + 1) {
			dp[0][i][i] = 1;
		}

		REP(i, 1, K) {
			rep(j, S) {
				rep(k, N) {
					REP(j2, k, N + 1) {
						dp[i][j + j2][max(k, j2)] += dp[i - 1][j][k];
					}
				}
			}
		}
		rep(i, K) rep(j, S) rep(k, N) {
			printf("dp[%d][%d][%d] = %d\n", i, j, k, dp[i][j][k]);
		}
		int sum = 0;
		rep(k, N+1) sum += dp[K - 1][S][k];
		cout << sum << endl;
	}

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define SUM(v) accumulate(ALL(v),0)

void solve(int n, int k, int s) {
    vector<int> v(n);
    rep(i,n) v[i] = i+1;

    int ans = 0;
    rep(mask, 1<<n) {
        vector<int> a;
        rep(i,n) if(mask&(1<<i)) a.push_back(v[i]);
        if(SZ(a) != k) continue;
        if(SUM(a) == s) ++ans;
    }

    cout << ans << "\n";
}

int main() {
    int n,k,s;
    while(cin>>n>>k>>s, n) solve(n,k,s);
    return 0;
}

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

// simple recursion
int rec(int n, int k, int s)
{
  if(s < 0) return 0;  // no answer
  if(k > n) return 0;  // less elements remain
  if(k == 0) return s == 0 ? 1 : 0; // 0 by 0?
  // using n, or not using n
  return rec(n-1, k-1, s-n) + rec(n-1, k, s);
}
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    if(k <= n) {
      cnt = rec(n, k, s);
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(void){
	int n,k,s;

	vector<vector<vector<int > > > a(21,vector<vector<int> >(11,vector<int>(156,0)));
	vector<vector<int> > b(21,vector<int>(2,0));
	for(int i=1;i<21;i++){
		b[i][1]=i;
	}
	int sum=0;
	for(int i=0;i<1024*1024;i++){
		int l=i;
		sum=0;
		int m=0;
		int count=0;
		bool flag=true;
		for(int j=1;j<21;j++){
			if(l%2==1){
				sum+=b[j][1];
				m=max(m,j);
				count++;
				if(count>10||sum>155){
					flag=false;
					break;
				}
			}
			l/=2;
		}
		if(flag){
			for(int j=m;j<21;j++){
			a[j][count][sum]++;
			}
		}
	}
	while(1){
		cin>>n>>k>>s;
		if(n==0)break;
		cout<<a[n][k][s]<<endl;
	}
	return 0;
}

C++: #include <cstdint>
#include <iostream>

using namespace std;

uint32_t comb(uint32_t n, uint32_t s, uint32_t i, uint32_t k, uint32_t sum) {
  if (k == 0 && s == sum) {
    return 1;
  } else if (i > n || k == 0) {
    return 0;
  } else {
    return comb(n, s, i + 1, k, sum) + comb(n, s, i + 1, k - 1, sum + i);
  }
}

int32_t main() {
  while (true) {
    uint32_t n, k, s;
    cin >> n >> k >> s;
    if (n == 0) break;
    cout << comb(n, s, 1, k, 0) << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
	int n,k,s;
	while(true){
	    cin>>n>>k>>s;
		if(n==0&&k==0&&s==0)
			break;
		int count=0;
		if(n==0&&k==0&&s==0)
			break;
		for(int i=0;i<pow(2.0,n+0.0);i++){
			int scount=0,kcount=0;
			int bit=i;
			for(int j=1;j<=n;j++){
				if((bit&1)==1){
					scount+=j;
					kcount++;
				}
				bit=bit>>1;
			}
			if(scount==s&&kcount==k)
				count++;
		}
		cout<<count<<endl;
	}
	return 0;
}