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>
using namespace std;


int dfs(int a,int b,int c){
	if(b < 0)
		return 0;
	if(c < 0)
		return 0;
	if(a < 0)
		return 0;
	int n=0;
	if(b == 0 && a == 1){
		n++;
	}
	n =n + dfs(a-1,b-c,c-1) + dfs(a,b,c-1);
	return n;
}

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int cnt = 0;
// n := ???????????????????????°????????° s := ?????????????¨? now := ?????¨?????????????????°???
void dfs(int n, int s, int now){
	if(now > 9){
		//n??????????????????????¨?s
		if(n == 0 && s == 0) cnt++;
		return;
	}
	dfs(n - 1, s - now, now + 1);//??°???now???????????????
	dfs(n, s, now + 1);//??°???now??????????????????
	return;
}
int main(void){
	while(1){
		int n, s; cin >> n >> s;
		if(n == 0 && s == 0) return 0;
		cnt = 0;
		dfs(n, s, 0);
		printf("%d\n", cnt);
	}
}

C++: //AOJ Problem0030

#include<iostream>
#include<vector>

using namespace std;

int ans;

void solve(int n,int s,int m,int sum,int max){//n:何個か s:目的値 m:何回目か sum:現在の合計 max:最大の足した数
	
	if(m>n || sum>s){
		return;
	}

	else if(n==m && sum==s){
		ans++;
		return;
	}

	else{
		for(int i=max+1;i<=s;i++){
		
			solve(n,s,m+1,sum+i,i);
		}
	}
}

int main(){

	int n,s;

	vector<int> dataN;
	vector<int> dataS;

	for(;;){
		cin>>n;
		cin>>s;
		if(n==0&&s==0){
			break;
		}
		dataN.push_back(n);
		dataS.push_back(s);
	}
	for(int j=0;j<dataN.size();j++){

		ans=0;

		for(int i=0;i<=s;i++){
			solve(dataN[j],dataS[j],1,i,i);
		}

		cout<<ans<<endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int n,s,spn;
void sp(int ne,int ns,bool* flag)
{
	if (ne > n) return;
	if (ne == n && ns == s) spn++;
    for(int i=0;i<10;++i){
        if(!flag[i]){
            flag[i]=true;
            sp(ne+1,ns+i,flag);
			flag[i] = false;
		}
    }
}
int main()
{
    while(1)
    {
        cin>>n>>s;if(!n)return 0;
        spn=0;
        bool flag[10]={false};
        sp(0,0,flag);
        if(n!=1)spn/=(n*(n-1));
        cout<<spn<<endl;
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int to, cost; edge(int t, int c) :to(t), cost(c){} };

int main()
{
	//while (cin >> n)
	stringstream ss;
	//ss << "result" << i + 1 << ".txt";
	//FILE* fp_out = freopen(ss.str().c_str(), "w", stdout);

	int n;
	while (cin >> n)
	{
		int s; cin >> s;
		function<int(int, int, int)> dfs = [&](int now, int rem, int sum)
		{
			if (rem == 0 && sum == s) return 1;
			if (rem == 0) return 0;
			int ret = 0;
			for (int i = now + 1; i < 10; i++)
			{
				ret += dfs(i, rem - 1, sum + i);
			}
			return ret;
		};

		int ans = 0;
		rep(i, 10) ans += dfs(i, n - 1, 0);
		cout << ans << endl;
	}

	return 0;
}

C++: #include <stdio.h>
bool used[11]={0,0,0,0,0,0,0,0,0,0,0};int mn(int a, int b) {return (a<b)?a:b;}
void dfs(int v, int sz, int &ans, int here) {used[here]=1;if (!v && !sz) ans++;if (v>=0 && sz>0) for (int j=mn(mn(v,9),here);j>=0;j--) if (!used[j]) dfs(v-j,sz-1,ans,j);used[here]=0;}
int main() {int N,M,i;while (1) {scanf("%d %d",&N,&M);if (!N && !M) return 0;i=0;dfs(M,N,i,10);printf("%d\n",i);}}

C++: #include<iostream>

using namespace std;
int n, s, ans;
void solve(int v, int sum, int num){
    if(sum==s&&num==n){
        ans++;
        return;
    }
    if(v>=10||num>=n||sum>=s) return;

    solve(v+1, sum+v, num+1);
    solve(v+1, sum, num);
}


int main(){

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

    return 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++: #include<iostream>

using namespace std;

int ans = 0;
void dfs(int n,int s,int depth){
	//if (s < 0) return;  //
	if (s == 0 and n == 0){ // ?§£??????????????£??????
		ans++;
		return;
	}
	if (n == 0) return;	

	d++;
	if (depth == 10)return;
	//???????????´???
	dfs(n-1,s-depth,depth);
	//?????°????????£?????´???
	dfs(n,s,depth);
return;
}

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

return 0;
}