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;

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

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
  int n, s;

  while(cin >> n >> s, n+s) {
    bool b[10];
    REP(i, 10) {
      if(i < 10-n) b[i] = false;
      else b[i] = true;
    }

    int cnt = 0;
    do {
      int S = 0;
      REP(i, 10) {
	if(b[i]) S += i;
      }
      if(S == s) cnt++;
    } while(next_permutation(b, b+10));

      cout<< cnt << endl;
  }
}

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

/** Problem0030 : Sum of Integer **/
int cnt, ans;

void solve(int i, int s, int n)
{
	if (n==0 && s == ans) {
		cnt++;
		return;
	}
	
	if (n==0 || i>9)
		return;
	
	solve(i+1, s+i, n-1);
	solve(i+1, s, n);
}

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

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

using namespace std;

int main()
{
  unsigned n, s;
  
  while(cin >> n >> s, (n != 0 || s != 0)) {
    vector<unsigned> no(9);
    unsigned cnt = 0, sum = 0, i, k, max = 0, min = 0;
    for(i = 0; i < n ; i++){
      no[i] = i;
      min += i;
      max += 9 - i;
    }
    if(max < s || min > s) { cout << 0 << endl; continue; }
    cnt = 0;
    while(1) {
      //for(i = 0; i < n; i++) cout << i << no[i] << "  ";
      //cout << endl;
      for(k = sum = 0; k < n; k++) {
	sum += no[k];
      }
      if (sum == s) cnt++;
      //cout << sum << endl;
      if (sum >= s) no[n - 1] = 9;
      no[n - 1]++;
    
	for(k = n - 1; k > 0; k--) {
	  if(no[k] > 9 -  n  +  k + 1) {
	    no[k - 1]++;
	    for(i = k; i < n; i++) {
	      no[i] = no[i - 1] + 1;
	    } 
	  }
	}
	if(no[0] > 9 - n + 1) break;	    
    }
    cout << cnt << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int n,s;
int c;

void search(int a,int sum,int before){
  FOR(i,before,s){
	if(sum+i>s) continue;
	if(a<n) search(a+1,sum+i,i+1);
	else if(sum+i==s) {
	  //	  cout << i <<" "<< a <<" " << sum << " " << before-1 << endl;
	  c++;
	}
  }
}

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

	cout << c << endl;

  }
}

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


int dp[10][110];


void makeDP(){
	dp[0][0] = 1;
	for(int i = 0;i <= 9;i++){
		for(int j = 100;j >= i;j--){
			for(int k = 9;k >= 1;k--){
				dp[k][j] += dp[k-1][j-i];
			}
		}
	}
}


int main(){
	int n, s;

	makeDP();

	while(cin >> n >> s, n || s) cout << dp[n][s] << endl;
	
	return 0;
}

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

// n個の重複しない整数(min ~ max)の和としてsを表す組み合わせの数
int ci(int n, int s, int min, int max) {
  // 特殊なパターンを処理
  if (s < min || n < 1) return 0;
  if (n == 1) return (s > max)? 0: 1;
  
  // 最も小さい数で場合分けし再帰処理
  int r = 0;
  for (int i=min; i<s && i<=max; i++) r += ci(n - 1, s - i, i + 1, max);
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, 9) << endl;
  }
  return 0;
}

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

int search(int i, int left, int count){
	if(i == 10){
		return left == 0 && count == 0;
	}
	return search(i + 1, left, count) + search(i + 1, left - i, count - 1);
}

int main(){
	int n, s;

	scanf("%d%d", &n, &s);

	std::cout << search(0, s, n) << std::endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(k,i,n) for(int i = (k); i < (int)(n); i++)

int cnt(int k,int n,int s){
    int c=0;
    if(n==1&&s>=k&&s<=9) return 1;
    else if(n==1) return 0;
    for(int i=k;i<=9-n+1;i++){
        c+=cnt(i+1,n-1,s-i);
    }
    return c;
}

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

C++: #include<map>
#include<list>
#include<cmath>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;

int A[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int cunt = 0;

void depth(int n, int s, int i){
	
	if (n == 0 && s == 0){
		cunt++;
		return;
	}
	else if (n == 0) return;
	else if (s < 0) return;
	else if (i == 10) return;


	depth(n - 1, s - A[i],i+1);
	depth(n, s, i+1);

}

int main(){
	int n, s;
	while (cin >> n >> s){
		if (n == 0 && s == 0) break;
		depth(n, s, 0);
		cout << cunt << endl;
		cunt = 0;
	}
	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 ) {
		if ( n == 0 && s == 0 ) break ;
		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 ;
		}
	}
}