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>

int n,s;

int dfs(int limit,int num,int res){
	if(num==n){
		if(res==s)
			return 1;
		else
			return 0;
	}
	int ans=0;
	for(int i=limit;i<10;++i){
		ans+=dfs(i+1,num+1,res+i);
	}
	return ans;
}

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

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int n, s;

int count( int x, int d, int z )
{
  int ret = 0;
  
  if ( z < 0 )
    return 0;

  if ( x == n )
    if ( d == z )
      return 1;
    else
      return 0;

  for ( int i = d + 1; i <= 9; ++i )
    ret += count( x + 1, i, z - d );

  return ret;
}

int main()
{
  while( cin >> n >> s && ( n != 0 || s != 0 ) )
    {
      int ret = 0;
      
      for ( int i = 0; i <= 9 ; ++i )
        ret += count( 1, i, s );
      
      cout << ret << endl;
    }
  
  return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int main(){
	int n,s,l,a,c;
	while(scanf("%d%d",&n,&s)){
		l=min(10,s);
		vector<int> v(l,0);
		rep(i,n)v[i]=1;
		c=0;
		do{
			a=0;
			rep(i,l)a+=i*v[i];
			c+=s==a;
		}while(prev_permutation(v.begin(),v.end()));
		printf("%d\n",c);
	}
	return 0;
}

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

int n;
int s;
int count;

int rec(int state, int num, int sum) {
  int count;
  count = 0;
  if(num > n) {
    if(sum == s) {
      return 1;
    } else {
      return 0;
    }
  }
  for(int i = state; i <= 9; i++) {
    count += rec(i+1, num+1, sum+i);
  }
  return count;
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int num,n,s,ans;
int solve(int a,int dp,int sum);

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

int solve(int c,int dp,int sum){
    if(dp==10){
        if(sum==s&&c==n)return 1;
        return 0;
    }
    return solve(c,dp+1,sum)+solve(c+1,dp+1,sum+dp);
}

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;
  }
  return 0;
}

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>
using namespace std;
int n,s,c;
void f(int m,int a,int t){
	if(a == n){
		if(t == s) ++c;
	}
	else {
		for(int i = m + 1;i < 10;++i){
			f(i,a + 1,t + i);
		}
	}
	return;
}
int main(){
	while(cin >> n >> s && (n != 0 || s != 0)){
		c = 0;
		for(int i = 0;i < 10;++i) f(i,1,i);
		cout << c << endl;
	}
	return 0;
}

C++: #include<cstdio>
int ans;
int n,s;
bool tryfunc(int now,int dep,int rest){
    if(rest==now && dep==0) ans++;
    else if(rest>now*2 && dep>0){
        for(int i=now+1;i<=(rest-now>s ? s:rest-now);i++){
            tryfunc(i,dep-1,(rest-now>s ? s:rest-now));
        }
    }
}
int main(){
    for(;;){
        ans=0;
        scanf("%d%d",&n,&s);
        if(n==0 && s==0) break;
        for(int i=0;i<10;i++){
            tryfunc(i,n-1,s);
        }
        printf("%d\n",ans);
    }
}

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

using namespace std;

int n, s;
int dp[11][101][11];
int solve(int i, int j, int k);

int main(void){
	
	while(cin >> n >> s){
		if(n == 0 && s == 0){break;}
		fill_n(**dp,11*101*11,-1);
		cout << solve(0,0,10) << endl;
	}
}

int solve(int now, int sum, int b1){
	if(now == n){
		if(sum == s){return 1;}
		else return 0;
	}
	if(dp[now][sum][b1] != -1){return dp[now][sum][b1];}
	int t = 0;
	for(int i = 0; i < 10; i++){
		if(b1 != 10 && b1 >= i){continue;}
		t += solve(now+1, sum + i, i);
	}
	return dp[now][sum][b1] = t;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,s;
int Sum_of_Integers(int i,int sum,int v);
int main(){
  while(1){
    cin >> n >> s;
    if(!n && !s)break;
    cout <<  Sum_of_Integers( 0 , 0 , -1) << endl;
  }
}
int Sum_of_Integers(int i,int sum,int v){
  int ret = 0;
  if(i > n || sum > s)return 0; // あふれたとき
  if(i == n && sum == s)return 1;
  for(int j=0;j<=9;j++){
    if(v<j)ret += Sum_of_Integers( i + 1, sum + j , j );
  }
  return ret;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

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

typedef long long ll;

int num, sum;
//now: 現在の数 cnt: 今なん回目？ add:何回足した？
int judge(int now, int cnt, int add)
{
	if(add == num)
	{
		if(now == sum)
			return 1;
		else
			return 0;
	}
	else if(cnt > 9)
	{
		return 0;
	}
	else
	{
		return judge(now + cnt, cnt+1, add+1) + judge(now, cnt+1, add);
	}
}

int main()
{
	while(cin >> num >> sum)
	{
		if(num == 0 && sum == 0)
			break;
		cout << judge(0, 0, 0) << endl;
	}
}

C++: #include <cstdio>
int n,s;
int dfs(int x,int y,int sum) {
	if(x==10) {
		return y==n&&sum==s;
	}
	return dfs(x+1,y,sum)+dfs(x+1,y+1,sum+x);
}
int main() {
	while(scanf("%d %d",&n,&s),n) {
		printf("%d\n",dfs(0,0,0));
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>

using namespace std;

int n = 0;
int s = 0;
static int ans;

void check(int atai, int num, int count){
	if (num > 9) {
		if (atai == s && count == n) {
			ans++;
		}
		return;
	}
	check(atai + num, num + 1, count + 1);
	check(atai, num + 1, count);
}


int main(int argc, char **argv)
{
	while (cin >> n >> s) {
		if (n == 0 && s == 0) {
			break;
		}
		check(0, 0, 0);
		cout << ans << endl;
	}
}

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

int calc(int n,int s,int min)
{
    int r=0;
    if (s<min)
	return 0;
    if (n==1)
    {
	if (s<10)
	    return 1;
	else
	    return 0;
    }
    for (int i=min; i<10; i++)
    {
	r+=calc(n-1,s-i,i+1);
    }
    return r;
}

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