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 <vector>
using namespace std;

int dp[21][11][156];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,k,s;
	while(cin >> n >> k >> s,n){
		vector<vector<vector<int> > > dp(n+1,vector<vector<int> >(k+1,vector<int>(s+1,0)));
		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 = 1;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 <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int dfs(int n,int k,int l,int s){
	//dbg(k); dbg(l); dbg(s);
	if(k==0&&s==0)return 1;
	if(s<0||k*n<s)return 0;
	int res=0;
	repl(i,l,n+1){
		res+=dfs(n,k-1,i+1,s-i);
	}
	return res;
}

int n,k,s;
int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>k>>s;
		if(n==0)break;
		cout<<dfs(n,k,1,s)<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	ll n,k,s;	//1 &#8804; n &#8804; 20, 1 &#8804; k &#8804; 10 and 1 &#8804; s &#8804; 155
	while(cin >> n>>k>>s && !(n==0 && k==0 && s==0))
	{
		ll a[11][21][156]={}; //i回目に最大値xで合計sになるもの
		a[0][0][0]=1;
	
		for(int i=0;i<k;i++)//i回目
		{
			for(int j=0;j<n+1;j++)//最大値jで
			{
				for(int l=0;l<s;l++)//合計lの配列から次がどう定義されるか
				{
					for(int m=j+1;m<n+1;m++)
					{
						if(l+m<=s)
						{
							a[i+1][m][l+m]+=a[i][j][l];
						}
					}
				}
			}
		}
		
		ll ans(0);
		REP(i,n+1){ans+=a[k][i][s];}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int Con(int n, int k, int s){
	if(s < 0) return 0;
	if(k > n) return 0;
	if(k == 0) return s == 0 ? 1 : 0;
	return Con(n - 1, k - 1, s - n) + Con(n - 1, k, s);
}

int main (){
	int n, k, s;

	while (1) {
		scanf("%d %d %d", &n, &k, &s);
		if(n == 0 && k == 0 && s == 0)
			return 0;
		printf("%d\n", Con(n, k, s));
	}
}

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

int cnt;

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

int main()
{
    int n, k, s;
    while (cin >> n >> k >> s, n) {
        cnt = 0;
        for (int i = n; i * k > s; --i) {
            countSet(i, k, s);
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#define INF (1<<30)
#define mm 100005
#define clr(A) memset(A,0,sizeof(A))
using namespace std;
typedef long long LL;
int A[25][12][160];

int main()
{
    //freopen("BUAA.in","r",stdin);
    //int T;
    clr(A);
    for(int i = 0;i<=20;i++)A[i][0][0] = 1;

    for(int i = 1;i<=20;i++)
    for(int j = 1;j<=10;j++)
    for(int k = (i+1)*i/2;k>=0;k--)
    {
        A[i][j][k] = A[i-1][j][k];
        if(k>=i)A[i][j][k]+=A[i-1][j-1][k-i];
    }
    int n,k,s;
    while(~scanf("%d%d%d",&n,&k,&s) && n+k+s!=0)
    {
        printf("%d\n",A[n][k][s]);
    }
    return 0;
}