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<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int n,s;
int used[10];

int saiki(int depth){
	if(depth==n){
		int p = 0;
		rep(i,10)if(used[i]==1)p+=i;
		if(p==s)return 1;
		return 0;
	}
	int ret = 0;
	
	for(int i=9;i>=0;i--){
		if(used[i]==0){
			used[i]=1;
			ret += saiki(depth+1);
			used[i]=0;
		}else{
			break;
		}
	}
	return ret;
}

int main(){
	rep(i,10)used[i]=0;
	
	while(1){
		cin>>n>>s;
		if(n==0)break;
		printf("%d\n",saiki(0));
	}
}

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

C++: #include <iostream>
using namespace std;
 
int cnt; int N, Ans;
 
void choose(int k, int l, int digit) {
  if(l == N && k == Ans) { cnt++; return; }
  else if (l == N) return;
  else if (digit >= 10) return;
   
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}
 
int main () {
  while(cin>>N>>Ans, N||Ans) {
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>

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

int func(int de, int k, int sum){
	int res = 0;
	if(de == n){
		if(sum == s)return 1;
		return 0;
	}
	if(sum > s)return 0;
	if(k==11)return 0;
	for(int i = k; i < 10; ++i){
		res += func(de + 1, i + 1, sum + num[i]);
		//	res += func(de, i + 1, sum);
	}
	return res;
}

int main(){
	while(std::cin >> n >> s, n, s){
		std::cout << func(0, 0, 0) << std::endl;
	}
	return 0;
}

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

int solve(int n, int index, int s) {
    if (n == 0 && s == 0) {
        return 1;
    } else if (n == 0 || s <= 0 || s < index || 9 < index) {
        return 0;
    }
    int res = 0;
    res += solve(n - 1, index + 1, s - index);
    res += solve(n, index + 1, s);
    return res;
}

int main() {
    while (true) {
        int n, s;
        cin >> n >> s;
        if ((n | s) == 0) {
            break;
        }
        cout << solve(n, 0, s) << endl;
    }
}

C++: #include <iostream>

using namespace std;


int n,s;

int count;

void dfs(int i,int j,int sum) {

  //cout << i << " " << j << " " << sum << endl;

  if(j==0 && sum==0) {

    count++;

    return;

  }

  if(i==10 || j==0 || sum<=0) return;

  dfs(i+1,j-1,sum-i);

  dfs(i+1,j,sum);

  return;

}
  

int main() {

  while(cin >> n >> s,n!=0 && s!=0) {

    count=0;

    dfs(0,n,s);

    cout << count << endl;

  }

  return 0;

}

C++: #include<iostream>
using namespace std;
int n,s,cnt;
void dfs(int m,int num,int sum);
int main(){
	while(cin>>n>>s,n && s){
		cnt=0;
		dfs(1,0,0);
		cout<<cnt<<endl;
	}
	return 0;
}

void dfs(int m,int num,int sum){
	if(m>9 && (num==n || num==n-1) && sum==s)cnt++;
	if(m>9)return;
	dfs(m+1,num+1,sum+m);
	dfs(m+1,num,sum);	
}

C++: #include <iostream>

using namespace std;

int rec(int n, int s, int over) 
{
    if (s < 0 || n < 0)
        return 0;
    if (!n && !s)
        return 1;
    
    int count = 0;
    for (int i = over + 1; i < 10; i++) 
        count += rec(n - 1, s - i, i);

    return count;
}

int main()
{
    int n, s;

    while (true) {
        cin >> n >> s;
        if (!n && !s)
            break;

        cout << rec(n, s, -1) << endl;
    }

    return 0;
}

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

int dp[11][46] = {0};

int main()
{
	dp[0][0]=1;
	for(int k=0; k<10; k++)
	{
		for(int i=k; i>=0; i--)
		for(int j=0; j<46-k; j++)
		{
			dp[i+1][j+k] += dp[i][j];
		}
	}

	int N,S;
	while(cin>>N>>S, N||S)
	{
		if(0<=N && N<11 && 0<=S && S<46)
		{
			cout << dp[N][S] << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int N=9,S=100;
	vvi dp(N+1,vi(S+1));
	dp[0][0]=dp[1][0]=1;
	loop(x,1,10)for(int i=N-1;i>=0;i--)for(int j=S;j>=0;j--)if(j+x<=100){
		dp[i+1][j+x]+=dp[i][j];
	}
	int n,s;
	while(cin>>n>>s,n+s){
		cout<<dp[n][s]<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int dfs(int n, int s, int k){
  if( !n )return ( s == 0 )? 1 : 0;
  int res = 0;
  for(int i=k; i<10; i++){
    res += dfs(n - 1, s - i, i + 1);
  }
  return res;
}

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

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

int count = 0;
int search(int n,int m,int i)
{
	
	if(n==0 && m==0){
		count++;
		return 1;
	}
	if(n==0 || i>=10){
		return 0;
		
	}
	search(n-1,m-i,i+1);
	search(n,m,i+1);
	return count;
}
int main()
{
	int n,m;
	while(cin >> n >> m){
		if(n == 0 && m == 0)
			break;
		count = 0;
		cout << search(n,m,0) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#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(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int n,s;

    vector<int> num(10);

    for(int i = 0;i < 10;i++){
        num[i] = i;
    }

    while(cin >> n >> s){

        if(n == 0 && s == 0){
            break;
        }

        int ans = 0;
        
        for(int i = 0 ; i < (1 << num.size()) ; i++){
            int sum = 0;
            int bit_count = 0;
            for(int j = 0 ; j < num.size() ; j++){
                if( (i >> j) & 1){
                    sum += num[j];
                    bit_count++;
                    /*if(bit_count == n){
                        break;
                    }*/
                }
            }
            if(sum == s && bit_count == n){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}