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;

int dfs(int x,int n,int s){
  
  if(n==0)
    return (s==0);
  
  if(x==10)
    return 0;
  
  int res=0;
  
  for(int i=x;i<=9;++i){
    res+=dfs(i+1,n-1,s-i);
  }
  return res;
}

int main(){
  int n,s;

  while(cin>>n>>s,n,s){
    cout<<dfs(0,n,s)<<endl;
  }
}

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

int n,k,count;
int value[10] = {0,1,2,3,4,5,6,7,8,9};

void dfs(int i,int sum,int num)
{
	if(num == n) 
	{
		if(sum == k)
		{
			count++;
		}
		return;
	}
	
	if(i == 10 || num == n)
	{
		return;
	}

	dfs(i+1,sum,num);
	dfs(i+1,sum + value[i],num+1);
}
int main()
{
	while(cin >> n >> k && n && k)
	{
		count = 0;
		dfs(0,0,0);
		cout << count << endl;

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int table[ 11 ][ 50 ] = { };

  for ( int i = 0; i < 0x400; ++i )   /* 0x400: (10000000000)_2 (10 zeros) */
  {
    int sum = 0;
    int ctr = 0;
    int cur = -1;

    while ( true )
    {
      int __tmp = i >> ++cur;

      if ( !__tmp ) break;
      if ( __tmp & 1 )
      {
        sum += cur;
        ++ctr;
      }
    }

    table[ ctr ][ sum ]++;
  }

  while ( true )
  {
    int n, s;

    cin >> n >> s;
    if ( n == 0 && s == 0 ) break ;

    cout
      << ( n >= 0 && n <= 10
           && s >= 0 && s < 50 ? table[ n ][ s ]
                                : 0 ) << 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>

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;
bool d[10];
int ans = 0;
vector< vector<int> > C;

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

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





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

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

int combination(int least,int n,int s)
{
	int sum = 0;
	if(n==1)
		return (least < s&&s<=9)?1:0;
	else
	{
		int sum  = 0;
		for(int i = least+1;i<=9;i++)sum +=combination(i,n-1,s-least);
		return sum;
	}
};


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

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

void func(int start,int num,int current);
int s,res;

int main(void){
  int n;
  cin >> n; cin >> s;
  while(n!=0 || s!=0){
    res = 0;
    func(0,n,0);
    cout << res << endl;
    cin >> n; cin >> s;
  }
  return 0;
}
  
void func(int start,int num,int current){
  int temp=0;
  for(int i=start; i<10; i++){
    if(current+i<=s) temp = current+i;
    else break;
    if(num!=1) func(i+1,num-1,temp);
    else if(temp==s) {
      res++;
    }
    temp=0;
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int n,s,result;

void saiki(int summed,int maxi,int sum)
{
	if(summed < n)
	{
		for(int a = maxi;a>=0;a--)
		{
			if(sum + a < s)
			{
 				saiki(summed + 1,a - 1,sum + a);
			}
			else if(sum + a == s)
			{
				if(summed + 1 == n)
				{
					result++;
				}
				else
				{
					saiki(summed + 1,a-1,sum+a);
				}
			}
		}
	}
}

int main()
{
	for(int i = 0;;i++)
	{
		cin >> n >> s;

		if(n == 0 && s == 0)
		{
			break;
		}

		result = 0;

		saiki(0,9,0);

		cout << result << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int n, s, cnt;

void dfs(int depth, int sum, int num) {
  if (depth == 0 && sum == s) {
    cnt++;
    return;
  }
  if (num == 10 || depth == 0) return;
  dfs(depth - 1, sum + num, num + 1);
  dfs(depth, sum, num + 1);
}

int main() {
  while (cin >> n >> s, n | s) {
    cnt = 0;
    dfs(n, 0, 0);
    cout << cnt << "\n";
  }
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;
int n, s;

int cnt = 0;

int func(string m, vector<bool> b, int num){
  if( m.size() == n ){
    int tmp = 0;
    for(int i=0; i<n; i++) tmp += m[i]-'0';
    if( tmp == s ) cnt++;
    if( tmp == s ) cerr << m << endl;
    return 0;
  }

  for(int i=num+1; i<10; i++){
    if( b[i] ) continue;
    b[i] = true;
    func( m + to_string(i), b, i);
    b[i] = false;
  }

}

int main(void) {


  while(cin >> n >> s){
    if( n == 0 && s == 0 ) break;

    vector<bool> b(10, false);
    for(int i=0; i<10; i++){
      b[i] = true;
      func(to_string(i), b, i);
      b[i] = false;
    }
    cout << cnt << endl;
    cnt = 0;
  }

  return 0;
}


// EOF

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	int n,s;
	while(scanf("%d %d",&n,&s)==2,n||s){
		int mat[10] = {0,1,2,3,4,5,6,7,8,9};
		int t = 0;
		map<vector<int>,int> table;
		do{
			vector<int> tmp;
			int sum = 0;
			for(int x=0;x<n;++x){
				tmp.push_back(mat[x]);
				sum += mat[x];
				if(sum>s)break;
			}
			if(sum==s){
				sort(tmp.begin(),tmp.end());
				table[tmp] = 100;
			}
		}while(next_permutation(mat,mat+9));
		cout<<table.size()<<endl;
	}
	return 0;
}

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

int n,s;
int ans = 0;

int dfs(int num,int total,int de)
{
	int count = 0;

	if(de == n && total == s)
	{
		return 1;
	}
	if(de == n && total != s)
	{
		return 0;
	}

	for(int i=num; i<=9; i++)
	{
		count += dfs(i+1,total+i,de+1);
	}
	return count;
}

int main()
{

	while(cin >> n >> s , n != 0 , s != 0)
	{
			dfs(0,0,0);

		cout << dfs(0,0,0) << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int count;
int n,s;

void find_dps(int sum, int now, int add_count) {
  //printf("%d %d : %d %d\n",sum,s,add_count,n);
  if (now > 10 || add_count > n || sum > s) {
    return;
  }
  if (sum == s && add_count == n) {
    //printf("now=%d\n", now);
    count++;
    return;
  }
  find_dps(sum+now, now+1, add_count+1);
  find_dps(sum, now+1, add_count);
}

int main (int argc, char const* argv[]) {
  while (true) {
    cin>>n>>s;
    if (n==0 && s==0) break;
    count = 0;
    find_dps(0,0,0);
    cout<<count<<endl;
  }
  return 0;
}