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 <string.h>
using namespace std;

int memo[10][1000][20];
//3,2,1
int dfs(int c,int h,int m)//c:選んだ回数、h:残りの数字、m以下の数字から選ぶ
{
	if(c==0&&h==0)
		return 1;
	if(h<0||m<0||c<0)
		return 0;
	if(memo[c][h][m] != -1)
		return memo[c][h][m];
	int res = 0;
	for(int i=0;i<=m;++i){
		res += dfs(c-1,h-i,i-1);
	}
	memo[c][h][m] = res;
	return res;
}

int main(void)
{
	while(1){
		int n,s;
		cin >> n >> s;
		if(n==0&&s==0)
			return 0;
		memset(memo,-1,sizeof(memo));
		if(n>10 || s>100)
			cout << 0 << endl;
		cout << dfs(n,s,9) << endl;
	}
	return 0;
}

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

int t;
int n[10];

void sousa(int a, int b){
	for(n[a-1] = 9; n[a-1] >= 0; n[a-1]--){
		if(a-1 < 0 || b < 0){
			cout << "out" << endl;
			break;
		}
		else if(a-1 == 0 && b-n[a-1] == 0){
			cout << "ok" << endl;
			t++;
			break;
		}
		else{
			cout << "lasting" << endl;
			sousa(a-1, b-n[a-1]);
		}
	}
}
int main(){
	vector<int> array;
	int n, m;
	while(cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		if(m > 45){
			array.push_back(0);
			continue;
		}
		t = 0;
		sousa(n, m);
		array.push_back(t);
	}
	for(int i = 0; i < array.size(); i++){
		cout << array[i]/2 << endl;
	}
}

C++: #include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int dp[11][353][1252];
 
int dfs(int cnt, int msk, int cur){
  if(cnt>10 || cur>330) return 0;
  if(cnt == 0) return (cur==0?1:0);
  if(dp[cnt][cur][msk] != -1) return dp[cnt][cur][msk];
  dp[cnt][cur][msk] = 0;
  REP(i,10){
    if(msk&(1<<i))continue;
    int nmsk = msk | (1<<i);
    int ncur = cur - i;
    if(ncur >= 0){
      dp[cnt][cur][msk] += dfs(cnt-1,nmsk,ncur);
    }
  }
  dp[cnt][cur][msk] /= cnt;
  return dp[cnt][cur][msk];
}
 
int main(){
  REP(i,11)REP(j,353)REP(k,1252)dp[i][j][k] = -1;
  int n,s;
  while(~scanf("%d%d",&n,&s)){
    if(n==0 && s==0)break;
    cout<<dfs(n,0,s)<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

void dfs(int n,int s,int k);

int ans=0;

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

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

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

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int n, s;
int ans = 0;

void dfs(int pos, int sum,int count) {
	if (count == n) {
		if (sum == s) {
			ans++;
			return;
		}
		else {
			return;
		}
	}
	if (sum > s)return;
	if (pos > 9)return;
	dfs(pos + 1, sum + pos,count+1);
	dfs(pos + 1, sum,count);
}

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

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

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

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

C++: #include <iostream>

using namespace std;

int count(int m, int n, int s) {
    if (n == 1) {
        if (s >= m) return 1;
        return 0;
    }
    int c = 0;
    for (int i = m; i < 9; i++) {
        c += count(i + 1, n - 1, s - i);
    }
    return c;
}

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

C++: #include<bits/stdc++.h>
using namespace std;
 
int N,S;
int dfs(int n,int t,int sum){
    if(n==10)return 0;
    if(t==N){
          if(sum==S)return 1;
          else return 0;
    }
    return dfs(n+1,t,r)+dfs(n+1,t+1,r+n);
}
int main(){
    while(cin>>N>>S,n||s)cout<<dfs(0,0,0)<<endl;
    return 0;
}

C++: #include <iostream>

//n : n????????°???????¶?????????§
//s : ?????????s?????????
int n, s; // 3 1
int ans;

void dfs(int a, int sum, int bmax) {
	if(a < n) {
			for(int i = bmax; i <= 9; ++i) {
				if(sum + i <= s)
					dfs(a + 1, sum + i, i + 1);
			}
	}
	else if(a == n) {
		if(s == sum)
			++ans;
	}
}

int main() {
	while(std::cin >> n >> s, !(n == 0 && s == 0)) {
		dfs(0, 0, 0);
		
		std::cout << ans << std::endl;
		
		ans = 0;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

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

using namespace std;

typedef pair<vector<int>, int> data;

/*
全探索
9! = 362880 余裕

持っている配列、ステップ数
*/

int sum(vector<int> nums) {
    int sum = 0;
    REP(i, nums.size()) {
        sum += nums[i];
    }
    return sum;
}

bool insertable(int num, vector<int> nums) {
    REP(i, nums.size()) {
        if ( num == nums[i] ) return false;
    }
    return true;
}

int dump(vector<int> n) {
    REP(i, n.size()) {
        cout << n[i] << " ";
    }
    cout << endl;
}

int main() {
    int n, s;

    while(cin >> n >> s, n||s) {
        queue<data> open;
        int cnt = 0;

        // 初期値をpush
        REP(i, 10-(n-1)) {
            vector<int> num(n);
            num[0] = i;
            open.push( MP(num, 1) );
        }

        while(!open.empty()) {
            data d = open.front(); open.pop();
            vector<int> nums = d.first;
            int c = d.second;

            // cout << c << " " << n << endl;
            if ( c == n ) {
                if ( s == sum(nums) ) {
                    cnt++;
                    // dump(nums);
                }
                continue;
            }

            for ( int i = nums[c-1]; i <= 9; i++ ) {
                if ( insertable(i, nums) ) {
                    nums[c] = i;
                    open.push( MP(nums, c+1) );
                }
            }
        }
        cout << cnt << endl;
    }
    
    return 0;
}