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++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int to, cost; edge(int t, int c) :to(t), cost(c){} };

int main()
{
	//while (cin >> n)
	stringstream ss;
	//ss << "result" << i + 1 << ".txt";
	//FILE* fp_out = freopen(ss.str().c_str(), "w", stdout);

	int n;
	while (cin >> n)
	{
		int s; cin >> s;
		function<int(int, int, int)> dfs = [&](int now, int rem, int sum)
		{
			if (rem == 0 && sum == s) return 1;
			if (now == 10 || rem == 0 || sum > s) return 0;
			return dfs(now + 1, rem, sum) + dfs(now + 1, rem - 1, sum + now);
		};

		cout << dfs(0, n, 0) << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;
 
#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()

#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)

#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
 
#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))
 
typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;
 
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};
int res;
int n,s;
void solve(int a,int b,int c){
    if(b > n || a > s) return;
    REP(i,c+1,10){
        if(a+i == s && b+1 == n){
            ++res;
        }
        else if(b < n && a+i < s){
            solve(a+i,b+1,i);
        }
    }
    return ;
}

int main(){
    while(cin>> n >> s){
        if( n + s == 0) break;
        res = 0;
        if(s <= 55){
            rep(i,10){
                solve(i,1,i);
            }
        }
        cout << res << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <stack>

using namespace std;

struct set { int i, sum, depth; };

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int depth) {
    stack<set> S;
    S.push(set{next, sum, depth});

    while (!S.empty()) {
        set u = S.top();
        if (u.depth == n && u.sum == s) { cnt++; }

        if (u.i == 10 && u.depth == 0 && u.sum == 0) { break; }

        if (u.next < 10 && u.depth < n) {
            S.push(set{u.i + 1, u.sum, u.depth});
            S.push(set{u.i + 1, u.sum + a[u.i], u.depth + 1});
        }
        else if (u.next == 10) {
            int tmp = u.depth;
            while (S.top().depth == tmp) { S.pop(); }
        }
        else { S.pop(); }
    }
}

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

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int n1,s;
int counter = 0;
int dfs(int num,int c,int sum){
    if(sum == s && c == n1 && num<=10){counter++; return 0;}
    if(sum > s || c > n1 || num >9){return 0;}
    dfs(num+1,c+1,sum+num);
    dfs(num+1,c,sum);
    return 0;
}
int main(){
    while(cin >> n1 >> s,n1+s){
        counter = 0;
        dfs(0,0,0);
        cout << counter <<endl;
    }
    
}

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int dp[16][64];

int main() {
    dp[0][0] = 1;
    rep (k, 10) {
        for (int i = 10; i >= 0; i--) {
            rep (j, 64) if (dp[i][j]) dp[i+1][j+k] += dp[i][j];
        }
    }
    for (;;) {
        int n, s;
        scanf("%d%d", &n, &s);
        if (n == 0 && s == 0) return 0;
        printf("%d\n", n < 16 && s < 64 ? dp[n][s] : 0);
    }
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n, s;
    int c; //条件を満たす場合の個数

    while(true){
        cin >> n >> s;
        if(n == 0 && s == 0) break;
        
        c = 0;
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n; j++){
                for(int k = 0; k <= n; k++){
                    if(i + j + k == s) c++;
                }
            }
        }
        cout << c << endl;
    }
}

C++: #include<iostream>
#include<cstring>

using namespace std;

int mark[10],n,m,ans;



void dfs(int d,int sum,int last) {
	if (d == n)  {
		if(sum==m) ans++;
		return;
	}
	else if (sum > m) return;
	for (int i = last; i < 10; i++) {
		dfs(d + 1, sum + i, i + 1);
	}
}
int main() {
	while(1){
		cin >> n >> m;
		if (n == m && n == 0) return 0;
		ans = 0;
		dfs(0, 0, 0);
		cout << ans <<endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef vector<int> comb;

inline int first(int n){
	return ((1 << n) - 1);
}

int nextSet(int x){
	int small, ripple, newSmall,ones;
	
	small = x & -x;
	ripple = x + small;
	newSmall = ripple & -ripple;
	ones = (( newSmall / small ) >> 1) - 1;
	
	return (ripple | ones);
}

comb setComb(int s, int n){
	comb c;
	for(int i=1 ; i<=n ; i++){
		if( s & 1)c.push_back(i-1);
		s >>= 1;
	}
	return c;
}

int main(){
	int n=10, k, x, s, sum, ans;
	comb c;
	
	while( cin >> k >> s , k || s){
		ans = 0;
		x = first(k);
		while( !(x & ~first(n) ) ){
			c = setComb( x , n );
			sum = 0;
			for(int i=0 ; i<c.size() ; i++){
				sum += c.at(i);
			}
			if(sum==s) ans++;
			x = nextSet( x );
		}
		cout << ans << endl;
	}
}