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

C++: #include <stdio.h>
#include <algorithm>
using namespace std;

int ans[101][10];

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int m,n;
	int num;
	int sum;
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 10; j++){
			ans[i][j] = 0;
		}
	}
	for(int i = 0; i < 1023; i++){
		num = 0;
		sum = 0;
		for(int j = 0; j < 10; j++){
			if((i / pow(2,j)) % 2 == 1){
				num++;
				sum += j;
			}
		}
		ans[sum][num]++;
	}
	
	scanf("%d %d",&m,&n);
	while(m != 0 && n != 0){
		printf("%d\n",ans[n][m]);
		scanf("%d %d",&m,&n);
	}
	
	return 0;

}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int n,s,ans;
void solve(int from,int now,int sum){
    if(now==n && sum==s) ans++;
    if(now<n && s-sum>=from*(n-now)){
        for(int i=from;i<=min(9,(s-sum)/(n-now));i++){
            solve(i+1,now+1,sum+i);
        }
    }
}

int main(){
    for(;;){
        scanf("%d%d",&n,&s);
        if(n==0 && s==0) break;
        ans=0;
        solve(0,0,0);
        printf("%d\n",ans);
    }
}

C++: #include<iostream>
using namespace std;
int cnt=0,s;
void kumiawase(int i,int n,int ALL){
    for(;i<10;i++){
        if(n==1){
            if(s==ALL+i){
                cnt++;
            }
            continue;
        }
        kumiawase(i+1,n-1,ALL+i);
    }
}

int main()
{
    int n,i=0;
    while(cin>>n>>s,n!=0 && s!=0){
        if(i==50) break;
        kumiawase(0,n,0);
        cout<<cnt<<endl;
        cnt=0;
        i++;
    }
}

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

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

using namespace std;

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

int dfs( int x, int i, int sum){

  if( x == n && sum == s){
    ++ans;
  }else{
    if( i < 10){
      dfs( x+1, i+1, sum+a[i]);
      dfs( x, i+1, sum);
    }else{
      return ans;
    }
  }
}

int main(){

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

    cout << dfs( 0, 0, 0) << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int n,m;

int f(int depth, int sum, int s)
{
    if(depth == 10)
    {
        if(sum == 0 && s == m)return 1;
        return 0;
    }
    return f(depth+1,sum-1,s+depth) + f(depth+1,sum,s);
}
int main()
{

    scanf("%d%d",&n,&m);
    printf("%d\n",f(0,n,0));
    return 0;
}

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

int n,k,count;

void dfs(int i,int sum,int num)
{
	if(sum == k && num == n) 
	{
		count++;
		return;
	}

	if(i == 10 || num == n)
	{
		return;
	}
	
	dfs(i+1,sum,num);
	dfs(i+1,sum+i,num+1);
}
int main()
{
	while(cin >> n >> k && n && k)
	{
		count = 0;
		dfs(0,0,0);
		cout << count << endl;

	}
	return 0;
}

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

int main(void){
  int n,s;

  while(1){

    int cnt = 0;

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

    for( int i = 0 ; i < n ; i++ ){
      for( int j = 0 ; j <= s ; j++ ){
	for( int k = j+1 ; k <= s ; k++ ){
	  for( int l = k+1 ; l <= s ; l++ ){

	    if( j + k + l == s && ( i != j && i != k &&j != k )) cnt++;

	  }
	}
      }
    }
    cout << cnt << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int sp(int n,int s,int num)
{
    if(!n&!s)return 1;
    if(num>9)return 0;
    return sp(n-1,s-num,num+1)+sp(n,s,num+1);
}
int main()
{
    while(1)
    {
        int n,s;
        cin>>n>>s;if(!n)return 0;
        cout<<sp(n,s,0)<<endl;
    }
    return 0;
}

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

int n,s;
int i;

int dfs(int num,int total,int de)
{
	int count = 0;

	if(de == n && total == s)
	{
		return 1;
	}
	if(de == n && total != s)
	{
		return 0;
	}

	for(i=num; i<=9; i++)
	{
		count += dfs(i+1,total+i,de+1);
	}
	return count;
}

int main()
{

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

		cout << dfs(0,0,0) << endl;
	}
}

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

int n,s,ans = 0;

void dfs(int i,int sum,int num){
    
    if(num == n){
        
        if(sum == s){
            ans++;
        }
        return;
    }
    if(i == 10){
        return;
    }
    //not including i
    dfs(i+1,sum,num);
    //including i
    dfs(i+1,sum + i,num+1);
}

int main(){

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

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#pragma region defins
#define ll long long
#define loop(i,n) for (int i = 0; i < n; i++)
#define loops(i,f,n) for (int i = (f); i < n; i++)
#define INF 100000000000000
#define sort(a) sort(a.begin(),a.end())
#define rsort(a) sort(a.rbegin(),a.rend())
using namespace std;
#pragma endregion
int n, s, ans;
void dfs(int num, int sum, int count)
{
    //cout << "num:" << num << " sum:" << sum << " count:" << count << endl;
    if (sum == s&&count == n)
    {
        ans++;
        //cout << "ans: " << ans << endl;
    }
    if (sum > s || num == 10 || count == n)return;
    dfs(num + 1, sum + num, count + 1);
    dfs(num + 1, sum, count);
}
 
int main()
{
    while (1)
    {
        cin >> n >> s;
        if (n == 0 && s == 0)break;
        else
        {
            ans = 0;
            dfs(0, 0, 0);
            cout << ans << endl;
        }
    }
}

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

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

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

C++: #include <iostream>

//n : n????????°???????¶?????????§
//s : ?????????s?????????
int n, s;
int ans;

void dfs(int a, int sum, int bmax) {
	if(a < n) {
		if(sum == s)
			++ans;
		else {
			for(int i = bmax + 1; i <= 9; ++i) {;
				if(sum + i <= s)
					dfs(a + 1, sum + i, i);
			}
		}
	}
}

int main() {
	while(std::cin >> n >> s, !(n == 0 && s == 0)) {
		if(n <= s)
			dfs(0, 0, 0);
		
		std::cout << ans << std::endl;
		
		ans = 0;
	}
}

C++: #include <iostream>
using namespace std;main(){int n=0,s,j,k,i,a[11][46];for(;n<506;n++)a[n%11][n/11]=0;for(i=0;i<1024;i++){for(j=i,n=s=k=0;j>0;j/=2,k++)n+=j%2,s+=j%2*k;a[n][s]++;}for(cin>>n>>s;n||s;s<46?cout<<a[n][s]:cout<<0,cout<<endl,cin>>n>>s);}