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 <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <stack>
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define E exp(double(1))
#define maxn 110000
#define eps 1e-7
using namespace std;

#ifdef __int64
    typedef __int64 LL;
#else
    typedef long long LL;
#endif

int cnt;
int n , k , s;

void gao(int tk,int ts,int t)
{
    int temp;
	for(int i = t;i <= ts/tk + 1; i ++)
    {
		if(tk != 1 && (ts - i)/(tk - 1) <= n)
		{
			temp = i + 1;
			gao(tk - 1, ts - i,temp);
        }
		if(tk == 1 && ts >= t && ts <= n)
		{
			cnt ++;
			return ;
		}
	}
}

int main()
{
	while(scanf("%d%d%d",&n,&k,&s))
    {
		if(n == 0 && k == 0 && s == 0)
			break;
		else
		{
			if((s / k >= n)||(k*(k-1)/2>s))
            {
				printf("0\n");
				continue;
			}
			else
			{
				cnt = 0;
				gao(k,s,1);
				printf("%d\n",cnt);
			}

		}
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,k,s;
int dfs(int pos,int sum,int cnt){
    if(pos>n){
        if(cnt==k&&sum==s)return 1;
        else return 0;
    }
    return dfs(pos+1,sum,cnt)+dfs(pos+1,sum+pos,cnt+1);
}
int main(){
    while(cin>>n>>k>>s,n||k||s){
        cout<<dfs(1,0,0)<<endl;
    }
    return 0;
}

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

int solve(int n, int k, int s, vector<int> v) {
  if ((int)v.size() == k) {
    /*
    for (auto x : v) {
      cerr << x << " ";
    }
    cerr << endl;
    */
    int sum = accumulate(v.begin(), v.end(), 0);
    if (sum == s) {
      return 1;
    } else {
      return 0;
    }
  }
  int start = (v.empty() ? 0 : v[v.size()-1]);
  int ans = 0;
  for (auto i = start+1; i <= n; i++) {
    vector<int> nv;
    copy(v.begin(), v.end(), back_inserter(nv));
    nv.push_back(i);
    ans += solve(n, k, s, nv);
  }
  return ans;
}

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

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int dp[11][156];

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        int N, K, S; cin >> N >> K >> S;
        if (!N) break;

        rep(i, 0, 11) rep(j, 0, 156) dp[i][j] = 0;
        dp[0][0] = 1;
        rep(i, 1, N + 1) {
            for (int j = K - 1; j >= 0; j--) {
                for (int k = S - 1; k >= 0; k--) {
                    if (k + i <= S)
                        dp[j + 1][k + i] += dp[j][k];
                }
            }
        } 
        cout << dp[K][S] << endl;
    }
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1) {
    int n,k,s;
    cin>>n>>k>>s;
    if(!n)break;
    vector<vector<vector<int>>> dp(k+1, vector<vector<int>>(n+1, vector<int>(s+n+1)));
    dp[0][0][0] = 1;
    REP(i,k) {
      REP(j,n+1) {
        REP(l,s)
          for(int m=j+1;m<=n;++m)
            dp[i+1][m][l+m] += dp[i][j][l];
      }
    }
    int sum = 0;
    REP(i,n+1) sum += dp[k][i][s];
    cout << sum << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int counter(int n, int k, int s);

int main()
{
	int n, k, s;
	while(1){
		cin >> n >> k >> s;
		if(n == 0 && k == 0 && s == 0) break;
		int next_s = s - n, cnt = 0;
		cnt = counter(n, (k - 1), next_s);
		cout << cnt << endl;
	}
	return 0;
}

int counter(int n, int k, int s)
{
	int ans = 0;
	if(k > 1){
		for(int i = n - 1; i > 1; i--){
			ans += counter(i, (k - 1), (s - i));
		}
	} else if(k == 1){
		if(s < n && 0 < s) ans = 1;
		else ans = 0;
	}
	return ans;
}