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 <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int kaizyo(int x){
    if(x==1)return x;
    else return x*kaizyo(x-1);
}

vector<int> v(10);
int n,s;
int ans=0;
void dfs(int sum,int ct,int i){
    if(i==10)return;
    if(ct==n){
        if(sum==s)ans++;
        return;
    }
    dfs(sum+v[i],ct+1,i+1);
    dfs(sum,ct,i+1);
    return;
}
int main() {
    rep(i,0,10)v[i]=i;
    while(1){
        ans=0;
        cin>>n>>s;
        if(n==0&&s==0)break;
        dfs(0,0,0);
        cout<<ans<<endl;
    }
  
    return 0;
}

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

using namespace std;

int main() {
    while(true) {
        int N, S;
        cin >> N >> S;
        if(!N && !S) break;

        int arr[10] = {0};
        for(int i = 0; i < N; ++i) arr[9-i] = 1;
        int cnt = 0;
        do {
            int sum = 0;
            for(int i = 0; i < 10; ++i)
                if(arr[i]) sum += i;
            if(sum == S) ++cnt;
        } while(next_permutation(arr, arr+10));

        cout << cnt << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  int pattern[64];
  int n;
  Solver(int n) : n(n) {
    memset(pattern, 0, sizeof(pattern));
  }
  void solve(int it=0, int c=0, int s=0){
    if (c == n){
      pattern[s]++;
      return;
    }
    if (it == 10) return;

    solve(it + 1, c + 1, s + it);
    solve(it + 1, c, s);
  }
};

int main()
{
  int n, s;
  while (n = in(), s = in(), n != 0 && s != 0){
    Solver solver(n);
    solver.solve();
    if (s < 64){
      printf("%d\n", solver.pattern[s]);
    }
    else puts("0");
  }

  return 0;
}

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

int n, s;

int dfs( int a, int m, int c ){
    if(a == s && c == n) return 1;
    if(a > s || c > n) return 0;
    if(m > 9) return 0;
    int t = 0;
    for(int i = m; a+i <= s && i < 10; i++){
        t += dfs(a+i, i+1, c+1);
    }
    return t;
}

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

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

using namespace std;

struct set { int i, sum, depth; };

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int depth) {
    stack<set> S;
    S.push(set{i, sum, depth});

    while (!S.empty()) {
        set u = S.top();
        if (u.depth == n && u.sum == s) { cnt++; }

        if (u.i == 10 && u.depth == 0 && u.sum == 0) { break; }

        if (u.i < 10 && u.depth < n) {
            S.push(set{u.i + 1, u.sum, u.depth});
            S.push(set{u.i + 1, u.sum + a[u.i], u.depth + 1});
        }
        else if (u.i == 10) {
            int tmp = u.depth;
            while (S.top().depth == tmp) { S.pop(); }
        }
        else { S.pop(); }
    }
}

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

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

int main()
{
  int n, s;
  int i, ,j, tmp;
  int sum, count;
  int ans

  while(cin>>n>>s){
    if(n+s==0) break;

    ans=0;
    for(i=0; i<1024; i++){
      tmp=i; sum=0; count=0;
      for(j=0; j<10; j++){
        if(tmp%2==1){
          sum+=i;
          count++;
        }
        tmp=tmp>>1;
      }
      if(count==n && sum==s) ans++;
    }
    printf("%d\n", ans);
  }

  reutrn 0;
}

C++: #include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int n,s;
	while(cin>>n>>s,n||s){
		if(n>10||s>45){
			cout<<0<<endl;
			continue;
		}
		int min = (int)pow(10.0,n-2);
		int lim = (int)pow(10.0,n);
		stack<int> st;
		vector<int> res;
		vector<bool> vis(lim,false);
		st.push(0);
		vis[0]=true;
		while(!st.empty()){
			int top = st.top();
			int tmp=top;
			int cur=0;
			while(tmp>0){
				cur+=tmp%10;tmp/=10;
			}
			st.pop();
			if(top>min&&cur==s){
				res.push_back(top);
			}else{
				if(top*10>=lim) continue;
				for(int i=top%10+1;i<10;++i){
					if(!vis[top*10+i]){
						vis[top*10+i]=true;
						st.push(top*10+i);
					}
				}
			}
		}
		cout<<res.size()<<endl;
	}
	return 0;
}