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 <bits/stdc++.h>

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  int pattern[64];
  int n;
  Solver(int n) : n(n) {}
  void solve(int it=-1, int c=0, int s=0){
    if (c == n){
      pattern[s]++;
      return;
    }
    for (int i = it + 1; i <= 9; i++){
      solve(i, c + 1, s + i);
    }
  }
};

int main()
{
  int n, s;
  while (n = in(), s = in(), n != 0 && s != 0){
    Solver solver(n);
    solver.solve();
    if (s < 64){
      printf("%d\n", solver.pattern[s]);
    }
    else puts("0");
  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> PL;

int n, s;
int ans = 0;
//int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
bool d[10];
vector< vector<int> > C;

void dfs(int i, int sum){
	if (i == n&&sum == s){
		vector<int> vi;
		if (C.empty()){
			REP(j, 10){
				if (d[j] == 1){
					vi.push_back(j);
				}
			}
			C.push_back(vi);
			ans++;
			return;
		}
		bool f = 1;
		REP(j, C.size()){
			int co = 0;
			REP(k, n){
				if (d[C[j][k]] == 1) co++;
			}
			if (co == n){
				f = 0;
				break;
			}
		}
		if (f){
			ans++;
			REP(l, 10){
				if (d[l] == 1){
					vi.push_back(l);
				}
			}
			C.push_back(vi);
		}
	}

	for (int j = 0; j < 10; j++){
		if (d[j] == 0){
			d[j] = 1;
			dfs(i + 1, sum + j);
			d[j] = 0;
		}
	}
	return;
}

int main(){
	while (cin >> n >> s&&n&&s){
		dfs(0, 0);
		cout << ans << endl;
		C.clear();
		ans = 0;
	}
}

C++: #include <stdio.h>
#include <string.h>

int n ;
int s ;
int ans ;
int sum ;
bool vis[12] ;

void init ( ) ;
void DFS ( int source , int k ) ;

int main ( )
{
	while ( scanf ( "%d %d" , &n , &s ) == 2 && ( n || s ) ) {
		init ( ) ;
		DFS ( 0 , 0 ) ;
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void init ( )
{
	memset ( vis , false , sizeof ( vis ) ) ;
	ans = 0 ;
	sum = 0 ;
}

void DFS ( int source , int k )
{
	if ( source == n ) {
		if ( sum == s ) {
			ans++ ;
		}
		return ;
	}
	for ( int i = k ; i <= 9 ; i++ ) {
		if ( vis[i] == false ) {
			vis[i] = true ;
			sum += i ;
			DFS ( source + 1 , i ) ;
			vis[i] = false ;
			sum -= i ;
		}
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int n, s;

ll dfs(int v,int sum,int depth) {
	ll res = 0;
	if (depth == n) {
		if (sum == s) return 1;
		else return 0;
	}
	REP(i, v + 1, 10) {
		ll tmp = dfs(i, v+i, depth + 1);
		res += tmp;
		 //cout << "dfs(" << i << "," << v + i << "," << depth + 1  
			//<< ") = " << tmp << endl;
	}
	return res;
}

int main() {
	while (1) {
		cin >> n >> s;
		if (n == 0) break;
		// dump(dfs(2, 6, 3));
		cout << dfs(-1,0,0) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int n,s;
	while(cin>>n>>s,n||s){
		if(n>10||s>45){
			cout<<0<<endl;
			continue;
		}
		int min = (int)pow(10.0,n-2);
		int lim = (int)pow(10.0,n);
		stack<int> st;
		vector<int> res;
		st.push(0);
		while(!st.empty()){
			int top = st.top();
			int tmp=top;
			int cur=0;
			while(tmp>0){
				cur+=tmp%10;tmp/=10;
			}
			st.pop();
			if(top>min&&cur==s){
				res.push_back(top);
			}else{
				if(top*10>=lim) continue;
				for(int i=top%10+1;i<10;++i){
					st.push(top*10+i);
				}
			}
		}
		cout<<res.size()<<endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, s;
int ans = 0;

void dfs(int i, int sum, int num){
	if (i == n&&sum == s){
		ans++;
		return;
	}

	for (int j = num; j < 10; j++){
		dfs(i + 1, sum + j, j);
	}
	return;
}

int main(){
	while (cin >> n >> s){
		if (n + s == 0)break;
		ans = 0;
		dfs(0, 0, 0);
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
vector<int> v;
int ret = 0;
void check(int s) {
	int total = 0;
	for(int x : v) {
		total += x;
	}
	if(s == total) ret++;
}
void select(int a, int l, int s) {
	if(!l) {
		check(s);
		return;
	}
	rep2(i,a,10) {
		v.push_back(i);
		select(i+1, l-1, s);
		v.pop_back();
	}
}
		
int main() {
	int n, s;
	while(cin >> n >> s && (n || s)) {
		select(0, n, s);
		cout << ret << endl;
		ret= 0;
	}
	return 0;
}