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 <algorithm>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    bool end = false ;
    while (end == false)
    {
        int n,s ;
        cin >> n >> s ;
        if (n == 0 && s == 0)
        {
            //0 0が来たら終わり
            end = true ;
            break ;
        }
        int ans = 0;
        //明らかに0のパターンはサボる
        if (s < n*(n-1)/2 || s > 9*n - n*(n-1)/2)
        {
            cout << 0 << endl ;
            continue ;
        }
        //ビット操作的な何かで、iの1ビット目を0の有無、2ビット目を1の有無...
        //というように対応させていく

        for (size_t i = 0; i < 1024; i++)
        {
            int num = i ;
            vector<int> a(10,0) ;
            //0~9それぞれについて、選ばれているかを管理する配列
            //a.at(i)→iがあれば1,なければ0
            for (size_t j = 0; j < 10; j++)
            {
                a.at(j) = num % 2 ;
                num = num /2 ;
            }
            //配列内の数の和＝要素数
            int youso = std::accumulate(a.begin(),a.end(),0) ;
            //要素数が一致したら和が一致するか判定する
            if (youso == n)
            {
                int sum = 0 ;
                for (size_t j = 0; j < 10; j++)
                {
                    if (a.at(j)==1)
                    {
                        sum += j ;
                    }
                    
                }
                if (sum == s)
                {
                    ans ++ ;
                }
                
            }
             
        }
        
        cout << ans << endl ;
        
    }
    return 0 ;
}

C++: #include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int n,s,ans;

void func(int x,int y,int z){
	if(!x&&!y){
		ans++;
		return;
	}
	if(!x||y<=0) return;
	for(int i=z;i<10;i++) func(x-1,y-i,i+1);
}

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

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

C++: #include<cstdio>
#include<vector>
using namespace std;
vector<int>combination(int n,int from){
  if(n<=0){return vector<int>{0};}
  vector<int> result;
  for(int i=from;i<10;i++){
    for(int r:combination(n-1,i+1)){
      result.push_back(r+i);
    }
  }
  return result;
}
int main(){
  int n,s;
  while(scanf("%d %d",&n,&s)>0){
    if(!(n|s)){break;}
    int count =0;
    for(int a:combination(n,0))
      if(a==s) count++;
    printf("%d\n",count);
  }
}

C++: #include <stdio.h>

int n,s;

int ans;

//depth first search
void dfs(int i,int sum,int n) {

  //³ð
  if((sum==s) && (n==0)) {

    ans++;
    return;

  }

  //s³ð
  if((i==10) || (n==0)) return;

  //Tõr
  dfs(i+1,sum,n); //iðgíÈ¢p^[(±êð»êÈãÅ«È­ÈéÜÅ±¯é)
  dfs(i+1,sum+i,n-1); //iðg¤p^[

}

int main(void) {

  while(scanf("%d %d",&n,&s)!=EOF) {

    if((n==0) && (s==0)) break;

    ans=0;

    dfs(0,0,n);

    printf("%d\n",ans);

  }

  return 0;

}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int dp[105][10][10], s, n;
int f(int a, int b, int c) {
  if(dp[a][b][c] != -1) return dp[a][b][c];
  if(a == s && c == n && b <= 10) return 1;
  if(a > s || c > n || b == 10) return 0;
  int res = 0;
  res += f(a+b, b+1, c+1);
  res += f(a, b+1, c);
  return dp[a][b][c] = res;
}

signed main(void)
{
  while(1) {
    cin >> n >> s;
    if(!n && !s) break;
    REP(i, 105) REP(j, 10) REP(k, 10) dp[i][j][k] = -1;
    cout << f(0, 0, 0) << endl;
  }
  return 0;
}

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

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

int main(void) {
    int n;
    while(cin >> n >> key, n + key != 0) {
        cout << dfs(n, 0, 0) << endl;
    }
    return(0);
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
//#include <map>

using namespace std;

int n,s,ans = 0;

bool dfs(int i, int cnt, int sum,vector <int> v){
	//??±???????????¢?´¢
	
	
	//for (int j = 0; j < v.size(); j++){
	//	cout << v[j] << " ";
	//}
	//cout << endl;
	

	if (i == 10)return true;



	if (cnt == n){
		if (sum == s) ans++;
		return true;
	}

	for (int j = 0; i < v.size(); j++){
		if (v[j] == i)return true;
	}


	//nouse
	dfs(i + 1, cnt, sum, v);

	//use
	v.push_back(i);
	dfs(i + 1, cnt + 1, sum + i,v);

	return false;

}

int main(){

	vector <int> v;

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

		dfs(0, 0, 0, v);

		cout << ans << endl;
	}


	return 0;
}