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 <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int ans, s;

void dfs(int begin, int depth, int sum) {
  if(depth == 0){
    if(s == sum){
      ans++;
    }
    return;
  }
  for(int i = begin+1 ; i <= 9 ; i++){
    dfs(i, depth-1, sum+i);
  }
}

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

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

inline int first(int n){
	return ((1 << n) - 1);
}

int nextSet(int x){
	int small, ripple, newSmall,ones;
	
	small = x & -x;
	ripple = x + small;
	newSmall = ripple & -ripple;
	ones = (( newSmall / small ) >> 1) - 1;
	
	return (ripple | ones);
}

comb setComb(int s, int n){
	comb c;
	for(int i=1 ; i<=n ; i++){
		if( s & 1 ) c.push_back(i-1);
		s >>= 1;
	}
	return c;
}

int main(){
	int n=10, k, x, s, sum, ans;
	comb c;
	
	while( cin >> k >> s , k || s ){
		ans = 0;
		x = first(k);
		while( !(x & ~first(n) ) ){
			c = setComb( x , n );
			sum = 0;
			for(int i=0 ; i<c.size() ; i++){
				sum += c.at(i);
			}
			if( sum == s ) ans++;
			x = nextSet( x );
		}
		cout << ans << endl;
	}
}

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

int n, s, m;

void sm(int i, int j, int r) {
	if (i == 10) {
		if (j == n && r == s)
			m++;
	}
	else {
		sm(i + 1, j + 1, r + i);
		sm(i + 1, j, r);
	}
}

int main()
{	
	cin >> n >> s;

	while (n > 0 || s > 0) {
		m = 0;

		sm(0, 0, 0);
		cout << m << endl;

		cin >> n >> s;
	}

	return 0;
}

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

int n, s;
bool numbers[10] = { true };
int ans;

void dfs(int sum, int i, int num){
	if (i == n){
		if (sum == s) ans++;
		return ;
	}
	for (int j = num+1; j < 10; ++j){
		if(sum + j <= s)dfs(sum + j, i + 1,j);
	}
}

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

C++: #include<iostream>

using namespace std;
int n, s, ans;

void solve(int cnt, int num, int sum){
    if(n==cnt&&s==sum){
        ans++;
        return;
    }else if(cnt>n||num>9||sum>s){
        return;
    }

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

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 <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep(i,n) for(i=0;i<n;i++)
#define rep_r(i,n) for(i=n-1;i>=0;i--)
#define debug_i(x) printf("x:%d\n",x)
#define debug_s(str) printf("str:%s\n",str)
#define debug_c(c) printf("c:%c\n",c) 

int main()
{
	int i,j,k;
	int n,s,kep,count=0,ans=0,a_c=0;
	int num[11]={0,1,2,3,4,5,6,7,8,9};
	int bit[11]={};
	int sum=0;
	while(1)
	{
		scanf("%d %d",&n,&s);
		if(n==0 && s==0)break;
		rep(i,1023)
		{
			sum++;
			kep=sum;
			for(j=0;;j++)
			{
				if(kep>0)
				{
					bit[j]=kep%2;
					kep/=2;
				}
				else break;
			}
			rep(j,10)if(bit[j]==1)count++;
			if(count==n)
			{
				rep(k,10)ans+=bit[k]*k;
				if(ans==s)a_c++;
			}
			count=0;
			ans=0;
		}
		printf("%d\n",a_c);
		rep(i,10)bit[i]=0;
		sum=0;
		a_c=0;
	}
	return 0;
}

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

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

int main( void )
{
	while (1)
	{
		int n, s;
		cin >> n >> s;
		if ( n == 0 && s == 0 )
			break;

		vector <int> numbers;
		for ( int i = 0; i < s; i++ )
			numbers.push_back( i );

		int kotae = 0;
		do
		{
			bool continue_flag = false;
			for ( int i = 0; i < n-1; i++ )
			{
				if ( numbers[i] > numbers[i+1] )
				{
					continue_flag = true;
					break;
				}
			}
			if ( continue_flag )
				continue;
			int sum = 0;
			for ( int i = 0; i < n; i++ )
			{
				sum += numbers[i];
			}
			if ( sum == s )
			{
				kotae++;
			}
		} while ( next_permutation( numbers.begin(), numbers.end() ) );

		cout << kotae / 6 << endl;

	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

int get_sum(int num,int sum,int *u,int n){
	int i,j;
	if(num==0&&sum==0){
		return 1;
	}
	if(n>9){
		return 0;
	}
	return (get_sum(num-1,sum-u[n],u,n+1)+get_sum(num,sum,u,n+1));
}

int main()
{
	int sum,num;
	int u[10];
	int i;
	while(1){
		scanf("%d %d",&num,&sum);
		if(num==0&&sum==0) break;
		for(i=0;i<10;i++){
			u[i]=i;
		}
		printf("%d\n",get_sum(num,sum,u,0));
	}
	return 0;
}

C++: #include<cstdio>

using namespace std;

int n,s;
int answer=0;

void roop(int T,int N,int S)
{
	if(N==n)//最後の処理ならば
	{
		if(s-S>T&&s-S<10)answer++;
	}
	else//それ以外
	{
		for(int i=T+1;i<10;i++)
		{
			roop(i,N+1,S+i);
		}
	}
}


int main()
{
	while(true)
	{
		scanf("%d%d",&n,&s);
		if(n==0&&s==0)break;
		answer=0;
		roop(-1,1,0);
		printf("%d\n",answer);
	}

	return 0;
}

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

int n,s;
int dfs(int cou,int now,int before);

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

int dfs(int cou,int now,int before){
  if(cou==n) {
    if(now == s) {
      return 1;
      cout << before << endl;
    }
    else return 0;
  }
  int num = 0;
  for(int i=before+1;i<10;i++){
      num += dfs(cou+1,now+i,i);
  }
  return num;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <numeric>
#include <ctime>
using namespace std;

// vector の表示用デバッグ
template<class T>
void debug(const vector<T>& v){
    cout << "[debug]" << endl << "{";
    for(int i = 0 ; i < v.size() ; i++ )
        cout << (i? ", " : "") << v[i];
    cout << "}" << endl;
}

int first(int n){
    return ((1 << n) - 1);
}

// 次の組合せを返す (32bitのintを返す)
int nextSet(int x){
    int small, ripple, newSmall,ones;
    small = x & -x;
    ripple = x + small;
    newSmall = ripple & -ripple;
    ones = (( newSmall / small ) >> 1) - 1;
    return (ripple | ones);
}

// bit列に対応するvectorを返す 
// ( i 番目のbitが 1 => i 番目の要素を選んでいる, i 番目のbitが 0 => i番目の要素を選んでいない)
vector<int> setComb(int s, int n, vector<int> a){
    vector<int> c;
    for(int i=0 ; i < n ; i++ ){
        if( s & 1 ) c.push_back( a[i] );
        s >>= 1;
    }
    return c;
}

// {a[0], a[1], ... , a[n-1]} の n 個の要素から k 個選んだ組合せを出力
int main(){
	const int n = 10;
    int k, s;
    while( cin >> k >> s , k || s ){
        vector<int> a(n);
        int ans = 0;
        for(int i=0 ; i < n ; i++ ){
            a[i] = i;
        }
        
        int x = first(k);
        while( !(x & ~first(n) ) ){
            vector<int> c = setComb( x , n , a );
            // 組合せ c に対する操作
            int sum = 0;
            for(int i=0 ; i < c.size() ; i++ ) sum += c[i];
            if( sum == s ) ans++;
            x = nextSet( x );
        }
        cout << ans << endl;
    }
}