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 <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	for(int n, s; cin >> n >> s && n && s;) {
		int ret = 0;
		for(int i = 0; i < (1<<10); i++) {
			int sum = 0;
			if(__builtin_popcount(i) != n) continue;
			for(int j = 0; j < 10; j++) {
				if((1 << j) & i) sum += j;
			}
			if(sum == s) ret++;
		}
		cout << ret << endl;
	}
	return 0;
}

C++: #include<cstdio>
using namespace std;
int saiki(int n,int m,int cnt);
int main(){
    int n,m;
    while(scanf("%d%d",&n,&m),n,m){
        int ans = 0;
        int cnt = 0;
        ans = saiki(n,m,cnt);
        printf("%d\n",ans);
    }
    return 0;
}
int saiki(int n,int m,int cnt){
    if(n == 0&&m == 0)return 1;
    if(cnt == 10)return 0;
    return saiki(n-1,m-cnt,cnt+1)+saiki(n,m,cnt+1);
}

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

int solve(int n, int s, int l) {
	if (n == 0) {
		if (s == 0) return 1;
		else return 0;
	}
	int res = 0;
	for (int i = l + 1; i < 10; i++) {
		res += solve(n - 1, s - i, i);
	}
	return res;
}

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

C++: #include <iostream>

using namespace std;

int n, s, count;

void DFS(int sum, int pre, int depth)
{
	if(depth > n || sum > s)
	{
		return;
	}
	else if(sum == s && depth == n)
	{
		++count;
		return;
	}
	else
	{
		for(int i = pre + 1; i < 10; ++i)
		{
			DFS(sum + i, i, depth + 1);
		}
	}
}

void solve()
{
	while(cin >> n >> s, n || s)
	{
		count = 0;
		for(int i = 0; i < 10; ++i)
		{
			DFS(i, i, 1);
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
using namespace std;
int _s,a,b;
int solve(int c,int n,int s){
      if(!n) return s==_s;
      if(c>=10) return 0;
      return solve(c+1,n-1,s+c) + solve(c+1,n,s);
}
int main(){
      while(cin >> a >> _s,a||_s)cout <<solve(0,a,0)<< endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int cnt,n,s,flg[10];
void func(int sum,int c,int j){
	int i;
//	cout<<sum<<' '<<c<<endl;
	if(c<n){
		for(i=j;i<10;i++){
			if(sum+i>s)break;
			if(flg[i]==1){	
				if(sum+i==s&&c+1==n){
//					cout<<sum<<' '<<i<<' '<<c<<endl;
					cnt++;
				}
				else if(sum+i<s&&c+1<n){
					flg[i]=0;
					func(sum+i,c+1,i+1);
					flg[i]=1;
				}
			}
		}
	}
}
int main(void){
	int i;
	while(1){
		for(i=0;i<10;i++) flg[i]=1;
		cin>>n>>s;
		if(n==0)break;
		cnt=0;
		func(0,0,0);
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n, s;
int ans = 0;
void solve(int i, int sum, int num) {
	if (i == n&&sum == s) {
		ans++;
		return;
	}
	for (int j = num; j <= 9; j++) {
		solve(i + 1, sum + j, j + 1);
	}
	return;
}
int main() {
	while (cin >> n >> s&&n + s) {
		ans = 0;
		solve(0, 0, 0);
		cout << ans << endl;
	}
}

C++: #include<iostream>
using namespace std;
int n, s;
int cou;
void dfs(int i, int sum,int num_of_add) {
	if (sum == s&&num_of_add==n) {
		cou++;
		return;
	}
	if (n == num_of_add||i==10)return;
	dfs(i + 1, sum, num_of_add);
	dfs(i + 1, sum + i, num_of_add + 1);
}
int main() {
	while (cin >> n >> s,n != 0 && s != 0) {
		cou = 0;
		dfs(0, 0, 0);
		cout << cou << endl;
	}
}

C++: #include <stdio.h>
int n, s, count = 0, digits[10]; // n 個の整数の和がsになる
void dfs(int cur) {              // cur = 0   {}
   if(cur == n) {               // cur = 1   {a}
       int sum = 0;             // cur = 2   {a, b}
       for(int i = 0; i < n; i++) { sum += digits[i]; }
       if(sum == s) { count++; }
       return;
   }
   for(int i = 0; i < 10; i++) {
       digits[cur] = i; // FIXME: 重複を避ける
       dfs(cur+1);  
   }
}
int main(void){
   n = 3; s = 6; count = 0;
   dfs(0);
   printf("%d\n", count);
 scanf("%d",&n);
    scanf("%d",&s);

    func(0,0,0);

    printf("%d",count);
  return 0;
}

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

bool a[10];
int n, s;
int sum;
int count;
int ans;

void bfs(int i);

int main() {
  while (1) {
    cin >> n >> s;
    if (!n && !s) break;

    for (int i=0; i<10; i++) a[i] = false;
    sum = 0;
    ans = 0;
    count = 0;
    bfs(0);
    cout << ans << endl;
  }
}

void bfs(int i) {
  if (sum+i < s && count < n-1 && i<9) {
    a[i] = true;
    sum += i;
    ++count;
    bfs(i+1);
    a[i] = false;
    sum -= i;
    --count;
  } else if (sum+i == s && count == n-1) {
    ans++;
  } else if (sum+i > s) {
    return;
  }

  if (i<9) {
    bfs(i+1);
  }

  return;
}

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

int pattern_num[1];

void find_pattern(int now, int sum, int t_n, int n, int s) {
	//printf("%d %d %d %d %d\n",now ,sum, t_n, n, s);
	// Found
	if (t_n == n && sum == s) {
		pattern_num[0]++;
		return;
	}
	// Temporary end
	if (sum > s || t_n == n && sum != s || now > s) {
		return;
	}
	// Search
	for (int i = now+1; i < 10; i++) {
		if (sum+i <= s)
			find_pattern(i, sum+i, t_n+1, n, s);
	}
	return;
}

int main(int argc, char *argv[]) {
	int n, s;
	while (true) {
		// init
		pattern_num[0] = 0;
		// load data
		fscanf(stdin, "%d %d", &n, &s);
		// End of Program
		if (n == 0 && s == 0) {
			break;
		}
		// find pattern
		for (int i = 0; i < 10; i++) {
			if (i <= s)
				find_pattern(i, 0, 1, n, s);
		}
		// print
		printf("%d\n", pattern_num[0]);
	}
	return 0;
}