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 <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int s;
int D[10] ={0,1,2,3,4,5,6,7,8,9};
int ans;

void dfs(int sum,int i,int n){
  if(sum ==s&& n==0){
    ans++;
    return;
  }
  if(i ==10||n==0)return;
  dfs(sum+i,i+1,n-1);//足す
  dfs(sum,i+1,n);//足さない
}

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

C++: #include<iostream>
#include<stdio.h>
using namespace std;
/*
int solve(int n,int m){
  if(2*m>90-(n-1)*n)return 0;
  if(2*m<(n-1)*n)return 0;
  if(n==1)return (0<=m&&m<=9?1:0);
  int res=0;
  if(m-n+1>=0)res+=solve(n-1,m-n+1);
  if(m-n>=0)res+=solve(n,m-n);
  if(m-10>=0)res-=solve(n,m-10);
  return res;
}
*/
int dp[11][101];

int main(){
  int n,m;
  for(int i=0;i<11;i++)
    for(int j=0;j<101;j++)
      dp[i][j]=0;
  for(int i=0;i<=9;i++)dp[1][i]=1;

  for(int i=2;i<=10;i++){
    for(int j=0;j<=100;j++){
      if(j-i>=0)dp[i][j]+=dp[i][j-i];
      if(j-(i-1)>=0)dp[i][j]+=dp[i-1][j-(i-1)];
      if(j-10>=0)dp[i][j]-=dp[i-1][j-10];
 
    }

  }
  /*
  for(int i=0;i<=10;i++){
    for(int j=0;j<=20;j++){
      printf("%2d ",dp[i][j]);
    }
    cout<<endl;
  }
  */
  while(cin>>n>>m&&n&&m){
    cout<<dp[n][m]<<endl;
  }
  return 0;
}

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

int main(){

  int n, s;
  int soi[10][101] = {};
	
	soi[1][0] = 1;
	
	for(int i=1; i<=9; i++){
		for(int j=i; j>0; j--){
			for(int k=0; k<=100; k++){
				if(soi[j][k] != 0){
					soi[j+1][k + i]++;
				}
			}
		}
		soi[1][i] = 1;
	}

	while(1){
		cin >> n >> s;
		if(n == 0 && s == 0) break;
		
		cout << soi[n][s] << endl;
		
	}

  return 0;

}

C++: #include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;
//半手動
int main(){
    int n, m;
    while(cin >> n >> m, n){
        int ans = 0;
        if(n >= 1){
            for(int i = 0; i < 10; i++){
                if(n == 1)
                    if(i == m)
                        ans++;
        if(n >= 2){
            for(int j = i + 1; j < 10; j++){
                if(n == 2)
                    if(i + j == m)
                        ans++;
        if(n >= 3){
            for(int k = j + 1; k < 10; k++){
                if(n == 3)
                    if(i + j + k == m)
                        ans++;
        if(n >= 4){
            for(int l = k + 1; l < 10; l++){
                if(n == 4)
                    if(i + j + k + l== m)
                        ans++;
        if(n >= 5){
            for(int o = l + 1; o < 10; o++){
                if(n == 5)
                    if(i + j + k + l + o == m)
                        ans++;
        if(n >= 6){
            for(int p = o + 1; p < 10; p++){
                if(n == 6)
                    if(i + j + k + l + o + p == m)
                        ans++;
        if(n >= 7){
            for(int q = p + 1; q < 10; q++){
                if(n == 7)
                    if(i + j + k + l + o + p + q== m)
                        ans++;
        if(n >= 8){
            for(int r = q + 1; r < 10; r++){
                if(n == 8)
                    if(i + j + k + l + o + p + q + r == m)
                        ans++;
        if(n >= 9){
            for(int s = r + 1; s < 10; s++){
                if(n == 9)
                    if(i + j + k + l + o + p + q + r + s == m)
                        ans++;
        }}}}}}}}}}}}}}}}}}
        cout << ans << endl;
    }
}

C++: #include<iostream>

int count=0;

int method(int n,int s,int k){
  if(k>9){
    return 0;
  }
  if(s==0&&n==0){
    count++;
    return 0;
  }
  if(s==0||n==0||k>s){
    return 0;
  }
  if(s-k>=0){
    method(n-1,s-k,k+1);
  }
  method(n,s,k+1);
  return 0;
}

int main(){
  int n,s;

  while(std::cin >> n >> s){
    if(n==0&&s==0){
      break;
    }
    count =0;
    method(n,s,0);

    std::cout << count << std::endl;
  }
}

C++: #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int n, s;

int dfs(int sum, int num, int pre) {
  if (num == n) {
    if (sum == s) return 1;
    else return 0;
  }

  int ret = 0;
  rep(i,pre + 1,10) {
    ret += dfs(sum+i, num+1, i);
  }
  return ret;
}

int main() {

  while(1) {
    cin >> n >> s;
    if (!n && !s) break;

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

	return 0;
}

C++: #include<iostream>
using namespace std;
int add(int n, int s, int x, int t);
int main(){
	for(;;){
		int n,s,t=0;
		cin >>n>>s;
		if(n == 0 && s == 0){break;}
		for(int i=0; i<10; i++){
			if(s>=i){t+=add(n-1,s-i,i,0);}
		}
		cout <<t<<endl;
	}
	return 0;
}
int add(int n, int s, int x, int t){
	int k = t;
	if(n == 0 && s == 0){return 1;}
	else if(n == 0 && s != 0){return 0;}
	else{
		for(int i=x+1; i<10; i++){
			if(s>=i){t+=add(n-1,s-i,i,k);}
		}
	}
	return t;
}

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

int n, s;
int COUNT = 0;
int A[10];

void dfs(int cur, int sum){
    if(cur == n){
        if(sum == s){
            COUNT++;
        }
    }
    else{
        if(cur == 0) {
            for(int i = 0; i < 10; i++){
                A[cur] = i;
                dfs(cur+1, sum+i);
            }
        }
        else {
            for(int i = A[cur-1] + 1; i < 10; i++){
                A[cur] = i;
                dfs(cur+1, sum+i);
            }
        }
    }
}

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