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<bits/stdc++.h>
using namespace std;
int main(){
	int n, s;
	for(;;){
		scanf("%d %d", &n, &s);
		if(n == 0 && s == 0) break;
		int ans = 0;
		for(int i = 0; i < (1 << 10); i++){
			int num_1 = 0;
			int sum = 0;
			for(int j = 0; j < 10; j++){
				if(1 << j & i){
					sum += j;
					num_1++;
				}
			}
			if(num_1 == n && sum == s) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define MOD 100000
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int ans=0;

void sum(int num, int s, int max)//??????????????°????????????????????????????????§???
{
  int i;
  if(num==0 && s==0)
    ans++;
  if(num<=0 || s<0 || max<0)return;

  for(i=max;i>=0;i--)
    sum(num-1,s-i,i-1);
  return;

}

int main()
{
  int n,s;
  while(1){
    cin>>n>>s;
    ans=0;
    if(n==0 && s==0)break;
    if(n*(19-n)/2<s || n*(n-1)/2>s){
      cout<<"0"<<endl;
      continue;
    }
    sum(n,s,9);
    cout<<ans<<endl;
  }
}

C++: #include <iostream>
using namespace std;
int ans = 0;

int dfs(int depth, int sum, int before) {
    int ret = 0;
    if(depth == 0) {
        if(sum == ans) return(1);
        else           return(0);
    }
    if(sum > ans || before > 9) return(0);
    for(int r = before; r <= 9; r++) {
        ret += dfs(depth - 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    cin.tie();
    ios::sync_with_stdio(false);
    while(true) {
        int depth = -1;
        cin >> depth >> ans;
        if(depth + ans == 0) break;
        cout << dfs(depth, 0, 0) << endl;
    }
    
    return(0);
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#include <stdio.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000007
using namespace std;
typedef long long int ll;

vector<int> used(10,0);
int n, s, ans;

void solve(int m, int sum){
    if (m==0) {
        if (sum == s) {
            ans++;
        }
        //cout << "|"<<ans<<"|"<<endl;
        return;
    }
    for (int i=0; i<10; i++) {
        if (used[i]==0) {
            //cout << i <<" "<<m<< endl;
            used[i]=1;
            solve(m-1, sum+i);
            used[i]=0;
        }
    }
}

int fac(int n){
    if (n==0) return 1;
    return n*fac(n-1);
}

int main(){
    while (1) {
        cin >> n >> s;
        if(n==0 and s == 0) break;
        ans = 0;
        solve(n, 0);
        cout << ans/fac(n) <<endl;
    }
}

C++: #include<iostream>
using namespace std;
int main()
{
int n,s,R;
while(cin>>n>>s&&n!=0||s!=0)
{
R=0;
	if(n>=1&&n<=45)
	{
		for(int j=0;j<10;j++)
		{	
			if(n>=2)
			{
				for(int k=j+1;k<10;k++)
				{		
					if(n>=3)
					{
						for(int l=k+1;l<10;l++)
						{
							if(n>=4)
							{
								for(int m=l+1;m<10;m++)
								{	
									if(n>=5)
									{
										for(int o=m+1;o<10;o++)
										{
										if(n>=6)
										{
											for(int p=o+1;p<10;p++)
											{
												if(n>=7)
												{
													for(int q=p+1;q<10;q++)
													{
														if(n>=8)
														{
															for(int r=q+1;r<10;r++)
															{
																if(n>=9)
																{
																		for(int t=q+1;t<10;t++)
																		{
																		if(j+k+l+m+o+p+q+r+t==s)
																		{
																		R++;	
																		}	
																		}
																	}
																	else if(j+k+l+m+o+p+q+r==s)
																	{
																	R++;	
																	}
																}
															}
															else if(j+k+l+m+o+p+q==s)
															{
															R++;	
															}
														}
													}
													else if(j+k+l+m+o+p==s)
													{
													R++;	
													}
												}	
											}
											else if(j+k+l+m+o==s)
											{
											R++;	
											}
										}
									}
									else if(j+k+l+m==s)
									{
									R++;	
									}
								}
							}
							else if(j+k+l==s)
							{
							R++;	
							}
						}				
					}
					else if(j+k==s)
					{
					R++;	
					}	
				}	
			}
			else if(j==s)
			{
			R++;	
			}	
		}
	}
cout<<R<<endl;
}
return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n, s;

int cal(int a, int b, int c)
{


	if (a == 1 && b >= c && b < 10)
	{
		return 1;
	}
	if (a == 1)
	{
		return 0;
	}
	int hoge = 0;


	for (int i = c; i < 10 && i < b; i++)
	{
		hoge += cal(a - 1, b - i, i + 1);
	}

	return hoge;


}

int main(void)
{
	while (cin >> n >> s,1)
	{
		if (n==0&&s==0)
		{
			break;
		}

		cout << cal(n, s, 0) << endl;
	}

	return 0;
}

C++: #include <iostream>

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

void dfs(int i, int sum, int k){
	if(k==n && sum==s){
		answer++;
	}
	if(i>9 || k==n || sum > s){
		return;
	}
	dfs(i+1, sum+arr[i], k+1);
	dfs(i+1, sum, k);
}

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

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

int main(){
	int n,s,r,bit;
	int sum;
	
	while(cin >> n >> s && n || s){
		r = 0;
		for(int i=0;i < (1<<10) ;i++){
			sum = bit = 0;
			for(int j=0;j<10;j++)
				if( i & (1<<j) )bit++;
			if(bit != n)continue;
			
			for(int j=0;j<10;j++){
				if( i & (1<<j) )sum+=j;
			}

			if( sum == s )r++;
		}
		cout << r << endl;
	}
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n, s;

int cal(int a, int b, int c)
{
	int hoge = 0;

	if (a == 1 && b >= c )
	{
		return 1;
	}
	if (a == 1)
	{
		return 0;
	}



	for (int i = c;i < b; i++)
	{
		hoge += cal(a - 1, b - i, i + 1);
	}

	return hoge;


}

int main(void)
{
	while (cin >> n >> s, 1)
	{
		if (n == 0 && s == 0)
		{
			break;
		}

		cout << cal(n, s, 0) << endl;
	}

	return 0;
}

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

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;

int n, s, c;

void func(int n, int sum, int max){
	if (n){
		for (int i = max + 1; i < 10; i++){
			func(n - 1, sum + i, i);
		}
	}
	else if (sum==s){
		c++;
		return;
	}
	return;
}

int main(){
	while (cin >> n >> s){
		if (n == 0)break;
		c = 0;
		func(n,0,-1);
		cout << c << "\n";
	}
}