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>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


int dfs(int n, int s, int k){
	if(n==0 && s==0){
		return 1;
	}
	if(n==0) return 0;
	if(s<0) return 0;			//ココ
	if(k>9 || k>s) return 0;
	int res1 = dfs(n-1, s-k, k+1);
	int res2 = dfs(n, s, k+1);
	return res1 + res2;
}

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

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

C++: #include <stdio.h>
 
int i,n,s;
 
int part(int cal, int index, int sum){
			if(index == 9 && cal == n && sum == s){
			i++;
			return;	
			} 
			
			if(index > 9|| cal > n||sum > s) return;
			
	part(cal, index + 1, sum);
	part(cal + 1, index + 1, sum + index);
}
 
main(){
	scanf("%d %d" , &n , &s);
	if (n==0 && s==0) return 0;
	part(0, 0, 0);
	printf("%d",i);
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int solve(int num,int sum,int x){
	if(num == 0 && sum == 0) return 1;
	if(x == 10) return 0;
	return solve(num-1,sum-x,x+1) + solve(num,sum,x+1);
}
int main(){
	while(1){
		int n,s;
		scanf("%d%d",&n,&s);
		if(n == 0 && s == 0) break;
		cout << solve(n,s,0) << endl;
	}
	return 0;
}

C++: #include <iostream>

int judge(int n, int s, int max)
{
    if(n == 1)
    {
        return 0 <= s && s <= max ? 1 : 0;
    }
    int ret = 0;
    for(int i = 0; i <= max; i++)
    {
        ret += judge(n-1, s-i*n-(n-1), max-i-1);
    }
    return ret;
}

int main()
{
    int n, s;
    while(std::cin >> n >> s, s || n)
    {
        std::cout << judge(n, s, 9) << std::endl;        
    }
}

C++: #include <iostream>
#include <bitset>

using namespace std;

int main() {
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int n, s, sum, cnt;

    while (cin >> n >> s) {
        if (!n && !s) { break; }
        cnt = 0;
        for (int i = 0; i < (1 << 10); i++) {
            sum = 0;
            for (int j = 0; j < 10; j++) {
                // if (bitset<10>(i).test(j)) {
                if ((i >> j) & 1) {
                    sum += a[j];
                }
            }
            if (sum == s && bitset<10>(i).count() == n) { cnt++; }
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int n;
	int s;
	int i, j, k;
	int dp[16][64];	
	
	for (i = 0; i < 16; i++){
		for (j = 0; j < 64; j++){
			dp[i][j] = 0;
		}
	}
	
	dp[0][0] = 1;
	for (i = 0; i <= 9; i++){
		for (j = 8; j >= 0; j--){
			for (k = 0; k < 64; k++){
				if (dp[j][k] != 0){
					dp[j + 1][k + i] += dp[j][k];
				}
			}
		}
	}
	
	while (scanf("%d %d", &n, &s), n != 0 || s != 0){
		if (s < 64){
			printf("%d\n", dp[n][s]);
		}
		else {
			printf("0\n");
		}
	}
	
	return (0);
}

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

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) 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;
}

C++: #include<iostream>

using namespace std;

int n,s,ans;//?????????????????°??§??£?¨?????????¨dfs?????§?????§??§??????????????§??°?????????????????°??§??£?¨?

void dfs(int now,int sum,int times){//now??????????????´??° sum?????????????¨? times??????????????§????????´??°?????°
	if(n < times)//???????????´??°???n?????????????????°??????
		return;
	if(n == times && s == sum){//???????????¶
		ans++;
		return;
	}
	for(int i = now + 1; i <= 9; i++)//????????¨????????´??°????????????
		dfs(i,sum + i, times + 1);//?????°??????
}

int main(){
	while(cin >> n >> s,n+s != 0){
		ans = 0;
		for(int i = 0; i <= 9; i++){//??¨????????´??°????????????
			dfs(i,i,1);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int n, s;//n 1~9 s 0~100
int ans=0;
//?????????????????¶.i??????????????????j??¨??????
//??\????????????????????????????????§????????????????????\???????????????.
int solve(int i,int j, int k){
	if(i==n){
		if(k==s)ans++;
	}else{
		FOR(l,j+1,10){
			if(k+l<=s){
				solve(i+1,l,k+l);
			}	
		}
	}
	return ans;
}


int main(){
	while(cin>>n>>s&&(n||s)){
		ans=0;
		cout<<solve(0,-1,0)<<endl;
	}
    return 0;
}

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

int main()
{
  int n, s;
  int i, ,j, tmp;
  int sum, count;
  int ans;
  char c;

  while(cin>>n>>c>>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=tmp/2;
      }
      if(count==n && sum==s) ans++;
    }
    printf("%d\n", ans);
  }

  reutrn 0;
}

C++: #include <iostream>
using namespace std;
int n,s,flag[10] = { 0 },c;
void f(int m,int a,int t){
	if(a == n){
		if(t == s) ++c;
		return;
	}
	else {
		if(t > s) return;
		for(int i = m;i < 10;++i){
			if(flag[i] == 0){
				flag[i] = 1;
				f(i + 1,a + 1,t + i);
				flag[i] = 0;
			}
		}
	}
	return;
}
int main(){
	while(cin >> n >> s && (n != 0 && s != 0)){
		for(int i = 0;i < 10;++i){
			flag[i] = 0;
		}
		c = 0;
		f(0,0,0);
		cout << c << endl;
	}
	return 0;
}

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

int n, s;

int countAns(int sum, int pos, int last){
	int ans = 0;
	if (pos > n) {
		return 0;
	}else if(pos==n && sum==s){
		return 1;
	}else if(sum >= s){
		return 0;
	}

	for (int i = last+1; i < 10; i++) {
		ans += countAns(sum+i, pos+1, i);
	}
	return ans;
}

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

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

using namespace std;

int N, K;

set<string> mem;
string s;

int main(void) {
    while(scanf("%d%d", &N, &K)) {
        if(N == 0 && K == 0) break;
        mem.clear();
        for(int i = 0; i < (1 << 10); i++) {
            int tmp = 0, ct = 0;
            s.clear();
            for(int j = 0; j <= K; j++) if(i & (1 << j)) {
                tmp += j;
                ct += 1;
                s += (char) j +  '0';
            }
            if(tmp == K && ct == N) {
                mem.insert(s);
            }
        }
        cout << mem.size() << endl;
    }
    return 0;
}