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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, K, s;
ll dp[30][100][200];

int main() {
	while (cin >> n >> K >> s&&n + K + s) {
		REP(i, 30)REP(j, 100)REP(k, 200)dp[i][j][k] = 0;
		dp[0][0][0] = 1;
		REP(i, n) {
			REP(j, 100) {
				REP(k, 200) {
					dp[i + 1][j][k] += dp[i][j][k];
					dp[i + 1][j][k] %= INF;
					dp[i + 1][j + 1][k + (i + 1)] += dp[i][j][k];
					dp[i + 1][j + 1][k + (i + 1)] %= INF;
				}
			}
		}
		cout << dp[n][K][s] << endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int n, k, s;
int dfs(int m, int sum, int d) {
  //cout << m << " " << sum << " " << d << endl;
  if(!m) {
    if(!sum) return 1;
    else return 0;
  }

  int res = 0;
  FOR(i, d, n+1) {
    res += dfs(m-1, sum-i, i+1);
  }

  return res;
}

signed main(void)
{
  while(true) {
    cin >> n >> k >> s;
    if(!n && !s && ! k) break;
    cout << dfs(k, s, 1) << endl;
  }
  return 0;
}

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

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;

vector<bool> num(21, false);

int search(int n, int k, int s);

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

int search(int n, int k, int s)
{
    int ret = 0;
    if (k > 1) {
        for (int i = n; i > 0; i--) {
            if (i < s) {
                ret += search(i-1, k-1, s-i);
            }
        }
    } else {
        if (0 <= s && s <= n) {
            return 1;
        } else {
            return 0;
        }
    }
    return ret;
}

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

#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;

int solve(int now,int pre,int d,int n,int k,int s){
	if(now>s ||d>k)return 0;
	if(now==s && d==k)return 1;
	int re=0;
	FOR(i,pre+1,n+1)re+=solve(now+i,i,d+1,n,k,s);
	return re;
}

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

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;
    }
    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;
}