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>
using namespace std;
int dp[11][156];
int n,k,s;

void init(){
  for(int i=0;i<11;i++){
    for(int j=0;j<156;j++)dp[i][j]=0;
  }
  dp[0][0]=1;
}

int main(){

  while(1){
    cin>>n>>k>>s;
    if(n==0&&k==0&&s==0)break;
    init();
    for(int i=1;i<=k;i++){
      for(int j=1;j<=s;j++){
	if(j-i>=0)dp[i][j]+=dp[i][j-i];
	if(j-i>=0)dp[i][j]+=dp[i-1][j-i];
	if(j-n-1>=0)dp[i][j]-=dp[i-1][j-n-1];
      }
    }
    cout<<dp[k][s]<<endl;
  }
  return 0;
}

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

int n,k,s,ans;

void rec(int num,int kk,int sum){
  if(kk < 0 || sum < 0) return;

  if(kk == 0 && sum == 0){
    ans++; return;
  } 

  for(int i = num ; i >= 1 ; i--){
    rec(i-1,kk-1,sum-i);
  }

}

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

  return 0;
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n,k,s;
int bitcount(int S) {
    int res=0;
    rep(i,n+2) if((S>>i)&1) res++;
    return res;
}
void solve() {
    ll ans=0;

    rep(i, 1<<(n)) {
        int sum=0;
        if(bitcount(i)!=k) continue;
        rep(j,(n+1)) {
            if(j==0) continue;
            if((i>>(j-1))&1) sum+=j;
        }

        if(sum==s) ans++;
    }

    cout<<ans<<endl;


}

int main() {
    while(cin>>n>>k>>s) {
        if(n+k+s==0) break;
        solve();
    }
    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int memo[21][11][156];
int dfs(int n, int k, int s){
  if(s == 0 && k == 0) return 1;
  if(s <= 0 || n < 0 || k == 0) return 0;
  if(memo[n][k][s] >= 0) return memo[n][k][s];
  return (memo[n][k][s] = dfs(n-1, k, s) + dfs(n-1, k-1, s-n));
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  fill((int*)memo, (int*)memo+21*11*156, -1);
  while(true){
	int n, k, s; cin >> n >> k >> s;
	if(n == 0) break;
	cout << dfs(n,k,s) << endl;
  }
  
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int solve(int n, int k, int s, int m, const vi a) {
  if(n == 0) return (s == m) ? 1 : 0;
  int ans = 0;
  REP(i, k-1) {
    vi v = a;
    v.pb(i+1);
    ans += solve(n-1, i+1, s, m+i+1, v);
  }
  return ans;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, k, s; cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    vi a;
    cout << solve(k, n+1, s, 0, a) << endl;
  }
}

C++: #include<iostream>
#include<cstring>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;

int main(){
  int n,k,s;
  int dp[30][20][200];

  while(cin >> n >> k >> s,n||k||s){
    memset(dp,0,sizeof(dp));
    dp[0][0][0] = 1;

    rep(i,n){
      rep(j,k+1){
	rep(w,s+1){
	  dp[i+1][j][w] += dp[i][j][w];
	  if(j!=k && w+i+1<=s)dp[i+1][j+1][w+i+1] += dp[i][j][w];
	}
      }
    }

    cout << dp[n][k][s] << endl;
  }
}