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 <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, k, s;
    while(cin >> n >> k >> s, n){
        auto dp = make_v(k+1, 300, n+1, 0);
        dp[0][0][0] = 1;
        for (int i = 0; i < k; ++i) {
            for (int j = 0; j < 220; ++j) {
                for (int l = 0; l <= n; ++l) {
                    for (int m = l+1; m <= n; ++m) {
                        dp[i+1][j+m][m] += dp[i][j][l];
                    }
                }
            }
        }
        int ans = 0;
        for (int l = 1; l <= n; ++l) {
            ans += dp[k][s][l];
        }
        cout << ans << "\n";
    }
    return 0;
}

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

int a,b,c;
int np;
int ans=0;

int dfs(int x,int d){
	d++;
	if(d<b){
		for(int i=x+1;i<=a;i++){
			np+=i;
			dfs(i,d);
			np-=i;
		}
	}else{
		if(np==c)ans++;
	}
	return 0;
}

int main(){
	while(cin>>a>>b>>c){
		ans=0;
		if(a==0&&b==0&&c==0)break;
		for(int i=0;i<=a;i++){
			np=i;
			dfs(i,0);
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int main(){
    int n,k,s;
    while(cin >> n >> k >> s){
        if(n == 0 && k == 0 && s == 0) break;
        int dp[30][30][200]={};
        for(int i=0; i<=n; i++) dp[i][0][0] = 1;

        for(int i=1;  i<=n; i++){
            for(int j=1; j<=k; j++){
                for(int l=0; l<=s; l++){
                    if(l < i) dp[i][j][l] = dp[i-1][j][l];
                    else dp[i][j][l] = dp[i-1][j][l] + dp[i-1][j-1][l-i];
                }
            }
        }
        cout << dp[n][k][s] << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdint>
#include <vector>

int testcase_ends() {
  int n, k, s;
  scanf("%d %d %d", &n, &k, &s);
  if (n == 0 && k == 0 && s == 0) return 1;

  int res = 0;
  for (int i = 0; i < (1 << n); ++i) {
    if (__builtin_popcount(i) != k) continue;
    int cur = 0;
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) cur += j+1;
    }
    if (cur == s) ++res;
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dp[32][16][256];

int dfs(int n, int k, int s){
  if(n==0){
    if(s==0&&k==0) return 1;
    return 0;
  }
  int &res = dp[n][k][s];
  if(res>=0) return res;
  res = 0;
  if(k && s>=n) res += dfs(n-1,k-1,s-n);
  res += dfs(n-1,k,s);
  return res;
}

int main(){
  int N,K,S;
  while(scanf("%d%d%d",&N,&K,&S) && N+K+S){
    memset(dp, -1, sizeof(dp));
    printf("%d\n", dfs(N,K,S));
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

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

int main(){
    int n,k,s,i,j,c,res;
    while(1){
        scanf("%d",&n);
        scanf("%d",&k);
        scanf("%d",&s);
        if(!n && !k && !s){break;}
        vector<int> t(n,0);
        vector<int> cd(n);
        iota(cd.begin(),cd.end(),1);
        for(i=0;i<k;i++){t[n-i-1]=1;}    
        res=0;
        do{
            c=0;
            for(i=0;i<n;i++){c+=(t[i]*cd[i]);}
            if(c==s){res++;}
        } while(next_permutation(t.begin(),t.end()));
        printf("%d\n",res);
    }
    return 0;
}