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 pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

ll dp[15][21][160] = {{{}}};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,s;
  dp[0][0][0] = 1;
  rep(j,21){
    rep(i,11){
      rep(k,155){
        dp[i+1][j+1][k+j+1] += dp[i][j][k];
        dp[i][j+1][k] += dp[i][j][k];
      }
    }
  }
  while(cin >> n >> k >> s && n + k + s){
  /* rep(i,5){                            */
  /*   rep(j,k+1){                        */
  /*     rep(l,s+1){                      */
  /*         cout << dp[i][j][l] <<  ' '; */
  /*       }                              */
  /*       cout << endl;                  */
  /*     }                                */
  /*     cout << endl;                    */
  /*   }                                  */
    cout << dp[k][n][s] << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  int n, k, s, ans, t, u;
  while (cin >> n >> k >> s, n) {
    int A[k];
    if (k == 1) {
      if (n >= s) cout << 1 << endl;
      else cout << 0 << endl;
      continue;
    }
    for (int i = 0; i < k-1; ++i) A[i] = i+1;
    A[k-1] = s - k*(k-1)/2;
    ans = 0;
    t = k-2;
    while (A[k-1] > A[k-2]) {
      if (A[k-1] <= n) ++ans;
      ++A[t];
      --A[t+1];
      if (A[t] >= A[t+1]) {
	while (t > 0) {
	  --t;
	  ++A[t];
	  u = 0;
	  for (int i = 0; i <= t; ++i) u += A[i];
	  for (int i = t+1; i < k-1; ++i) {
	    A[i] = A[i-1]+1;
	    u += A[i];
	  }
	  A[k-1] = s - u;
	  if (A[k-1] > A[k-2]) {
	    t = k-2;
	    break;
	  }
	}
	if (!t) break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
int main(){
	int n,m,s;
	while(cin>>n>>m>>s,n){
		int sum=0;
		r(a,1,n){if(m==1&&s==a)sum++;
			if(m>1)r(b,a+1,n){if(m==2&&s==a+b)sum++;
				if(m>2)r(c,b+1,n){if(m==3&&s==a+b+c)sum++;
					if(m>3)r(d,c+1,n){if(m==4&&s==a+b+c+d)sum++;
						if(m>4)r(e,d+1,n){if(m==5&&s==a+b+c+d+e)sum++;
							if(m>5)r(f,e+1,n){if(m==6&&s==a+b+c+d+e+f)sum++;
								if(m>6)r(g,f+1,n){if(m==7&&s==a+b+c+d+e+f+g)sum++;
									if(m>7)r(h,g+1,n){if(m==8&&s==a+b+c+d+e+f+g+h)sum++;
										if(m>8)r(i,h+1,n){if(m==9&&s==a+b+c+d+e+f+g+h+i)sum++;
											if(m>9)r(j,i+1,n){if(m==10&&s==a+b+c+d+e+f+g+h+i+j)sum++;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		cout<<sum<<endl;
	}
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;


int n, k, s;
int ans;


void calc(int sum, int b, int e){
	if(sum > s){
		return;
	}
	if(e == k){
		if(sum == s) ans++;
		return;
	}
	for(int i = b + 1; i + sum <= s && i <= n; i++){
		calc(sum + i, i, e + 1);
	}
}

int main(){
	while(cin>>n>>k>>s){
		if(n == 0 && k == 0 && s == 0) break;
		ans = 0;
		calc(0, 0, 0);
		cout<<ans<<endl;
	}
}

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

void solve(int n,int k,int s,int sum){
  if(sum==s&&k==0){
    cnt++;
    return;
  }
  if(k==0) return; 
  for(int i=n;i>=k;--i){
    solve(i-1,k-1,s,sum+i);
  }
  return ;
}

int main(){
  int n,k,s;
  while(cin>>n>>k>>s&&n){
    int sum=0;
    cnt=0;
    solve(n,k,s,sum);
    cout<<cnt<<endl;
  }

  return EXIT_SUCCESS;
}

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

#define N_MAX 20
#define K_MAX 10
#define S_MAX 155

int dp[N_MAX + 1][K_MAX + 1][S_MAX + 1] = {};

int main() {
  
  for (int i = 0; i <= N_MAX; i++){
    dp[i][0][0] = 1;
  }

  for (int n = 1; n <= N_MAX; n++) {
    for (int k = 1; k <= K_MAX; k++) {
      for (int s = 1; s <= S_MAX; s++) {

	dp[n][k][s] +=
	  (s - n < 0 ? 0 : dp[n-1][k-1][s-n]) +
	  dp[n - 1][k][s];
	/*
	if(n <= 2 && k <= 1 && s <= 10){
	  cout << n << ", " << k << ", " << s << ", " << dp[n][k][s] << endl;
	}
	*/
      }
    }
  }

  while( true ) {

    int n, k, s;
    cin >> n >> k >> s;
    if ( n == 0 ) break;

    cout << dp[n][k][s] << endl;

  }

  return 0;

}