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 <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)


int n,s;
int ans=0;


int solve(int c,int d,int s){
	if(c==n){
		if(s<=9&&s>=d){
			ans++;
		}
	}
	else{
		for(int i=d;i<10;i++){
			solve(c+1,i+1,s-i);
		}
	}
	return ans;
}
	
	

int main(){
	while(cin>>n>>s,n||s){
		//if(s>45) cout<<0<<endl;
		ans = 0;
		cout << solve(1,0,s) <<endl;
	}
	return 0;
}

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

C++: #include<iostream>
#include<cstdio>
using namespace std;
int sum,n,s;
void func(int np,int nn,int pre){
	if(np==s&&nn==n)
		sum++;
	else
	if(nn<n)
	for(int i=pre+1;i<10;i++)
		if(np+i<=s)
			func(np+i,nn+1,i);
}
int main(){
	while(cin>>n>>s,n||s){
		sum=0;
		func(0,0,-1);
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

const int num[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int ans = 0, n, s, sum = 0;

void subsetsum(int n, int k)
{
  for(int i = n; i < 10; i++){
    if(k){
      sum += num[i];
      subsetsum(i + 1, k - 1);
      if(sum == s && k == 1)
	ans++; 
      sum -= num[i];
    }else{
      break;
    }
  }
}
	

int main()
{
  while(1){
    cin >> n >> s;
    if(n == 0 && s == 0){
      break;
    }else{
      subsetsum(0, n);
      cout << ans << endl;
      ans = 0;
    }
  }
}

C++: #include <iostream>

using namespace std;

int n , s;

int dfs(int i , int sum , int N){

	if(N == 0 && sum == 0) return 1;//yes
	if(N == 0 || i == 10) return 0;//no

	return dfs(i + 1 , sum , N) + dfs(i + 1 , sum - i , N - 1);
}

int main(){

	while(cin >> n >> s , n){

		cout << dfs(0 , s , n) << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	while(1)
	{
		int n,s;
		int ans=0;
		cin >> n >> s;
		if(n==0&&s==0)break;
		int comb=(1<<n)-1;
		while(comb<(1<<10))
		{
			int sum=0;
			for(int i=0;i<10;i++)
			{
				if((comb>>i)&1)sum+=i;
			}
			if(sum==s)ans++;
			int x=comb&-comb,y=comb+x;
			comb=((comb&~y)/x>>1)|y;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int cnt; int N, Ans;

void choose(int k, int l, int digit) {
  if(k == Ans && l == N) { cnt++; return; }
  else if (k > N) return;
  else if (l == N) return;
  else if (digit >= 10) return;
  
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}

int main () {
  while(cin>>N>>Ans, N||Ans) {
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

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

int f(int n, int s, int x)
{
	if (n == 0) {
		if (s == 0) return 1;
		else return 0;
	}
	if (x >= 10) {
		return 0;
	}
	return f(n - 1, s - x, x + 1) + f(n, s, x + 1);
}

int main()
{
	int n, s;
	
	while (1) {
		cin >> n >> s;
		
		if (n == 0 && s == 0) break;
		
		printf("%d\n", f(n, s, 0));
	}
	
	return 0;
}

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

int res;
const int d[10]={0,1,2,3,4,5,6,7,8,9};

bool dfs(int now,int idx,int n,int sum,int s){
	
	if(idx>9) return false;
	
	if(now==n&&sum==s) {
		res++;
		return true;
	}
	
	if(dfs(now,idx+1,n,sum,s)) return true;
	
	if(dfs(now+1,idx+1,n,sum+d[idx],s)) return true;
	
	return false;
}

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

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

int dfs(int n, int sum, int before) {
    int ret = 0;
    if(n < 0 || before > 9 || (n > 0 && sum >= key)) return(0);
    else if(n == 0) return(sum == key);
    
    for(int r = before; r <= 9; r++) {
        ret += dfs(n - 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    int n;
    while(cin >> n >> key, n + key != 0) {
        cout << dfs(n, 0, 0) << endl;
    }
    return(0);
}

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;

int dfs(int v,int sum,int depth) {
	int 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;
}