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<cstdio>
#define REP(i,a,n) for(int i = 0;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
void func(int num);
int in(){int n;scanf("%d",&n); return n;};
 
int flag[10] = {0};
int num2,ans;
int main(void){
 while(1){
  ans = 0;
  int num = in(); num2 = in();
  if(num == 0 && num2 == 0) break;
  func(num);
  printf("%d\n",ans);
 }
 return 0;
}
 
void func(int num){
 if(num == 0){
  int n = 0;
  rep(i,10){if(flag[i]) n+= i;}
  if(n == num2) ans++;
  return;
 }
 rep(i,10){
  if(flag[i] == 1) return;
  flag[i] = 1;
  func(num-1);
  flag[i] = 0;
 }
 return;
}

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

int cou;
int n,s,k=9;
void sum(int right, int left, int loop_c){
	if( left < 0 ) return;
	if( right < 0 ) return;
	if( right == 0 && loop_c == 0) cou++;
	sum( right-left , --left, --loop_c);
	sum( s , left , n );
}

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

C++: #include <iostream>
#include <sstream>
#define SSTR( x ) static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
using namespace std;

// n個の重複しない整数 (min~) 用いてsを表す組み合わせの数
int ci(int n, int s, int min, string str) {
  if (s < min) return 0; else if (n < 1) return 0; else if (n == 1) {
    //cout << str + SSTR(s) << endl;
    return 1;
  }
  int r = 0;
  for (int i=min; i<s; i++) {
    r += ci(n - 1, s - i, i + 1, str + SSTR(i) + " ");
  }
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, "") << endl;
  }
  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[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 hoge(int b, int n, int s) {
    if (n == 1)
        return (0 <= s && s <= 9 && b <= s)? 1 : 0;
    int sum = 0;
    for (int i = b; i <= 9; ++i)
        sum += hoge(i+1, n-1, s-i);
    return sum;
}

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

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

using namespace std;
const int N = 12;
int n, s;
int ans = 0;
typedef pair <int, int> pii;
map <pii, int> m;

int suma(int a) {
	int tot = s * (s + 1) / 2;
	return tot - a * (a + 1) / 2;
}

void bt(int sum, int index, int pos) {
	if(sum == 0 && pos == n) {
		ans++;
		return;
	}
    if(pos == n) return;
	if(sum < 0) return;
	for(int i = index; i <= min(9, s); i++) {
		bt(sum - i, i + 1, pos + 1);
	}
}



int main() {
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	while(true) {
	    cin >> n >> s;
	    if(!n && !s) return 0;
	    pii p = make_pair(n, s);
	    if(!m.count(p)){
	    	bt(s, 0, 0);
	    	m[p] = ans;
		}
	    else
	    	ans = m[p];
	    cout << ans << "\n";
	    ans = 0;
	}
    return 0;
}

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

static int m;

void p(int s,int n,int a[],int j) {
	int i;
	int hokanj=0;
	if(s<0)return;
	if(s==0 && n==0){m++;return;}
	for(i=j+1;i<=9;i++){
		if(a[i]==0){a[i]=1;s-=i;hokanj=j;j=i;p(s,--n,a,j);}
		a[i]=0;s+=i;++n;j=hokanj;
	}
	return;
	
}
int partition(int s,int n, int a[]) {
	p(s,n,a,-1);
	return m;
}

int main(void){
	int s=1,n=1;
	while(scanf("%d %d",&n,&s)>0 && (n!=0 || s!=0)){
		m=0;
		int a[]={0,0,0,0,0,0,0,0,0,0};
		partition(s, n, a);
		printf("%d\n",m);
	}
	return 0;
}

C++: #include<iostream>
 
int res = 0;

#include <iostream>
using namespace std;

 
int a[10]={0,1,2,3,4,5,6,7,8,9};
int S;	int N;
 	//N←枚数 S←合計 K
int solve(int i,int sum,int used){
	int count,ct=0;
if(i==10){
	//cout<<sum<<" ";確認用
	if(sum==0&&ct==0)return count;//「深さが10でsumが0」が二度目なら終了
	if(sum==0)ct++;//a[0]を使った場合の0と使わない場合の0がある。	
		if(sum==S&&used==N)count++;
		
		used--;
  		return 0;
  	}
	if(solve(i+1,sum+a[i],used=used+1)!=0)return count;
	if(solve(i+1,sum,used)!=0)return count;
	
	used--;
 return 0;
}	

int main(void){
    cin>> N>>S;
    cout<<solve(0,0,0)<<endl;

}

C++: #include<iostream>
using namespace std;
int ans(int n, int m, int x);
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    cout <<ans(n,m,0)<<endl;
  }
  return 0;
}
int ans(int n, int m, int x){
  int a=0;
  if(n == 0 && m == 0) return 1;
  if(n>0) for(int i=x; i<10; i++) if(m-i>=0) a+=ans(n-1,m-i,i+1);
  return a;
}

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 (it > 9) return;
    if (c == n){
      pattern[s]++;
      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>
# 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&&sum == s) {
		ans++;
		return;
	}
	if (pos == 10 || count == n)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;
	}
}