Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func solve(a, b, c int) int {
	if a == 1 && b >= c && b < 10 {
		return 1
	}
	if a == 1 {
		return 0
	}
	ret := 0
	for i := c; i < 10 && i < b; i++ {
		ret += solve(a-1, b-i, i+1)
	}
	return ret
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		fmt.Println(solve(a, b, 0))
	}
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

typedef pair<int, int> paii;
typedef long long ll;


int main()
{
	int n, s;
	
	while(cin >> n >> s, (n||s))
	{
		int c = 0;
		int lim = 1 << 10;
		
		for(int k = 0; k < lim; k++)
		{
			int sum = 0;
			int sel = 0;
			for(int i = 0; i < 10; i++)
			{
				if( k & (1 << i))
				{
					sum += i;
					sel++;
				}
			}
			
			if(sum == s && sel == n)
				c++;
		}
		
		cout << c << endl;
	}
	
	return 0;
	
}

C++: #include <iostream>
#include <stack>

using namespace std;

struct sets { int i, sum, k; };

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int k) {
    stack<sets> S;
    S.push(sets{i, sum, k});

    while (!S.empty()) {
        set u = S.top();
        if (u.k == n && u.sum == s) { cnt++; }

        if (u.i == 10 && u.k == 0 && u.sum == 0) { break; }

        if (u.i < 10 && u.k < n) {
            S.push(sets{u.i + 1, u.sum, u.k});
            S.push(sets{u.i + 1, u.sum + a[u.i], u.k + 1});
        }
        else if (u.i == 10) {
            int tmp = u.k;
            while (S.top().k == tmp) { S.pop(); }
        }
        else { S.pop(); }
    }
}

int main() {
    while (cin >> n >> s) {
        if (!n && !s) { break; }
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

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

int a[10] = { 0,1,2,3,4,5,6,7,8,9 };
int n, s, r;

void dfs(int i, int sum, int n) {
	if (n == 0 && sum == s) {
		r++;
		return;
	}
	if (i == 10 || !n)return;
	dfs(i + 1, sum + a[i], n - 1);
	dfs(i + 1, sum, n);
	return;
}

int main() {
	while (cin >> n >> s, n, s) {
		r = 0;
		dfs(0, 0, n);
		cout << r << endl;
	}
	return 0;

}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int n,s;
    while(cin >> n >> s,n){
        function<int(int,int,int)> rec = [&](int now,int sum,int dep){
            if(dep == n){
                return (int)(sum == s);
            }
            int ret = 0;
            for(int i = now; i <= 9; i++){
                ret += rec(i+1,sum+i,dep+1);
            }
            return ret;
        };
        cout << rec(0,0,0) << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int search(int mn, int S, int N)
{
  int count = 0;
  if (mn > N) {return 0;}
  if (S == 1) {
    if (N <= 9) {
      return 1;
    } else {
      return 0;
    }
  }
  for (int i = mn; i < 10; i++) {
    if (N < i) {
      break;
    }
    count += search(i + 1, S - 1, N - i);
  }
  return count;
}

int main()
{
  int N, S;
  while (scanf("%d %d ", &S, &N) == 2) {
    if (N == 0 && S == 0) {break;}
    cout << search(0, S, N) << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int solve(int n,int m){
  if(m<n)return 0;
  if(n==1)return (0<=m&&m<=9);
  int res=0;
  if(m-n+1>=0)res+=solve(n-1,m-n+1);
  if(m-n>=0)res+=solve(n,m-n);
  if(m-10>=0)res-=solve(n,m-10);
  return res;
}
int main(){
  int n,m;
  while(cin>>n>>m&&n&&m){
    cout<<solve(n,m)<<endl;
  }
  return 0;
}

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

// n個の重複しない整数(>=min)用いてsを表す組み合わせの数
int ci(int n, int s, int min) {
  if (s < min) return 0; else if (n < 1) return 0; else if (n == 1) return 1;
  int r = 0;
  for (int i=min; i<s && i<10; i++) {
    r += ci(n - 1, s - i, i + 1);
  }
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0) << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  int n, s;
  while (cin >> n >> s) {
    if (n == 0 && s == 0) break;
    int ans = 0;
    for (int i = 0; i < 1024; i++) {
      int a = 0, b = 0;
      for (int j = 0; j < 10; j++)
        if ((i >> j) & 1) {
          a += j;
          b++;
        }
      if (a == s && b == n) ans++;
    }
    cout << ans << endl;
  }
}