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;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> int least_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_ffs(n) - 1;
  if (sizeof(T) == 8) return __builtin_ffsll(n) - 1;
}

// n must be greater than 0.
template<typename T> int least_bit_fast(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_ctz(n);
  if (sizeof(T) == 8) return __builtin_ctzll(n);
}

template<typename T> int most_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return n ? 31 - __builtin_clz(n) : -1;
  if (sizeof(T) == 8) return n ? 63 - __builtin_clzll(n) : -1;
}

template<typename T> int count_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_popcount(n);
  if (sizeof(T) == 8) return __builtin_popcountll(n);
}

class BitIterator : public iterator<input_iterator_tag, int> {
public:

  class Iterator : public iterator<input_iterator_tag, int> {
  private:
    int val, bit;

  public:
    Iterator(int val, int bit) : val(val), bit(bit) {}

    Iterator operator*() {return *this;}

    bool operator!=(const Iterator& itr) const {return val != itr.val;}

    void operator++() {val = least_bit(bit & -(1 << (val + 1)));}

    operator int() {return val;}
  };
  
  Iterator i, n;
  int bit;

  BitIterator(int n) : i(least_bit(n), n), n(-1, n), bit(n) {}

  bool operator!=(const BitIterator& itr) const {return i != itr.i;}

  void operator++() {*this = BitIterator(bit + 1);}

  operator int() const {return bit;}

  bool in(int i) const {return bit & (1 << i);}

  Iterator& begin() {return i;}

  Iterator& end() {return n;}
};

class FixSizeSet {
private:
  struct Iterator : public iterator<input_iterator_tag, int> {
  private:
    BitIterator val, n;

  public:
    Iterator(int val, int n) : val(val), n(n) {}

    Iterator operator*() {
      return *this;
    }

    bool operator!=(const Iterator& itr) const {
      return n != itr.n;
    }

    void operator++() {
      int x = val & -val, y = val + x;
      val = ((val & ~y) / x / 2) | y;
      if (val >= (1 << n)) n = 0;
    }

    operator int() const {
      return val;
    }

    bool in(int i) const {
      return val.in(i);
    }

    BitIterator::Iterator& begin() {
      return val.begin();
    }

    BitIterator::Iterator& end() {
      return val.end();
    }
  };
  
  Iterator i, n;

public:
  FixSizeSet(int n, int k) : i((1 << k) - 1, n), n(0, 0) {}

  Iterator& begin() {
    return i;
  }

  Iterator& end() {
    return n;
  }
};

int main() {
  while (true) {
    int n, k, s, res = 0;
    cin >> n >> k >> s;
    if (n == 0 && k == 0 && s == 0) break;
    for (auto iter : FixSizeSet(n, k)) {
      int sum = 0;
      for (auto i : iter) sum += i + 1;
      if (sum == s) ++res;
    }
    cout << res << endl;
  }
}

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    while(true){
        ll n,k,s;
        cin>>n>>k>>s;
        if(n==0) break;
        ll ans=0;
        for(int i=0;i<(1<<n);i++){
            ll sum=0,cnt=0;
            for(int j=0;j<n;j++){
                if(i>>j&1){
                    cnt++;
                    sum+=j+1;
                }
            }
            if(cnt==k&&sum==s) ans++;
        }
        cout<<ans<<'\n';
    }
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int nks[21][11][156];

void br(){
	int s, t;
	for(int i=1; i<=20; i++){
		for(int j=0; j < (1<<i);j++){
			s = 0;
			t = 0;
			for(int k=0; k < i;k++){
				if(j&(1<<k)){
					s+=(k+1);
					t++;
				}
			}
			if(s<=155 && t<=10) nks[i][t][s]++;
		}
	}
}

int main(){
	int i, j, n, k, s;
	br();
	while(1){
		cin >> n >> k >> s;
		if(!n)break;
		cout << nks[n][k][s] << endl;
	}
	return 0;
}

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

long long int saiki( long long int N, long long int K, long long int S, long long int now ) {
	if( K == 0 ) {
		return S == 0;
	}
	long long int ret = 0;
	for( long long int i = now + 1; i <= N&&S - i >= 0; i++ ) {
		ret += saiki( N, K - 1, S - i, i );
	}
	return ret;
}

int main() {
	long long int N, K, S;
	while( cin >> N >> K >> S, N || K || S ) {
		cout << saiki( N, K, S, 0 ) << endl;
	}
}