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;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_M = 100;
const int MAX_N = 10;
const int MAX_S = 1000;
const int M = MAX_M;
const int N = MAX_N;
const int S = MAX_S;
ll dp[MAX_N+1][MAX_S+1];
int n, s;

int main()
{
  dp[0][0] = 1LL;
  rep(i, M+1) rev(j, N) rep(k, S-i+1) dp[j+1][k+i] += dp[j][k];

  while((cin >> n >> s) && n){
    cout << dp[n][s] << endl;
  }


  return 0;
}

C++: 
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
int ans;
int n;
int s;
void count_ans(int k,int C,int j){
if(k==n){
if(C==s){
ans++;
}
}else{
for(int i=j+1;i<10;i++){
count_ans(k+1,C+i,i);
}
}
}
int main(){
while(cin>>n>>s,(n!=0)||(s!=0)){
ans=0;
count_ans(0,0,-1);
cout<<ans<<endl;
}
}

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

const int LN = 10, LS = 10000;
int dp[LN+1][LN+1], n, s;

void set(){
    for(int i = 0; i <= LS; i++){
        dp[1][i] = 1;
    }
    for(int i = 1; i < LN; i++){
        for(int j = 0; j <= LS; j++){
            dp[i+1][j] = 0;
            if( j >= i ) dp[i+1][j] += dp[i][j-i];
            if( j > i ) dp[i+1][j] += dp[i+1][j-i-1];
        }
    }
}

int main(){
    set();
    while(true){
        cin >> n >> s;
        if(n == 0 && s == 0) break;
        cout << dp[n][s] << endl;
    }
    return 0;
}

C++: //AOJ Problem0030

#include<iostream>
#include<vector>

using namespace std;

int ans;

void solve(int n,int s,int m,int sum,int max){//n:何個か s:目的値 m:何回目か sum:現在の合計 max:最大の足した数
	
	if(m>n || sum>s){
		return;
	}

	else if(n==m && sum==s){
		ans++;
		return;
	}

	else{
		for(int i=max+1;i<=s;i++){
		
			solve(n,s,m+1,sum+i,i);
		}
	}
}

int main(){

	int n,s;

	vector<int> dataN;
	vector<int> dataS;

	for(;;){
		cin>>n;
		cin>>s;
		if(n==0&&s==0){
			break;
		}
		dataN.push_back(n);
		dataS.push_back(s);
	}
	for(int j=0;j<dataN.size();j++){

		ans=0;

		for(int i=0;i<=dataS[j];i++){
			solve(dataN[j],dataS[j],1,i,i);
		}

		cout<<ans<<endl;
	}

	return 0;
}

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

int counter(int n, int s,int a){
	if(n == 1)
		if(0 <= s && s <= a){
			return 1;
		} else {
			return 0;
		};
	if(s < 0 || n > a ) return 0;
	int max = a;
	for(int i = 1; i < n; i++)
		max += (a - i);
	if(s > max) return 0;
	int count = 0;
	for(int j = 1; j <= a; j++){
		count += counter(n - 1, s - j, j - 1);
	}
	return count;
}
int main(){
	int n,s;
	while(cin >> n >> s){
		if(n == 0 && s == 0) break;
		cout << counter(n, s, 9) << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int c;
int sub(int n, int x, int s, int sum){
	int i;
	if (n == 0){
		if (s == sum){
			c++;
		}
		return 0;
	}
	for (i = x; i < 10 - n; i++){
		sub(n - 1, i + 1, s, sum+i);
	}
}
int main(void){
	int i, n, s, sum;
	while (1){
		cin >> n >> s;
		if (n == 0 && s == 0){ break; }
		c = 0;
		sub(n, 0, s, 0);
		cout << c << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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


int n,s;
int ans=0;
int a[100];
//int dp[12][12][10][120] = {0};

int solve(int n,int c,int d,int s){
	if(c==n){
		if(s<=9&&s>=d){
			//cout<<"s="<<s<<endl;
			/*rep(i,n-1){
				cout<<a[i]<<" ";
			}*/
			//cout<<s<<endl;
			ans++;
		}
	}
	else{
		//cout <<"d = "<< d <<endl;
		for(int i=d;i<10;i++){
			//cout<<"i = "<<i<<endl;
			solve(n,c+1,i,s-i);
			//a[n-c] = i;
		}
	}
	return ans;
}
	
	

int main(){
	while(cin>>n>>s,!(n==0&&s==0)){
		ans = 0;
		rep(i,100) a[i] = 0;
		//cout<<n<<" "<<s<<endl;
		//solve(n,n,s);
		//dp[n][1][1][s] = solve(n,n,1,s);
		cout << solve(n,1,1,s) <<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 <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

using namespace std;

int combi(int n, int s, vector<int> usedNum){
	int combiCount = 0;
	int tmp;
	bool usedFlag;

	n--;
	for(int i = 0; i <= 9; i++){
		usedFlag = false;
		
		for(int j = 0; j < usedNum.size(); j++){
			if(usedNum[j] == i) usedFlag = true; 
		}
		
		if(usedFlag){
			continue;
		}
		tmp = s;
		tmp -= i;
		if(n != 0){
			usedNum.push_back(i);
			combiCount += combi(n, tmp, usedNum);
		}
		else if(n == 0 && tmp == 0){
			usedNum.pop_back();
			return ++combiCount;
		}
	}

	usedNum.pop_back();
	return combiCount;
}


int main(){
	int n, s;
	int combiCount = 0;
	vector<int> usedNum;
	while(cin >> n >> s && (n != 0 || s != 0)){
		combiCount = combi(n, s, usedNum);
		cout << combiCount << endl;
	}
	return 0;
}

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