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 <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
    while (true) {
        int n, k, s;
        cin >> n >> k >> s;
        if (n == 0 and k == 0 and s == 0) {
            break;
        }
        if (s < n) {
            cout << 0 << endl;
            continue;
        }
        vector<vector<int>> dp(n + 1, vector<int>(s + 1, 0));  // ?????????i??§??????j
        for (int i = 1; i <= n; i++) {
            dp[i][i] = 1;
        }
        for (int l = 1; l < k; l++) {
            auto tmp = dp;
            fill(dp.begin(), dp.end(), vector<int>(s + 1, 0));
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= s; j++) {
                    if (tmp[i][j] > 0) {
                        for (int m = i + 1; m <= min(n, s - j); m++) {
                            dp[m][j + m] += tmp[i][j];
                        }
                    }
                }
            }
        }
        int sum = 0;
        for (int i = 0; i <= n; i++) {
            sum += dp[i][s];
        }
        cout << sum << endl;
    }

    return 0;
}

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

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

int dp[22][11][160] = {};
int dfs(int n, int k, int s) {
	if (n == s&&k == 1) { return 1; }
	if (n <= 0)return 0;
	if (k <= 0)return 0;
	if (s <= 0)return 0;
	if (dp[n][k][s] != -1)return dp[n][k][s];
	int ret = 0;
	rep(i, 1, n) {
		ret += dfs(i, k - 1, s - n);
	}
	return dp[n][k][s] = ret;
}

signed main() {
	for (int n, k, s; cin >> n >> k >> s&&n;) {
		memset(dp, -1, sizeof(dp));
		int ans = 0;
		rep(i, 1, n + 1)ans += dfs(i, k, s);
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#define N 20
using namespace std;
int n,k,s,C;
void Ess(int,int,int);
int main(){
  bool r;
  while(1){
    cin >> n >> k >> s;
    if(n==0&&k==0&&s==0) break;
    C=0;
    Ess(0,0,0);
    cout << C << endl;
  }
  return 0;
}
void Ess(int x,int sum,int cnt){
  if(n==x){
    if(cnt==k&&sum==s) C++;
    return ;
  }
  Ess(x+1,sum,cnt);
  Ess(x+1,sum+x+1,cnt+1);
  return ;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int dp[30][20][200];
int main() {
	int N, K, S;
	while (scanf("%d%d%d", &N, &K, &S), N) {
		memset(dp, 0, sizeof(dp));
		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 k = 0; k <= S; k++) {
					if (k < i)dp[i][j][k] = dp[i - 1][j][k];
					else dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - i];
				}
			}
		}
		printf("%d\n", dp[N][K][S]);
	}
}

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

void print(int arr[], int n) {
	for(int i = 0; i < n; i++)
		cout << arr[i] << ' ';
	cout << '\n';
}

int main(void) {
	int n, k, s;
	while(cin >> n >> k >> s, n || k || s) {
		int arr[k];
		long ans = 0;
		for(int i = 0; i < k; i++)
			arr[i] = i+1;
		while(1) {
			//print(arr, k);
			long sum = 0;
			for(int i = 0; i < k; i++)
				sum += arr[i];
			if(sum == s)
				ans++;
			int i;
			for(i = k - 1; i >= 0; i--)
				if(arr[i] < n && arr[i] + k - i - 1 < n) {
					arr[i]++;
					break;
				}
			if(i < 0)
				break;
			for(int j = i + 1; j < k; j++)
				arr[j] = arr[j - 1] + 1;
		}
		cout << ans << '\n';
	}
}

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

int main()
{
  int n,k,s,i,j,l,m,o,p,q,r,t,u,sum,ans;

  for(;;){
    cin>>n>>k>>s;
    if(!(n|k|s)) break;

    ans=0;
    if(k>0){
      for(i=1;i<=n-k+1;i++){
	sum=i;
	if(sum>s) break;
	if(sum==s&&k==1){
	  ans++; break;
	}
	if(k>1){
	  for(j=i+1;j<=n-k+2;j++){
	    sum=i+j;
	    if(sum>s) break;
	    if(sum==s&&k==2){
	      ans++; break;
	    }
	    if(k>2){
	      for(l=j+1;l<=n-k+3;l++){
		sum=i+j+l;
		if(sum>s) break;
		if(sum==s&&k==3){
		  ans++; break;
		}
		if(k>3){
		  for(m=l+1;m<=n-k+4;m++){
		    sum=i+j+l+m;
		    if(sum>s) break;
		    if(sum==s&&k==4){
		      ans++; break;
		    }
		    if(k>4){
		      for(o=m+1;o<=n-k+5;o++){
			sum=i+j+l+m+o;
			if(sum>s) break;
			if(sum==s&&k==5){
			  ans++; break;
			}
			if(k>5){
			  for(p=o+1;p<=n-k+6;p++){
			    sum=i+j+l+m+o+p;
			    if(sum>s) break;
			    if(sum==s&&k==6){
			      ans++; break;
			    }
			    if(k>6){
			      for(q=p+1;q<=n-k+7;q++){
				sum=i+j+l+m+o+p+q;
				if(sum>s) break;
				if(sum==s&&k==7){
				  ans++; break;
				}
				if(k>7){
				  for(r=q+1;r<=n-k+8;r++){
				    sum=i+j+l+m+o+p+q+r;
				    if(sum>s) break;
				    if(sum==s&&k==8){
				      ans++; break;
				    }
				    if(k>8){
				      for(t=r+1;t<=n-k+9;t++){
					sum=i+j+l+m+o+p+q+r+t;
					if(sum>s) break;
					if(sum==s&&k==9){
					  ans++; break;
					}
					if(k>9){
					  for(u=t+1;u<=n;u++){
					    sum=i+j+l+m+o+p+q+r+t+u;
					    if(sum>s) break;
					    if(sum==s){
					      ans++; break;
					    }
					  }
					}
				      }
				    }
				  }
				}
			      }
			    }
			  }
			}
		      }
		    }
		  }
		}
	      }	  
	    }
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
}