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

int n;
int s;

int main() {
  while (1) {
    scanf("%d%d", &n, &s);
    if (n == 0 && s == 0) return 0;

    int lim = 1 << 10;
    int ans = 0;
    for (int i=0; i<lim; i++) {
      int sum = 0;
      int cnt = 0;

      for (int j=0; j<10; j++) {
        if (i >> j & 1) {
          sum += j;
          cnt++;
        }
      }

      if (sum == s && cnt == n) ans++;
    }

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
/*
for(int bit = 0 ; bit < (1<<10) ; bit++){
	for(int j = 0 ; j < 10 ; j++){
		if( i & (1<<j) ){
			//なにか
		}
	}
}
*/
	/*
	箱2つあって
	/*
		00
		10
		01
		11
	
	for(int i = 0 ; i < 4  ; i++)
		int a = (i >> 0) & 1;
		int b = (i >> 1) & 1;
	}
	/*
	0000000000~
	1111111111
	 (10000000000)
	 cout << (1<<3) << endl;
	*/
int main(){
	int n,s,i;
	while(1){
	cin>>n;
	cin>>s;
		if(n==0 && s==0)
		break;
	int ans=0;
	for(int bit = 0 ; bit < (1<<10) ; bit++){
		int p[10]={},a=0,x=0;
	for(int j = 0 ; j < 10 ; j++){
		if( bit & (1<<j) ){
			p[j]=1;;
			a++;
		}
	}
		//cout<<a<<" ";
		
		if(a==n){
			for(i=0;i<10;i++){
				if(p[i]==1)
				x+=i;
				//cout<<i;
			}
			//cout<<endl;
			if(x==s)
			ans++;
		}
	}
		cout<<ans<<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 (it == 10){
      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>
using namespace std;
int n, s, sum = 0;
void f(int*,int);

int main() {
	while (1) {
		cin >> n >> s;
		if (n == 0 && s == 0)
			break;
		int *a;
		a = new int[n];
		f(a, 0);
		cout << sum << endl;
		sum = 0;
		delete[] a;
	}
	return 0;
}

void f(int *a, int x) {
	if (x == 0)
		a[0] = 0;
	else
		a[x] = a[x - 1] + 1;
	if (x == n - 1) {
		for (; a[x] < 10; a[x]++) {
			int y = 0;
			for (int i = 0; i < n; i++) {
				y += a[i];
				//cout << a[i] << " ";
			}
		//	cout << endl;
			if (y == s)
				sum++;
		}
		return;
	}
	for (; a[x] <= 10 - n + x; a[x]++)
		f(a, x + 1);
	return;
}

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++: #define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int test(int n, int s, int i){//n個でsを作る
	//cout << n <<" "<<s<<" "<<i<<endl;
	if(n==0){
		if(s==0){
			return 1;//作れた
		}else{
			return 0;
		}
	}
	if(i>=10 || s-i<0){
		return 0;
	}

	return test(n, s, i+1) + test(n-1, s-i, i+1);
}

int main(){
	
	int km[11][101]={0};
	
	for(int i=0;i<10;i++){
		km[1][i]=1;
	}
	/*
	for(int i=1;i<9;i++){
		for(int j=i-1;j<101;j++){
			for(int k=j;j+k<101;k++){
				if(i+1==3 && j+k==6) cout << i << " "<< j<<" "<<k<<" "<<km[i][j]<<endl;
				if(j!=k){
				km[i+1][j+k]+=km[i][j];
				}else{
					km[i+1][j+k]+=1;
				}
			}
		}
	}
	*/
	/*
	for(int i=2;i<=10;i++){
		/*
		for(int j=0;j<101;j++){
			if(km[i-1][j]){
				for(int k=j+1;k<=10&&j+k<101;k++){
					if(i==3 && j+k==6) cout << j<<" "<<k<<endl;
					
					km[i][j+k]+=km[i-1][j];
				}
			}
		}
		
		for(int j=0;j<10;j++){
			for(int k=0;k<101;k++){
				if(km[i-1][k]&&k>j){
					if(i==3 && k+j==1) cout << j<<" "<<k<<endl;;
					km[i][k+j]++;
				}
			}
		}
	}
	*/
	/*
	for(int i=2;i<=10;i++){//２個で作る組み合わせから計算
		for(int j=0;j<101;j++){//横に調べて行って
			if(km[i-1][j]){//もしあれば
				for(int k=i-1;k<10;k++){
					if(i==2 && k+j==3) cout << j<<" "<<k<<endl;
					km[i][j+k]++;
				}
			}
		}
	}

	for(int i=0;i<10;i++){
		for(int j=0;j<30;j++){
			cout << km[i][j]<<" ";
		}
		cout << endl;
	}
	cout << km[3][6];
	*/
	/*
	int n, s;
	while(cin >> n >> s){
		if(n==0 && s==0) break;
		cout << km[n][s] << endl;
	}
	*/

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

C++: #include <stdio.h>
int ans;
void f(int n,int l,int s){
	if(n==0){
		if(s==0)ans++;
		return;
	}
	for(int i=l;i<=9;i++)f(n-1,i+1,s-i);
	return;
}
int main(){
	int n,s;
	while(1){
		scanf("%d%d",&n,&s);
		if(n==0&&s==0)return 0;
		ans=0;
		f(n,0,s);
		printf("%d\n",ans);
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int factorial(int n){
	int x = 1;
	for(int i=1;i<=n;++i){
		x*=i;
	}
	return x;
}
int solve(int *used,int n,int sum,int target,int count){
	if(n==0){
		if(sum==target)return count+1;
		return count;
	}
	for(int i=0;i<10;++i){
		int u[10];
		for(int j=0;j<10;++j)u[j]=used[j];
		if(used[i]==0){
			u[i]=1;
			count = solve(u,n-1,sum+i,target,count);
		}
	}
	return count;
}
int main(void){
	int n,s;
	while(cin>>n>>s,n,s){
		int used[10]={0};
		int count = solve(used,n,0,s,0);
		cout<<count/factorial(n)<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int cnt[101][10];
void rec(int idx, int d, int n){
  if(d >= 10)return;
  for(int i = idx+1 ; i < 10 ; i++){
    cnt[n+i][d+1]++;
    rec(i,d+1,n+i);
  }
}
void calc(){
  rec(-1,0,0);
}
int main(){
  calc();
  int n,s;
  while(cin >> n >> s, n||s){
    cout << cnt[s][n] << 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 <stdio.h>
#include <string.h>

int dp[20][60][20];

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;
}