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 n, s, cnt;

void dfs(int i, int sum, int depth) {
    if (depth == n && sum == s) {
        cnt++;
        return;
    }

    if (i == 10 || depth == n || sum > s) return;

    dfs(i+1, sum, depth);
    dfs(i+1, sum + i, depth + 1);
}

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

C++: #include<iostream>
using namespace std;
int c;
int sub(int n, int x, int s, int sum){
	int i;
	if (n == 0){
		if (s == sum){
			c++;
		}
		return 0;
	}
	for (i = x; i <= 10 - n; i++){
		sub(n - 1, i + 1, s, sum+i);
	}
}
int main(void){
	int i, n, s, sum;
	while (1){
		cin >> n >> s;
		if (n == 0 && s == 0){ break; }
		c = 0;
		sub(n, 0, s, 0);
		cout << c << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int n, s;
int ans;

void dfs (int curr, int depth, int sum )
{
	if (sum > s ) return;

	if (depth == n ){
		if (sum == s ) ans++;
		return;
	} // end if

	if (curr >= 10 ) return;

	dfs (curr+1, depth, sum );
	dfs (curr+1, depth+1, sum + curr );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.sum_of_integers", "r", stdin );
	while (scanf ("%d %d", &n, &s ), n, s ){
		ans = 0;
		dfs (0, 0, 0 );
		printf ("%d\n", ans );
	} // end loop
		
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int dfs(int,int);
vector<vector<int>> dp(10,vector<int>(82,-1));
int n,s;
int main(){
	while(1){
		cin>>n>>s;
		if(n==0&&s==0)break;
		dfs(0,0);
	}



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

		}
	}

}

C++: #include <iostream>
using namespace std;
int n,s,c;
void f(int m,int a,int t){
	if(a == n){
		if(t == s) ++c;
	}
	else {
		for(int i = m;i < 10;++i){
			f(i + 1,a + 1,t + i);
		}
	}
	return;
}
int main(){
	while(cin >> n >> s && (n != 0 && s != 0)){
		c = 0;
		f(0,0,0);
		cout << c << endl;
	}
	return 0;
}

C++: #include <iostream>
#define N 9
using namespace std;
int solver(int n, int s, int t){	//t??\????????°n?????§s?????????????????????????????°
	if(n == 0 || s < 0 || t > N) return 0;
	if(n == 1 && s == t) return 1;
	return solver(n-1, s-t, t+1) + solver(n, s, t+1);
}
int main(){
	int n, s;
	while(cin >> n >> s, n){
		cout << solver(n, s, 0);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n,s,o;
void rec(int d,int k,int x){
  if(d>n) return;
  else if(d==n){
    if(x==s) o++;
  }else{
    for(int i=k+1;i<=9;i++){
      rec(d+1,i,x+i);
    }
  }
}
int main(){
  cin >> n >> s;
  while(n!=0){
    o=0;
    rec(0,-1,0);
    cout << o << endl;cin >> n >> s;
  }
}

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

int solve(int i, int n, int s) {
  if(n == 0 && s == 0) return 1;
  if(i > 9 || n < 0 || s < 0) return 0;

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

int main() {
  int n, s;
  while(cin >> n >> s && n && s) {
    cout << solve(0, n, s) << endl;
  }

  return 0;
}

C++: #include <iostream>

int search_combination(int from, int n, int s)
{
    if (n == 1) {
        if (from <= s && s <= 9) return 1;
        else return 0;
    }
    else {
        int cnt = 0;
        for (int i = from; i <= 10 - n; ++i)
            cnt += search_combination(i + 1, n - 1, s - i);
        return cnt;
    }
}

int main()
{
    while (true) {
        int n, s;
        std::cin >> n >> s;
        if (n == 0 && s == 0) break;

        if (s < n * (n - 1) / 2) std::cout << 0 << std::endl;
        else if (n * (19 - n) / 2 < s) std::cout << 0 << std::endl;
        else std::cout << search_combination(0, n, s) << std::endl;
    }
}

C++: #include <iostream>

using namespace std;

bool initComb(bool* b, int n)
{
	if (n>10) return false;
	for (int i=0; i<n; i++) b[i] = true;
	return true;
}

bool nextComb(bool* b)
{
	int pos;
	int last_true_pos;
	for (pos=9; pos>=0; pos--) {
		if (!b[pos]) {
			last_true_pos = pos + 1;
			break;
		}
	}
	for (pos--; pos>=0; pos--) {
		if (b[pos]) {
			b[pos]   = false;
			b[pos+1] = true;
			if (last_true_pos < 10) {
				for (int i=last_true_pos; i<10; i++) b[i] = false;
				for (int i=0; i<10-last_true_pos; i++) b[i+pos+2] = true;
			}
			return true;
		}
	}
	return false;
}

int main()
{
	int n, s;
	
	while (true) {
		cin >> n >> s;
		if (n==0 && s==0) break;
		
		bool isMember[10] = {false};
		if ( !initComb(isMember, n) ) {
			cout << 0 << endl;
			continue;
		}
		
		int count = 0;
		
		do {
			int sum = 0;
			for (int i=0; i<10; i++) sum += isMember[i] ? i : 0;
			if (sum == s) { 
				//for (int i=0; i<10; i++) {
				//	if (isMember[i]) cout << i << " ";
				//}
				//cout << endl;
				count++;
			}
		} while ( nextComb(isMember) );
		
		cout << count << endl;
	}
	
	return 0;
}

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

using namespace std;
const int N = 12;
int n, s;
int ans = 0;

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

int main() {
	while(true) {
	    cin >> n >> s;
	    if(!n && !s) return 0;
	    if(n == 2) {
	    	cout << n / 2 + 1 << "\n";
	    	continue;
		}
	    bt(s, 0, 0);
	    cout << ans - 1 << "\n";
	    ans = 0;
	}
    return 0;
}