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 iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  for (int n,s; cin >> n >> s && (n||s);) {

    int ans = 0;

    for (int b = 0; b < (1<<10); ++b) {
      int sum = 0;
      int cx = 0;
      rep(i, 10) {
        if (b & (1 << i)) {
          ++cx;
          sum += i;
        }
      }
      if (cx == n && sum == s) {
        ++ans;
      }
    }

    cout << ans << endl;

  }

  return 0;
}

C++: #include <stdio.h>
#include <string.h>

int dp[11][55][11];

int cnt_sum(int n, int s, int x){
  if(dp[n][s][x] != -1){
    return dp[n][s][x];
  }
  if(n == 0 && s == 0){
    return (1);
  }
  if(x>9){
    return (0);
  }
   
  return dp[n][s][x] = (cnt_sum(n-1, s-x, x+1) + cnt_sum(n, s, x+1));
}
int main(){
  int n, s;
  memset(dp,-1,sizeof(dp));
  while(1){
    scanf("%d %d", &n, &s);
    if(n == 0 && s == 0){
      break;
    }
    printf("%d\n", cnt_sum(n, s, 0));
  }
  return 0;
}

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

int main(){

  int n, s;
  int soi[10][101] = {};
	
	soi[1][0] = 1;
	
	for(int i=1; i<=9; i++){
		for(int j=i; j>0; j--){
			for(int k=0; k<=100; k++){
				if(soi[j][k] != 0){
					soi[j+1][k + i] += soi[j][k];
				}
			}
		}
		soi[1][i] = 1;
	}
	
	while(1){
		cin >> n >> s;
		if(n == 0 && s == 0) break;
		
		cout << soi[n][s] << endl;
		
	}

  return 0;

}

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

int s,ans;

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

int main()
{
  int n,sum,integer;
  for(;;){
    sum=0,integer=0,ans=0;
    cin>>n>>s;
    if(!(n|s)) break;
    find(sum,integer,n);
    cout<<ans<<endl;
  }
}

C++: #include<cstdio>
using namespace std;
int s;
int func(int now,int sum,int num){
	int count=0;
	if(!num)return s==sum?1:0;
	if(now==10 || !num || sum>s) return 0;
	count+=func(now+1,sum+now,num-1);
	count+=func(now+1,sum,num);
	return count;
}

int main(void){
	int n,i;
	while(scanf("%d %d",&n,&s),n){
		printf("%d\n",func(0,0,n));
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int serch(int n,int s,int now,int re,int k)
{
    if(k==n&&re+now==s)return 1;
    if(now-1<0)return 0;
    if(re+now<s)serch(n,s,now-1,re+now,k+1);
    if(re+now>s)serch(n,s,now-1,re,k);
}
int main()
{
    int n,s,ans;
    while(1){
        cin>>n>>s;
        if(n==0&&s==0)break;
        if(9*n<s)ans=0;
        else ans=serch(n,s,9,0,1);
        cout<<ans/2<<endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,s,j,k;
  int 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]++;
    cout <<n << "," << s << endl;
  }
  for(;n||s;cin>>n>>s)cout<<a[n][s]<<endl;
}

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

int func(int num, int rest, int before){
	//if(before + 1 < 0) return 0;
	if(num == 0){
		if(rest == 0){
			//cout << before << endl;
			return 1;
		}
		return 0;
	}
	int res = 0;
	for(int i = 0; i <= rest && i <= before; ++i){
		res += func(num - 1, rest - i, i - 1);
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, s;
	while(cin >> n >> s && n != 0 && s != 0){
		cout << func(n, s, 9) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
//#include <fstream>
using namespace std;
int ans,n,s;
 
void dfs(int cnt,int sum,int i){
	if(sum==s&&cnt==n){
        ++ans;
        return;
    }
    if(sum>s||cnt>n||i>9){
        return;
    }
    dfs(cnt,sum,i+1);
    dfs(cnt+1,sum+i,i+1);
    return;
};
 
int main(){
    while(cin>>n>>s&&n&&s){
        ans=0;
        dfs(0,0,0);
        cout << ans << "\n";
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int ans = 0;

int dfs(int depth, int sum, int before) {
    int ret = 0;
    if(depth == 0) {
        if(sum == ans) return(1);
        else           return(0);
    }
    if(sum > ans) return(0);
    if(before > 9) return(0);
    for(int r = before; r <= 9; r++) {
        ret += dfs(depth - 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    cin.tie();
    ios::sync_with_stdio(false);
    while(true) {
        int depth = -1;
        cin >> depth >> ans;
        if(depth + ans == 0) break;
        cout << dfs(depth, 0, 0) << endl;
    }
    
    return(0);
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

bool notuse[10];
int cnt;

void dfs(int n,int k)
{
    if(n==0 && k == 0){
        cnt++;
        return ;
    }else{
        for(int i = 0; i < 10; i++){
            if(notuse[i] && k - i >= 0){
                notuse[i] = false;
                dfs(n-1,k-i);
                notuse[i] = true;
            }
        }
    }
}

int main() 
{
    ll div[9] = {1};
    for(int i = 1; i < 9; i++){
        div[i]=div[i-1]*(i+1);
    }
    while(true){
        int n,s; cin >> n >> s;
        if(n==0 && s == 0) break;
        for(int i = 0; i < 10; i++){
            notuse[i] = true;
        }
        cnt = 0;
        dfs(n,s);
        cout << cnt/div[n-1] << endl;
    }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int solve(int n, int sum, int amax) {
	if (n == 0) {
		if (sum == 0) {
			return 1;
		}
		else {
			return 0;
		}
	}
	else if (amax*n < sum ||0 * n>sum)return 0;
	else {
		int nans=0;
		for (int x =0; x <= amax; ++x) {
			nans+=solve(n-1,sum-x,x-1);
		}
		return nans;
	}
}


int main() {
	while (true) {
		int N,S;cin>>N>>S;
		if(!N)break;
		int ans=solve(N,S,9);
		cout<<ans<<endl;

	}
	return 0;
}