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 main()
{
  int n, s;
  int i, j, tmp;
  int sum, count;
  int ans;

  while(cin>>n){
    cin>>s;
    if(n+s==0) break;

    ans=0;
    for(i=0; i<1024; i++){
      tmp=i; sum=0; count=0;
      for(j=0; j<10; j++){
        if(tmp%2==1){
          sum+=j;
          count++;
        }
        tmp/=2;
      }
      if(count==n && sum==s) ans++;
    }
    printf("%d\n", ans);
  }

  return 0;
}

C++: #include <iostream>
//#include <fstream>
using namespace std;
int ans,n,s;
 
void dfs(int cnt,int sum,int i){
	if(sum==s&&cnt==n){
        ++ans;
        return;
    } else if(cnt==n||i>=10){
        return;
    }
	dfs(cnt+1,sum+i,i+1);
    dfs(cnt,sum,i+1);
};
 
int main(){
    while(cin>>n>>s&&n&&s){
        ans=0;
        dfs(0,0,0);
        cout << ans << "\n";
    }
    return 0;
}

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

int n, s, res = 0, w = 1;
int a[10] = { 0 };

void dfs(int sum, int cnt) {
	if (cnt == n) {
		if (sum == s) {
			res++;
                        return;
		}
	}
	for (int i = 0; i < 10; i++) {
		if (a[i] == 0) {
			a[i] = 1;
			dfs(sum + i, cnt + 1);
			a[i] = 0;
		}
	}
	return;
}

int main() {
	while (1) {
		res = 0; w = 1;
		cin >> n >> s;
		if (n == 0 && s == 0) return 0;
		dfs(0, 0);
		for (int i = 1; i <= n; i++) {
			w *= i;
		}
		cout << res / w << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int sum (int n,int s,int cnt);

int N,S,latte;

int main (void)
{
    int i;
    while(1){
        scanf("%d%d",&N,&S);
        if(N==0&&S==0)break;
        latte = 0;
        printf("%d\n",sum(0,0,0));
        //printf("latte = %d\n",latte);
    }
    return 0;
}
int sum(int n,int s,int cnt)
{
    latte++;
    if(s>S || cnt>N || s+(n+9)*(9-n+1)/2<S) return 0;
    if(n>9){
        if(cnt==N && s==S) return 1;
        else return 0;
    }
    return sum(n+1,s+n,cnt+1)+sum(n+1,s,cnt);
}

C++: #include <cstdio>

int main(){
  int n,s;
  while(scanf("%d %d",&n,&s),n){
    int ans=0;
    for(int i=0; i<1024; i++){
      int a=0,b=0;
      for(int j=0; j<10; j++)
	if((i>>j)&1){a+=j;b++;}
      if(a==s&&b==n) ans++;
    }
    printf("%d\n",ans);
  }
}

C++: #include <cstdio.h>

using namespace std;

int get_sum(int num,int sum,int *u,int n){
	int i,j;
	if(num==0&&sum==0){
		return 1;
	}
	if(n>9){
		return 0;
	}
	return (get_sum(num-1,sum-u[n],u,n+1)+get_sum(num,sum,u,n+1));
}

int main()
{
	int sum,num;
	int u[10];
	int i;
	while(1){
		scanf("%d %d",&num,&sum);
		if(num==0&&sum==0) break;
		for(i=0;i<10;i++){
			u[i]=i;
		}
		printf("%d\n",get_sum(num,sum,u,0));
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int dp[20][55][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;
    }
    if(n >= 11 || s >= 46) printf("0\n");
    else printf("%d\n", cnt_sum(n, s, 0));
  }
  return 0;
}

C++: #include <iostream>
//#include <fstream>
using namespace std;
int ans,n,s;
 
void dfs(int cnt,int sum,int i){
	if(sum==s&&cnt==n){
        ++ans;
        return;
    }
    if(sum>s||cnt==n||i>=10){
        return;
    }
    dfs(cnt,sum,i+1);
    dfs(cnt+1,sum+i,i+1);
    return;
};
 
int main(){
    while(cin>>n>>s&&n&&s){
        ans=0;
        dfs(0,0,0);
        cout << ans << "\n";
    }
    return 0;
}

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

using namespace std;

int dfs(int x, int n, int s)
{
    if (n == 0) {
        return (s == 0);
    }
    if (x >= 9) 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) {
        cout << dfs(0, n, s) << endl;
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

/*
0 1 2 3 4 5 6 7 8 9

*/

int A(int n, int s, int f) {
	int cnt = 0;
	if (n > 2)
		for (int i = f; i <= 9; i++) {
			if (s - i > i)cnt += A(n - 1, s - i, i + 1);
			else break;
		}
	else if (n == 2)
		for (int i = f; i <= 9; i++) {
			if (s - i <= 9 && s - i > i)cnt++;
			else break;
		}
	else if (n == 1)
		cnt = 1;

	return cnt;
}

int a, S;

//void dfs(int i, int s, int n) {
//	//cout << i << " " << s << " " << n << endl;
//	if (s == S&&n == 0) {
//		a++;
//		return;
//	}
//	if (i == 10 || n == 0)
//		return;
//
//	dfs(i + 1, s + i, n - 1);
//	dfs(i + 1, s, n);
//}

int main() {
	for (int n; cin >> n >> S && (n || S);) {
	//for (int n = 0; n < 9; n++) {
		//for (S = 1; S < 9; S++) {
			a = 0;
			//dfs(0, 0, n);
			//cout << n << " " << S << ":" << a << " " << A(n, S, 0) << endl;
			cout<<A(n, S, 0) << endl;
		//}
	}

	return 0;
}

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

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

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

C++: #include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

int Shinobu(int n, int s, int num)
{
  if (n == 0 && s == 0) return (1); // mitukatta
  if (num > 9 || s < 0) return (0);

  return (Shinobu(n, s, num + 1) + Shinobu(n - 1, s - num, num + 1));
}

signed main()
{
  ios::sync_with_stdio(false);

  for (int n, s; cin >> n >> s, n || s; print(Shinobu(n, s, 0)));

  return (0);
}

C++: #include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>

using namespace std;

int N, S, ans, dp[100][100][100];

void rec(int base, int x, int used) {
    if(x > S || used > N) return;
    if(x == S && used == N) {
        if(!dp[base][x][used]) {
            dp[base][x][used] = 1;
            ans += 1;
        }
        return;
    }
    dp[base][x][used] = 1;
    for(int i = base; i <= 9; i++) {
        rec(i + 1, x + i, used + 1);
    }
}

int main(void) {
    while(1) {
        scanf("%d%d", &N, &S);
        if(N == 0 && S == 0) break;
        ans = 0;
        memset(dp, 0, sizeof(dp));
        rec(0, 0, 0);
        printf("%d\n", ans);
    }
    return 0;
}