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 <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int n,s,k,ans;
void dfs(int cnt,int sum,int beg){
    if(sum==s&&cnt==k){ans++; return;}
    else if(cnt >k || s<sum)return;
    for(int i=beg+1; i<=n;i++)dfs(cnt+1,sum+i,i);
    return ;
}
int main(){
    while(cin>>n>>k>>s,n+s+k){
        dfs(0,0,0);
        cout<<ans<<endl;
        ans=0;
    }
}

C++: #include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>


using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T, class BinaryOperation>
constexpr T fold(std::initializer_list<T> args, T init, BinaryOperation op)
{
    return std::accumulate(args.begin(), args.end(), init, op);
}

// numeric_low
namespace numeric
{
    template<class T>
    constexpr T gcd(const T x, const T y)
    {
        if (x < 0)return gcd(-x, y);
        if (y < 0)return gcd(x, -y);
        return (!y) ? x : gcd(y, x % y);
    }

    template<class T>
    constexpr T lcm(const T x, const T y)
    {
        if (x < 0)return lcm(-x, y);
        if (y < 0)return lcm(x, -y);
        return x * (y / gcd(x, y));
    }
}

template <class... Args>
std::size_t hash(Args... args)
{
    return fold({ static_cast<std::size_t>(args)... }, 0_sz,
        [](std::size_t seed, std::size_t x)
        {
            // uses magic number from boost
            return seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        });
}

template <class Begin, class End>
void printAll(Begin beginIter, End endIter, std::string delimiter)
{
    for (auto iter{ beginIter }; iter != endIter; ++iter)
    {
        std::cout << *iter;
        if (std::distance(iter, endIter) != 1)
            std::cout << delimiter;
    }
}

template <class Container>
void printAll(const Container& c, std::string delimiter)
{
    printAll(std::cbegin(c), std::cend(c), delimiter);
}

template<class T>
void printAll(const std::initializer_list<T>& ini, std::string delimiter)
{
    printAll(ini.begin(), ini.end(), delimiter);
}


void print(std::vector<int> v)
{
    for (auto e : v)
    {
        std::cout << e << std::endl;
    }

}

int main()
{
    using namespace std;

    while (true)
    {
        int N, K, S;
        cin >> N >> K >> S;

        if (N == 0)
            break;

        //vvec<int> dp(K + 1, vec<int>(S + 1, 0));

        //dp[0][0] = 1;

        //for (int i = 1; i <= N; ++i)
        //{
        //    for (int j = 1; j <= K; ++j)
        //    {
        //        for (int k = 0; k <= S; ++k)
        //        {
        //            // iを使ってkが作れる
        //            if (k - i >= 0)
        //                dp[j][k] += dp[j - 1][k - i];
        //        }
        //    }
        //}

        // dp[i][j][k]: i番目までj個使ってkが何個作れるか
        vec<vvec<int>> dp(N + 1, vvec<int>(K + 1, vec<int>(S + 1, 0)));

        for (int i = 0; i <= N; ++i)
            dp[i][0][0] = 1;

        for (int i = 1; i <= N; ++i)
            for (int j = 1; j <= K; ++j)
                for (int k = 0; k <= S; ++k)
                {
                    // not use i-th element

                    dp[i][j][k] = dp[i - 1][j][k];

                    // i番目の数字を使う
                    if (k - i >= 0)
                        dp[i][j][k] += dp[i - 1][j - 1][k - i];
                }

        cout << dp[N][K][S] << endl;
        
    }


    return 0;
}

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

using namespace std;

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

    int n, k, s;
    while (true)
    {
        cin >> n >> k >> s;
        if (n == 0)
            break;
        int res = 0;
        for (int i = 0; i < (1 << n); i++)
        {
            int tmp = i;
            int sum = 0, cnt = 0;
            for (int j = 0; j < n; j++)
            {
                if (tmp % 2)
                {
                    cnt++;
                    sum += (j + 1);
                }
                tmp /= 2;
            }
            if (cnt == k && sum == s)
                res++;
        }
        cout << res << endl;
    }
}