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

int match_num(int n, int sum, int i_ = 0)
{
  if (sum == 0 and n == 0) return 1;
  if (sum < 0 or n == 0) return 0;
  int result = 0;
  for (int i = i_; i < 9; ++i)
  {
    result += match_num(n - 1, sum - i, i + 1);
  }
  return result;
}

int main(void)
{
  int n, sum;
  while (true)
  {
    cin >> n >> sum;
    if (n == 0 and sum == 0) break;
    cout << match_num(n, sum) << endl;
  }
  return 0;
}

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

map<pair<pair<int,int>,int>,int> memo; 

int BT( int N, int S, int d, int p, int s )
{
	if ( d==N )
		return s==S ? 1 : 0;
	if ( s>S)
		return 0;

	pair<pair<int,int>,int> k = make_pair(make_pair(d,p),s);
	if ( memo.count(k)>0 )
		return memo[k];
	int ans = 0;
	for ( int i=p; i<=S; i++ )
		ans += BT(N,S,d+1,i+1,s+i);
	return memo[k]=ans;
}

int main()
{
	while ( true )
	{
		memo.clear();
		int n, s;
		cin >> n>>s;
		if ( n ==0 && s==0 )
			break;

		cout << BT(n,s,0,0,0) << endl;

	}

	return 0;
}

C++: #include<iostream>

using namespace std;

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

int main(){
  int n,s;

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

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int go(int p, int n, int s) {
	if (n == 0 && s == 0) return 1;
	if (s < 0) return 0;
	int res = 0;
	REP (i, p + 1, 9) res += go(i, n - 1, s - i);
	return res;
}

int main() {
	for (int n, s; cin >> n >> s, (n | s) != 0; ) {
		cout << go(-1, n, s) << endl;
	}
	
	return 0;
}

C++: class Node
  attr_accessor :state, :depth, :path_cost
  attr_reader :parent

  def initialize(state, parent)
    @state = state
    @parent = parent
    @depth = parent.nil? ? 0 : parent.depth + 1
  end

  def goal?(limit, max)
    nums.size == limit && sum == max
  end

  def bad_end?(limit, max)
    nums.length > limit || sum > max
  end

  def nums
    parent.nil? ? [state] : parent.nums << state
  end

  def sum
    nums.inject(:+)
  end
end


  STDIN.read.split("\n").each do |line|
    limit, max = line.split.map(&:to_i)

    next if limit == 0 && max == 0

    goals = []
    10.times do |i|
      init_node = Node.new(i, nil)
      queue = [init_node]
      black_list = [init_node.nums.sort]

      loop do
        break if queue.empty?

        elem = queue.shift

        goals << elem if elem.goal?(limit, max)

        next if elem.bad_end?(limit, max)

        10.times do |j|
          next if elem.nums.include?(j)
          new_node = Node.new(j, elem)
          new_nums = new_node.nums.sort
          next if black_list.include?(new_nums)
          black_list << new_nums
          queue << new_node
        end
      end
    end

    puts goals.map { |e| e.nums.sort }.uniq.size
  end

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

int dp[11][101];

int main(){
  int n,m;
  for(int i=0;i<11;i++)for(int j=0;j<101;j++)dp[i][j]=0;
  for(int i=0;i<=9;i++)dp[1][i]=1;
  for(int i=2;i<=10;i++){
    for(int j=1;j<=100;j++){
      if(j-i>=0)dp[i][j]+=dp[i][j-i];
      if(j-(i-1)>=0)dp[i][j]+=dp[i-1][j-(i-1)];
      if(j>9)dp[i][j]-=dp[i-1][j-10];
    }
  }
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    cout<<dp[n][m]<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x)		(x).begin(),(x).end()

typedef long long		ll;
typedef pair<int, int>	P;

//-------------------------------------------
int n,s;
int ans=0;

void dfs(int nnum,int cnt,int sum){
    //cout << "nnum:" << nnum << "\tcnt:" << cnt << "\tsum;" << sum << "\t lastadded:"<<nnum-1 << "\tans:" << ans << endl;
    if(cnt==n){
        if(sum==s){
            ans++;
        }
        return;
    }
    if(nnum<=9){
        dfs(nnum+1,cnt+1,sum+nnum);
        dfs(nnum+1,cnt,sum);
    }
    return;
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int dp[11][46] = {},i,j,k,x,y;dp[0][0] = 1;
    for(i=0;i<10;i++){
        for(j=i+1;j>=1;j--){
            for(k=i;k<=45;k++) dp[j][k] += dp[j-1][k-i];
        }
    }
    while(true){
        scanf("%d%d",&x,&y);
        if(x == 0 && y == 0) break;
        if(y > 45) printf("0\n");
        else printf("%d\n",dp[x][y]);
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int answer;

void saiki( int number, int sum, int t )
{

	if( number == 0 ){
		if( sum == 0 ){
			answer++;
			return;
		} else {
			return;
		}
	}

	if( sum < 0 ) return;

	if( t > 9 ) return;


	saiki( number - 1, sum - t, t + 1 );

	saiki( number, sum, t + 1 );

}

int main(void)
{
	int number, sum;

	while( cin >> number >> sum && number != 0 && sum != 0 ){
		answer = 0;
		saiki( number, sum, 0 );
		cout << answer << endl;
	}
	return 0;
}