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<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int ans = 0;

int int_sum(int n,int sum){
	vector<vector<int> > v(n+1, vector<int>(sum+1, 0));
	v[0][0] = 1;
	for (int i = 0;i <10;i++) {
		for (int j = n;j >= 1;j--) {
			for (int k = i;k <= sum;k++) {
				v[j][k] += v[j - 1][k - i];
			}
		}
	}
	return v[n][sum];
	
}
int main(){
	int n, sum;
	while (cin >> n >> sum) {
		if (n == 0 && sum == 0) break;
		else cout << int_sum(n, sum) << endl;
	}

	}

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

using namespace std;

int n,s,ans;
int use[10];

void solve(int now,int kei){
	if(now==n){
		if(s==kei){
			ans++;
		}
		return;
	}

	for(int i=0;i<=9;i++){
		if(use[i]==0){
			use[i]=1;
			solve(now+1,kei+i);
			use[i]=0;
		}
	}
}

int main(void){

	while(1){
		cin>>n>>s;
		ans=0;
		for(int i=0;i<10;i++) use[i]=0;
		if(n==0||s==0) break;
		solve(0,0);
		cout<<ans/6<<endl;
	}

	return 0;
}

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;
		return;
	}
	else {
		if(t > s) return;
		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>
using namespace std;

int cnt, n, s;
bool used[10];

void rec(int pos, int t, int sum ){
    if ( t == n ){
	if ( sum == s ) cnt++;
	return;
    }
    if ( pos > 9 ) return;

    rec(pos+1, t, sum);
    rec(pos+1, t+1, sum + pos);
}   
 
main(){
    while( cin >> n >> s ){
	if ( n == 0 && s == 0 ) break;
	cnt = 0;
	rec(0,  0, 0);
	cout << cnt << endl;
    }
}

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 p[10]={},a,x,ans;
	for(int bit = 0 ; bit < (1<<10) ; bit++){
	for(int j = 0 ; j < 10 ; j++){
		if( bit & (1<<j) ){
			p[j]++;
			a++;
		}
	}
		if(a==n){
		for(i=0;i<10;i++){
			if(p[i]==1){
			x+=i;
			}
		}
			if(x==s)
			ans++;
		}
	}
		cout<<ans<<endl;
	}
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int a, b, ret;
// x????¶???????????????????????????§???y????¶???????????????????????????§???????¨????sum???
void dfs(int x, int y, int sum) {
    if(sum == b && y == a) {
        ret++; return;
    }
    if(x == 10 || sum > b) return;
    dfs(x+1,y,sum);
    dfs(x+1,y+1,sum+x);
}

int main() {
    while(cin >> a >> b) {
        ret = 0;
        if(a == 0 && b == 0) break;
        dfs(0,0,0);
        cout << ret << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;

int ans[101][10];

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int m,n;
	int num;
	int sum;
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 10; j++){
			ans[i][j] = 0;
		}
	}
	for(int i = 0; i < 1023; i++){
		num = 0;
		sum = 0;
		for(int j = 0; j < 10; j++){
			if((i / pow(2,j)) % 2 == 1){
				num++;
				sum += j;
			}
		}
		ans[sum][num]++;
	}
	
	scanf("%d %d",&m,&n);
	while(m != 0 || n != 0){
		printf("%d\n",ans[n][m]);
		scanf("%d %d",&m,&n);
	}
		return 0;

}