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 cnt;

void choose(int n, int k, int digit) {
  if(n == 0 && k == 0) { cnt++; return; }
  else if (n <= 0) return;
  else if (k == 0) return;
  else if (digit >= 10) return;
  
  choose(n-digit, k-1, digit+1);
  choose(n, k, digit+1);
}

int main () {
  int n, ans, res;

  while(cin>>n>>ans, n|ans) {
    res = 0; cnt = 0;
    choose(ans, n, 0);
    cout << cnt << endl;
  }
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  int n, s, i, j, ans, sum, num;
  while(cin >> n >> s, n + s){
    ans = 0;
    for(i = 0; i < (1 << 10); i++){
      num = sum = 0;
      for(j = 0; j < 10; j++){
        if(1 << j & i){
          num++;
          sum += j;
        }
      }
      if(num == n && sum == s){
        ans++;
      }
    }
    cout << ans << endl;
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int n,s;

int dfs(int i,int j,int sum){
	if (sum>s) return 0;
	if (i==n){
		if (sum==s){
			return 1;
		}
		else {
			return 0;
		}
	}
	int res=0;
	FOR(k,j,10){
		res+=dfs(i+1,k+1,sum+k);
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	do{
		cin>>n>>s;
		if (n){
			cout<<dfs(0,0,0)<<endl;
		}
	}while (n);
	return 0;
}

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

int dfs(int n,int s,int i){
  if(n == 0){
    if(s == 0)return 1;
    else return 0;
  }
  if(s - i < 0)return 0;
  if(i > 9)return 0;

  return dfs(n,s,i + 1) + dfs(n - 1,s - i,i + 1);
}

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

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

int saiki(int n, int s, int i, int *result){
    if(n <= 0){
        if(s == 0){
            *result += 1;
        }
    }else{
        for(int j=i;j<10;j++){
            saiki(n-1,s-j,j+1,result);
        }
    }
}
int main(){
    int n, s;
    int result;
    cin >> n >> s;
    while(n || s){
        result = 0;
        saiki(n, s, 0, &result);
        cout << result << endl;
        cin >> n >> s;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int n,s,ans;

void dfs(int k,int now,int m){
	if(k==n){
		if(now==s) ans++;
		return;
	}
	rep(i,m+1,10){
		dfs(k+1,now+i,i);
	}
	return;
}


signed main(){
	while(1){
		cin>>n>>s;
		if(n+s==0) break;
		ans=0;
		dfs(0,0,-1);
		o(ans);
	}
}

C++: #include<stdio.h>
int a[15];
int backtrack(int l,int n,int s)
{
	int i,j,k,flag,t,count=0;
	for(i=0;i<=9;i++)
	{
A:
		flag=0;
		a[l]=i;
	 	for(j=1;j<=l-1;j++)
		{
			if(a[l]<=a[j])
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			if(l==n)
			{
				t=0;
				for(k=1;k<=n;k++)
				{
					t+=a[k];
				}
				if(t==s)
				{
					count++;
				}
			}
			else if(l<n)
			{
				l++;
				i=-1;
				continue;
			}
		}
		if((a[n]==9)||(a[l]==9&&flag==1))
		{
			while(a[l]==9)
			{
				l--;
			}
			if(l==0)
			{
				break;
			}
			else
			{
				i=a[l]+1;
				goto A;
			}
		}
	}
	printf("%d\n",count);
    return 0;
}

int main()
{
	int n,s,i,j,k,count;
	while(scanf("%d %d",&n,&s),n||s)
	{
		if(n<=0||s<=0||n>10||s>45||s<n*(n-1)/2)
		{
			printf("0\n");
		}
		else
		{
			backtrack(1,n,s);
		}
	}
	return 0;
}

C++: #include<cstdio>
#define REP(i,a,n) for(int i = 0;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
void func(int num);
int in(){int n;scanf("%d",&n); return n;};

int flag[10] = {0};
int num2,ans = 0;
int main(void){
 int num = in(); num2 = in();
 func(num);
 printf("%d\n",ans);
 return 0;
}

void func(int num){
 if(num == 0){
  int n = 0;
  rep(i,10){if(flag[i]) n+= i;}
  if(n == num2) ans++;

  return;
 }
 rep(i,10){
  if(flag[i] == 1) return;
  flag[i] = 1;
  func(num-1);
  flag[i] = 0;
 }
 return;
}

C++: #include <iostream>

int sumOfIntegers(int min, int num, int sum);

int main()
{
    int num, sum;

    while (true) {
        std::cin >> num >> sum;

        if (num == 0 && sum == 0) {
            break;
        }

        std::cout << sumOfIntegers(0, num, sum) << std::endl;
    }

    return 0;
}

int sumOfIntegers(int min, int num, int sum)
{
    if (min > sum || min > 9 || num == 0) {
        return 0;
    }

    if (min == sum && num == 1) {
        return 1;
    }

    return (sumOfIntegers(min + 1, num, sum) + sumOfIntegers(min + 1, num - 1, sum - min));
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int N,S;
int dfs(int n,int t,int sum){
    if(n>10)return 0;
    if(t==N){
          if(sum==S)return 1;
          else return 0;
    }
    return dfs(n+1,t,sum)+dfs(n+1,t+1,sum+n);
}
int main(){
    while(cin>>N>>S,N||S)cout<<dfs(0,0,0)<<endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}

int main(){
    int n,s;
    while(cin >> n >> s,n!=0){
        int ans=0;
        for (int bit=0;bit<(1<<10);bit++){
            int flag=0;
            int count=0;
            rep(i,10){
                if (bit&(1<<i)){
                    flag++;
                    count+=i;
                }
            }
            if (flag!=n){
                continue;
            }
            if (count==s){
                ans++;
            }
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int n, s;
	vector<int> flags;

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

		flags.clear();
		for ( int i = 0; i < 9; i++ )
		{
			flags.push_back( i < n ? 1 : 0 );
		}
		sort( flags.begin(), flags.end() );

		int count = 0;

		do
		{
			int sum = 0;

			for ( unsigned int i = 0; i < flags.size(); i++ )
			{
				if ( flags[i] )
				{
					sum += i;
				}
			}

			if ( s == sum )
			{
				count++;
			}
		} while ( next_permutation( flags.begin(), flags.end() ) );

		cout << count << endl;
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
    int n, s;
    while (cin >> n >> s) {
        if ((n | s) == 0) break;
        int dp[n + 1][s + 1];
        fill(dp[0], dp[n + 1], 0);
        dp[0][0] = 1;
        for (int i = 0; i <= 9; i++) {
            for (int j = n; j > 0; j--) {
                for (int k = i; k <= s; k++) {
                    dp[j][k] += dp[j - 1][k - i];
                }
            }
        }
        cout << dp[n][s] << endl;
    }
}