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;
const int N = 12;
int n, s;
int ans = 0;
typedef pair <int, int> pii;
map <pii, int> m;

void bt(int sum, int index, int pos) {
	if(sum == 0 && pos == n) {
		ans++;
		return;
	}
    if(pos == n) return;
	if(sum < 0) return;
	for(int i = index; i <= s; i++) {
		bt(sum - i, i + 1, pos + 1);
	}
}



int main() {
	//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	while(true) {
	    cin >> n >> s;
	    if(!n && !s) return 0;
	    pii p = make_pair(n, s);
	    if(!m.count(p)){
	    	bt(s, 0, 0);
	    	m[p] = ans;
		}
	    else
	    	ans = m[p];
	    cout << ans << "\n";
	    ans = 0;
	}
    return 0;
}

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

int n;
int s;
int cc;
vector<int> re;


void test(int xs,int c,int lvl){
	if(lvl==n&&xs==s){
		cc++;
	}else{
		for(int i=c+1;i<s;i++){
			test(xs+i,i,lvl+1);
		}
	}
}

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

		cc=0;
		if(n<s){
			for(int i=0;i<n-1;i++){
				test(0,i,1);
			}
		}
		re.push_back(cc);
	}
	for(int i=0;i<re.size();i++){
		cout<<re[i]<<endl;
	}
}

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

// n個の重複しない整数(min ~ max)の和としてsを表す組み合わせの数
int ci(int n, int s, int min, int max) {
  // 特殊なパターンを処理
  if (s < min || n < 1) return 0;
  if (n == 1) return (s > max)? 0: 1;
  
  // 最も小さい数で場合分けし再帰処理
  int r = 0;
  for (int i=min; i<s && i<=max; i++) r += ci(n - 1, s - i, i + 1, max);
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, 9) << endl;
  }
  return 0;
}

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

int numofbits5(long bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

C++: #include <stdio.h>

int num(int i, int n, int s){
    int count=0;
    
    if(n==1){
        if(s<i && s>=0) return 1;
        else 0;
    }
    if(i<n) return 0;
    if(s<0) return 0;
    
    for(int j=i-1; j>=0; j--){
        count+=num(j, n-1, s-j);
    }
    
    return count;
}

int main(void){
    int n, s;
    scanf("%d %d", &n, &s);
    
    while(n!=0 && s!=0){
        printf("%d\n", num(10,n,s));
        scanf("%d %d", &n, &s);
    }
    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int n, s,ans=0;
   while(1){
      cin >> n >> s;
      ans=0;
      if(n+s==0) break;
      if(n==1) cout << 1 << endl;
      if(n==2) cout << n/2+n%2 << endl;
      if(n==3){
         FOR(i,0,101-n)FOR(j,i+1,102-n)FOR(k,j+1,103-n)if(i+j+k==s){
            ans++; break;
         }
      }
      if(n==4){
         FOR(i,0,101-n)FOR(j,i+1,102-n)FOR(k,j+1,103-n)
         FOR(l,k+1,104-n)if(i+j+k+l==s){
            ans++; break;
         }
      }
      if(n==5){
         FOR(i,0,101-n)FOR(j,i+1,102-n)FOR(k,j+1,103-n)
         FOR(l,k+1,104-n)FOR(m,l+1,105-n)if(i+j+k+l+m==s){
            ans++; break;
         }
      }
      if(n==6){
         FOR(i,0,101-n)FOR(j,i+1,102-n)FOR(k,j+1,103-n)
         FOR(l,k+1,104-n)FOR(m,l+1,105-n)FOR(o,m+1,106-n)
         if(i+j+k+l+m+o==s){
            ans++; break;
         }
      }
      if(n==7){
         FOR(i,0,101-n)FOR(j,i+1,102-n)FOR(k,j+1,103-n)
         FOR(l,k+1,104-n)FOR(m,l+1,105-n)FOR(o,m+1,106-n)
         FOR(p,o+1,107-n)if(i+j+k+l+m+o+p==s){
            ans++; break;
         }
      }
      if(n==8){
         FOR(i,0,101-n)FOR(j,i+1,102-n)FOR(k,j+1,103-n)
         FOR(l,k+1,104-n)FOR(m,l+1,105-n)FOR(o,m+1,106-n)
         FOR(p,o+1,107-n)FOR(q,p+1,108-n)
         if(i+j+k+l+m+o+p+q==s){
            ans++; break;
         }
      }
      if(n==9){
         FOR(i,0,101-n)FOR(j,i+1,102-n)FOR(k,j+1,103-n)
         FOR(l,k+1,104-n)FOR(m,l+1,105-n)FOR(o,m+1,106-n)
         FOR(p,o+1,107-n)FOR(q,p+1,108-n)FOR(r,q+1,109-n)
         if(i+j+k+l+m+o+p+q+r==s){
            ans++; break;
         }
      }
      
      cout << ans << endl;
   }
}

C++: // AOJ.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include "stdio.h"
#include <vector>
#include <iostream>

using namespace std;

class Puzzle
{
public:
	vector<int> used;

	void play()
	{
		int n;
		int s;
		int ans = 0;
		used = vector<int>(10, 0);

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

			printf("%d\n",ans);

			ans = try_sum(n, s, 0);
			printf("%d\n",ans);
		}
	}

	int try_sum(int n, int s, int min)
	{
		if (n == 0 && s == 0) return 1;
		if (n == 0 || s <= 0) return 0;
		int ans = 0;

		for (int ni = min; ni < 10; ni++) {
			if (used[ni] == 0 ) {
				used[ni] = 1;
				ans += try_sum(n - 1, s - ni, ni + 1);
				used[ni] = 0;
			}
		}

		return ans;
	}

};


int main()
{
	Puzzle puz;

	puz.play();

    return 0;
}