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> 

int main(){
	int a,b,x=0;
	int fg[50];	
	while(std::cin>>a>>b&&a!=0&&b!=0){
		int d2=0,d3=0,d4=0,d5=0,d6=0,d7=0,d8=0,d9=0;
		int o=0;
		x++;
		for(int d=0;d<10;d++){
			if(a>1&&d<=10-a){
				for(d2=d+1;d2<10;d2++){
			if(a>2&&d2<=10-a+1){
				for(d3=d2+1;d3<10;d3++){
			if(a>3&&d3<=10-a+2){
				for(d4=d3+1;d4<10;d4++){
			if(a>4&&d4<=10-a+3){
				for(d5=d4+1;d5<10;d5++){
			if(a>5&&d5<=10-a+4){
			for(d6=d5+1;d6<10;d6++){
			if(a>6&&d6<=10-a+5){
				for(d7=d6+1;d7<10;d7++){
			if(a>7&&d7<=10-a+6){
				for(d8=d7+1;d8<10;d8++){
			if(a>8&&d8<=10-a+7){
				for(d9=d8+1;d9<10;d9++){
		if(a==9&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==8&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==7&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==6&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
		
			o++;
		}
			}
		}
		if(a==5&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==4&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==3&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==2&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
		}
		if(a==1&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		fg[x]=o;
	}
	for(int j=1;j<=x;j++){
		std::cout<<fg[j]<<std::endl;
	}
	return 0;
}

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

int dfs(int n, int sum, int before) {
    int ret = 0;
    if(n < 0 || before > 9 || (n > 0 && sum >= key)) return(0);
    else if(n == 0 && sum == key) return(1);
    

    for(int r = before; r <= 9; r++) {
        ret += dfs(n - 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    int n;
    while(cin >> n >> key, n + key != 0) {
        cout << dfs(n, 0, 0) << endl;
    }
    return(0);
}

C++: #include<iostream>

using namespace std;

int ans = 0;
void dfs(int n,int s,int d){
	if (s < 0) return;
	if (s == 0 and n == 0){
		ans++;
		return;
	}
	if (n == 0) return;	
	d++;
	if (d == 10)return;
//	cout << "n=" << n;
//	cout << " s=" << s;
//	cout << " d=" << d <<  endl;
	//???????????´???
	dfs(n-1,s-d,d);
	//?????°????????£?????´???
	dfs(n,s,d);
return;
}

int main(){
	int n,s; cin >> n >> s;
	while (!(n == 0 and s == 0)){
		dfs(n,s,-1);
		cout << ans << endl;
		cin >> n >> s;
	}

return 0;
}

C++: #include <cstdio>

using namespace std;

int count(int n, int s, int begin) {
  if (n == 1) { return begin <= s && s <= 9 ? 1 : 0; }
  if (9 - begin < n) { return 0; }
  if (n * (begin + n - 1) / 2 > s) { return 0; }
  int acc = 0;
  for (int i = begin; i <= 9 && i * 2 < s; ++i) {
    acc += count(n - 1, s - i, i + 1);
  }
  return acc;
}

int main() {
  while (true) {
    int n, s;
    scanf("%d %d", &n, &s);
    if (n == 0 && s == 0) { break; }
    printf("%d\n", count(n, s, 0));
  }

  return 0;
}

C++: #include<map>
#include<list>
#include<cmath>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;

int A[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int cunt = 0;

void depth(int n, int s, int i){

	if (n == 0 && s == 0){
		cunt++;
		return;
	}
	else if (n == 0) return;
	else if (s == 0) return;
	else if (i == 10) return;


	depth(n - 1, s - A[i], i++);
	depth(n, s, i++);

}

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

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

int main()
{
  int n, s;
  while (cin >> n >> s && !(n == 0 && s == 0)) {
    vector<bool> arr(10, true);
    for (int i = 0; i < n; i++) {
      arr[i] = false;
    }

    int ans = 0;
    do {
      int m = 0;
      for (int i = 0; i < 10; i++) {
        if (!arr[i]) {
          m += i;
        }
      }
      if (m == s) {
        ans++;
      }
    } while (next_permutation(arr.begin(), arr.end()));
    cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

ll rec(int i, int j, int k){
    if(i==0){
        if(k==0)return 1;
        else return 0;
    }
    ll res = 0;
    for (int x = j+1;x<=k;x++){
        res += rec(i-1,x,k-x);
    }
    return res;
}

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

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <string.h>
#include <utility>
#include <cstdio>
#include <set>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>
#include <assert.h>
using namespace std;
namespace mp = boost::multiprecision;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define ll long long
#define LL long long

int flg[10];

int dfs(int n, int s) {
	int ret = 0;
	if (n == 0) return s == 0;
	for (int i = 0; i < 10; ++i) {
		if (flg[i]) continue;
		flg[i]++;
		ret += dfs(n-1, s-i);
		flg[i]--;
	}
	return ret;
}

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

C++: #include <iostream>

using namespace std;
int a;
int f(int n,int s,int i){
  if(n==1&&i>=s&&s>=0){
    a++;
    return 0;
  }
  if(s<=0||s>=i*n) return 0;
  for(int j=i;j>=n-1;j--) f(n-1,s-j,j-1);
}
int main(){
  int n,s;
  while(cin>>n>>s){
    a=0;
    if(n==0&&s==0) break;
    f(n,s,9);
    cout<<a<<endl;
  }
  return 0;
}