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 <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

int n, k, s;

ll solve(int c, int dk, int sum) {
	if(dk == k) {
		if(sum == s) {
			return 1LL;
		} else {
			return 0LL;
		}
	}
	ll res = 0;
	for(int i=c; i<=n && i<=s-sum; i++) {
		res += solve(i+1, dk+1, sum+i);
	}
	return res;
}

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

C++: #include<iostream>
#include<vector>
using namespace std;
const int N = 20;
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    for(int i = 0; i < 1<<n; i++) {
      int c = 0;
      int ss = 0;
      for(int j = 1, x = 1; j <= i; j<<=1, x++) {
        if(i & j) { c++; ss+=x; }
      }
      if(c == k && s == ss) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
const int N = 20;
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    for(int i = 0; i < 1<<n; i++) {
      int c = 0, ss = 0;
      for(int j = 0; j < n; j++) {
        if(i & (1<<j)) { c++; ss+=(j+1); }
      }
      if(c == k && s == ss) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int n,k,s,ans;

void A(int r,int p,int q){
	if(r==k){
		if(q==s)ans++;
		return;
	}
	for(int i=p+1;i<=n;i++) A(r+1,i,q+i);
}

int main(){
	while(scanf("%d%d%d",&n,&k,&s),n||k||s){
		ans=0;A(0,0,0);printf("%d\n",ans);
	}
}

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

#define int long long
 
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;
}
 
signed 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 <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int memo[21][11][156];

// try to use from bigger number
int search(int n, int k, int s){
  if(memo[n][k][s]!=-1) return memo[n][k][s];

  if(k==1){
    if(n>=s) return 1;
    else return 0;
  }
  int res=0;
  for(int i=min(n,s-1); i>1; i--){
    // use i
    res += search(i-1, k-1, s-i);
  }
  memo[n][k][s]=res;
  return res;
}

int main(){
  rep(i,21) rep(j,11) rep(k,156) memo[i][j][k]=-1;

  int n,k,s;
  while(scanf("%d %d %d", &n, &k, &s), n|k|s){
    cout<<search(n,k,s)<<endl;
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

// dp[i][j][s]: i番目でjより大きい数を選べ，和がsのとき，最終的にsにできる個数
int dp[10][21][156];

int N, K, S;
int rec(int index, int x, int s){
    if(index == K){return s == S;}
    if(dp[index][x][s] != -1){return dp[index][x][s];}

    int res = 0;
    FOR(i, x+1, N+1){
        if(s + i <= S){
            res += rec(index+1, i, s+i);
        }
    }

    return dp[index][x][s] = res;
}

int main(){
    while(std::cin >> N >> K >> S, N || K || S){
        std::fill(dp[0][0], dp[0][0]+10*21*156, -1);
        std::cout << rec(0, 0, 0) << std::endl;
    }
}

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

using namespace std;

int f(int p, int t, int n, int k, int s)
{
    if(k==0) return t==s ? 1 : 0;
    if(t>s) return 0;
    int res = 0;
    for(int i=p+1; i<=n; i++) res += f(i, t+i, n, k-1, s);
    return res;
}

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