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 <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int n, int k, int s) {
    LL ans = 0;
    REP(i, (1 << (n))) {
        int cnt = 0;
        int buf = 0;
        REP(j, n) if (i & (1 << j)) {
            cnt++; buf += j + 1;
        }
        if (buf == s && cnt == k) {
            ans++;
        }
    }
    cout << ans << endl;
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m >> p, n) {
        solve(n, m, p);
        //return 0;
    }
}

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

typedef tuple<int,int,int> T;
map<T,int> memo;

int dp(int n, int k, int s) {
  if (s < k || n < 1 || s < 1) {
    return 0;
  } else if (k == 1 && s <= n) {
    return 1;
  } else if (memo.find(make_tuple(n, k, s)) != memo.end()) {
    return memo[make_tuple(n, k, s)];
  } else {
    int ans = dp(n - 1, k, s - k) + dp(n - 1, k - 1, s - k);
    memo[make_tuple(n, k, s)] = ans;
    return ans;
  }
}

int main() {
  int n, k, s;
  while (cin >> n >> k >> s && n) {
    cout << dp(n, k, s) << endl;
  }
}

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

using namespace std;
int ans = 0,n;

void a( int t, int k, int s) {
 if (k==0&&s == 0) {
  ans++;
  return;
 }
 if (k == 0 || t > n)return;
 for (int i = t+1; i <= n; i++) {
  a( i, k - 1, s - i);
 }
 return;
}
int main() {
 int  k, s;
 while (1) {
  cin >> n >> k >> s;
  if (n == 0 && k == 0 && s == 0)break;
  ans = 0;
  a(0, k, s);
  cout << ans << endl;
 }
 return 0;
}

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

using namespace std;

int n, k, s;
int ret;

void f(int m, int num, int sum){
    if(num == k && sum == s)ret++;
    else if(s <= sum || k <= num) return;
    else {
        for(int i=m; i <= n; i++){
            f(i+1, num+1, sum+i);
        }
    }
}

int main(){
    while(cin >> n >> k >> s, n+k+s){
        ret = 0;
        for(int i=1; i <= n; i++){
            f(i+1, 1, i);
        }
        cout << ret << endl;
    }
}

C++: #include <numeric>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
    int n,k,s,i,c,res;
    while(1){
        scanf("%d",&n);
        scanf("%d",&k);
        scanf("%d",&s);
        if(!n && !k && !s){break;}
        vector<int> t(n,0);
        int cd[n];
        iota(cd,cd+n,1);
        for(i=0;i<k;i++){t[n-i-1]=1;}    
        res=0;
        do{
            c=0;
            for(i=0;i<n;i++){c+=(t[i]*cd[i]);}
            if(c==s){res++;}
        } while(next_permutation(t.begin(),t.end()));
        printf("%d\n",res);
    }
    return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, k, s;
    while (cin >> n >> k >> s && n){
        int comb = (1 << k) - 1;
        int ans = 0;
        while (comb < (1 << n)){
            int p = 0;
            REP(i,n){
                if ((comb >> i) & 1) p += i + 1;
            }
            if (p == s) ans++;
            int x = comb & -comb, y = comb + x;
            comb = ((comb & ~y) / x >> 1) | y;
        }
        cout << ans << endl;
    }
    return 0;
}