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;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
typedef long long ll;


int n, k;
int ans = 0;
void dfs(int i,int j, int sum)
{
	if (i == n)
	{
		if (sum == k)ans++;
	}
	else if (j<=9&&sum<=k)
	{
		dfs(i + 1, j + 1, sum + j);
		dfs(i, j + 1, sum);
	}
}

int main()
{
	while (cin>>n>>k)
	{
		if (n == 0 && k == 0)return 0;
		ans = 0;
		dfs(0, 0, 0);
		cout << ans << 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>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

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 fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, s;
int ans = 0;

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

	for (int j = num; j <= 9; j++){
		dfs(i + 1, sum + j, j + 1);
	}
	return;
}

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

C++: #include <iostream>
using namespace std;
int main(){
  int n,s,j,k,a[11][46];
  for(int s=0;s<46;s++)for(int n=0;n<11;n++)a[n][s]=0;
  for(int i=0;i<1024;i++){
    for(j=i,n=0;j>0;j/=2)
      n += j%2;
    for(j=i,s=0,k=0;j>0;j/=2,k++)
      s += j%2*k;
    a[n][s]++;
  }
  for(cin>>n>>s;n||s;s<46?cout<<a[n][s]:cout<<0,cout<<endl,cin>>n>>s);
}

C++: 
// 再帰関数を利用して整数n個の和でsを作れたら１を返す
// 出来ないときは０を返す


#include <iostream>
 
using namespace std;

int rec( int s , int n , int num ){

  if( s < 0 )return 0;                    //整数n個の和でsを作ることは不可能
  if( s == 0 && n == 0 )return 1;         //整数n個の和でsを作ることが出来た
                                          //この問題は数の順番を考慮しなくて
                                          //いいからiに num + 1を入れてよい  
  int ans = 0;
  for( int i = num + 1 ;  i < 10 ; i++ ){ //同じ数字は使えない
    ans += rec( s - i , n - 1 , i );
  }
  return ans;
}


int main(void){

  while(1){

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

  cout << rec( s, n , -1 ) << endl;

  }
 return 0;
}

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

int count;

void func(int n, int s, int tmp, int num)
{
	int i;
	if(tmp == s && n == 0){
		count++;
		return ;
	}

	for(i = num; (i+tmp) <= s; i++){
		if(i == tmp){
			break;
		}
		func(n-1, s, i+tmp, num+1);
	}
	
	return ;
}

int main(int argc, char **argv){
	int n, s;
	
	while(1){
		cin >> n >> s;
		
		if(n == 0 && s == 0){
			break;
		}
		count = 0;
		
		for(int i = 0; i < s; i++){
			func(n-1, s, i, 1);
		}
		
		cout << count << endl;
	}
	
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int main()
{
	int n, s;

	while(cin >> n >> s && (n || s))
	{
		vint num(10);
		rep(i, 10)
			num[i] = i;

		vector<bool> par(10, 0);

		REP(i, 10-n, 10)
			par[i] = 1;

		int res = 0;
		do
		{
			int buf = 0;
			rep(i, 10)
				buf += i * par[i];
			
			res += buf == s;


		}while(next_permutation(ALL(par)));

		cout << res << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int dfs(int n,int s,int i){
  if(n == 0){
    if(s == 0)return 1;
    else return 0;
  }
  if(s < 0)return 0;
  if(i > 9)return 0;

  return dfs(n,s,i + 1) + dfs(n - 1,s - i,i + 1);
}

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

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

int n, s;
vector<int> nums;

int solve( int sum, int nn, int l ){
	if( nn==0 )	return (sum == s)?1:0;
	int cnt=0;
	for( int i=l+1; i<=9-nn; i++ ){
		cnt += solve( sum+i, nn-1, i );
	}
	return cnt;
}

int main(){
	for( int i=0; i<=9; i++ )	nums.push_back(i);
	while( cin >> n >> s, n||s ){
		cout << solve( 0, n, -1 ) << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;


int n,s;

int count;

void dfs(int i,int j,int sum) {

  //cout << i << " " << j << " " << sum << endl;

  if(j==0 && sum==0) {

    count++;

    return;

  }

  if(i==10 || j==0) return;

  dfs(i+1,j-1,sum-i);

  dfs(i+1,j,sum);

  return;

}
  

int main() {

  while(cin >> n >> s) {

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

    count=0;

    dfs(0,n,s);

    cout << count << endl;

  }

  return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
int num;  int n,s;
void dfs(int i,int sum,int dp){
  if(sum>s)
    return;
  if(dp==n){
    if(sum==s){
      num++;
      return;
    }else
      return;
  }
  for(int j=i+1;j<=9;j++)
    dfs(j,sum+j,dp+1);
}
int main(){
  while(cin>>n>>s,n+s!=0){
    num=0;
    for(int i=0;i<=9;i++)
      dfs(i,i,1);
    cout<<num<<endl;
  }
  return 0;
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n, k;
  while(cin >> n >> k){
    if(n == 0 && k == 0)break;
    int res = 0;
    rep(i, (1 << 10)){
      int num = 0;
      int sum = 0;
      rep(j, 10){
        if((i >> j) % 2 == 1){
          num++;
          sum += j;
        }
      }
      if(num == n && sum == k)res++;
    }
    cout << res << endl;
  }
	return 0;
}