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;
using ll = long long;
using pii = pair<int, int>;

int N, K, S;
ll dp[25][25][160];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> N >> K >> S, N) {
    fill_n((ll*)dp, 25*15*160, 0);
    for (int i = 1; i <= N; i++) {
      dp[1][i][i] = 1;
    }
    for (int i = 1; i < K; i++) {
      for (int j = 1; j <= N; j++) {
        for (int k = i; k <= S; k++) {
          for (int l = j+1; l <= N && k+l <= S; l++) {
            dp[i+1][l][k+l] += dp[i][j][k];
          }
        }
      }
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
      ans += dp[K][i][S];
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>

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

using namespace std;

int dp[21][11][160];
int dfs(int n, int k, int s){
	if(k == 0) return s == 0; 

	int &res = dp[n][k][s];
	if(res >= 0) return res;

	res = 0;
	for(int i = n; i >= k; i--){
		res += dfs(i-1, k-1, s-i);
	}

	return res;
}

int main(){
	int n, k, s;
	memset(dp, -1, sizeof(dp));
	while(cin >> n >> k >> s, n|k|s){
		cout << dfs(n, k, s) << endl;
	}


	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
using namespace std;

int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a || b || c) {
		int s = 0;
		for (int d = 1; d < (1 << a); d++) {
			int g = 0, h = 0;
			for (int e = 1, f = 1; e <= a; e++, f <<= 1) {
				if (d&f) {
					g++;
					h += e;
				}
			}
			if (g == b&&c == h)s++;
		}
		cout <<s<< endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define rd(a) cin>>(a)
#define RD(a,b) cin>>(a)>>(b)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int ans=0;

void solve(int k, int n, int p) {
  if(n==0 && k==0) ans++;
  if(k<0 || n==0) return;
  rrep(i,p) solve(k-i-1,n-1,i);
}
int main() {
  int n,m,k;
  while(cin >> n >> m >> k && (n||m||k)) {
    ans=0;
    solve(k,m,n);
    pr(ans);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int n, k, s;
	while ( cin >> n >> k >> s, n || k || s ) {
		int dp[11][21][200] = {0}; // dp[???????????£??????][???????????????][????¨?] = ??´????????°
		dp[0][0][0] = true;
		for (int i = 0; i < k; ++i) {
			for (int last = 0; last <= n; ++last) {
				for (int use = last+1; use <= n; ++use) {
					for (int sum = 0; sum <= 155; ++sum) {
						dp[i+1][use][sum+use] += dp[i][last][sum];
					}
				}
			}
		}
		int ans = 0;
		for (int last = 0; last <= n; ++last) {
			ans += dp[k][last][s];
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <iostream>
using namespace std;
int n,k,s,flg,cnt;

void saiki(int kai,int sum,int p) {
  if(kai == k && sum == s) cnt++;
    if(kai < k && sum < s) {
      for(int i=p+1;i<=n;i++) saiki(kai+1,sum+i,i);	
    }
}

int main() {

  while(1) {
  cin >> n >> k >> s;
  if(n==0 && k==0 && s==0) break;
  cnt = 0;
  saiki(0,0,0);
  cout << cnt <<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>

int count(const int n, const int k, const int sum) {
	static std::vector<std::vector<std::vector<int>>> memo(21, std::vector<std::vector<int>>(11, std::vector<int>(156, -1)));
	if (k == 0) return (sum == 0) ? 1 : 0;
	if (n == 0) return 0;
	if (sum <= 0) return 0;
	if (memo[n][k][sum] == -1) {
		memo[n][k][sum] = count(n - 1, k, sum);
		if (sum >= n) {
			memo[n][k][sum] += count(n - 1, k - 1, sum - n);
		}
	}
	return memo[n][k][sum];
}
int main() {
	while (true) {
		int n, k, s; std::cin >> n >> k >> s;
		if (n == 0) return 0;
		std::cout << count(n, k, s) << std::endl;
	}
}

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

int main()
{
	int n, k, s, res;
	while (cin >> n >> k >> s, n || k || s) {
		res = 0;
		for (int i = 0; i < (1 << n); i++) {
			int dec = 0;
			for (int j = 1; j <= i; j <<= 1) {
				if (j & i)
					dec++;
			}
			int da = 0;
			if (dec == k) {
				for (int j = 0; 1 << j <= i; j++)
					if ((1 << j) & i)
						da += j + 1;
				if (da == s)
					res++;
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

int dp[21][11][156] = {0};

int main(){
    int n,k,s;
    for(int i=1;i<21;++i)
            dp[i][1][i] = 1;
    for(int i=1;i<21;++i){
        for(int j=1;j<11;++j){
            for(int l=1;l<156;++l){
                dp[i][j][l] += dp[i-1][j][l];
                if(l - i > 0)
                    dp[i][j][l] += dp[i-1][j-1][l-i];
            }
        }
    }
    while(scanf("%d %d %d",&n,&k,&s), n != 0 || k != 0 || s != 0){
        printf("%d\n",dp[n][k][s]);
    }

    return 0;
}