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 <stdio.h>
int n, s, count = 0, digits[10]; // n 個の整数の和がsになる
void dfs(int cur, int start) {              // cur = 0   {}
  if(cur == n) {               // cur = 1   {a}
      int sum = 0;             // cur = 2   {a, b}
      for(int i = 0; i < n; i++) { sum += digits[i]; }
      if(sum == s) { count++; }
      return;
  }
  for(int i = start; i < 9; i++) {
      digits[cur] = i; // FIXME: 重複を避ける
      dfs(cur+1, i+1);  
  }
}
int main(void){
  n = 3; s = 1; count = 0;
  dfs(0, 0);
  printf("%d\n", count);
  return 0;
}

C++: #include <iostream>

using namespace std;

int recursive(int n, int s, int lower)
{
	if(n == 1)
	{
		if(s < lower)
			return 0;

		return 1;
	}

	int count = 0;
	for(int i = lower; i <= 9; i++)
		count += recursive(n - 1, s - i, i + 1);
	return count;
}

int main()
{
	int n, s;
	while(cin >> n >> s)
		cout << recursive(n, s, 0) << endl;

	return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		int output = 0;
		for(int a=0;a<=9;a++){
			for(int b=0;b<=9;b++){
				for(int c=0;c<=9;c++){
					for(int d=0;d<=9;d++){
						if(a+b+c+d==n){
							output++;
						}	
					}
				}
			}
		}
		cout << output << endl;
	}
}

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

using namespace std;

int main()
{
    int n, s;
	while (cin >> n >> s, n || s) {
        int ans = 0;

        for (int i = 0; i < (1<<10); ++i) {
            int cnt = 0, sum = 0;

            for (int j = 0; j < 10; ++j) {
                if (i >> j & 1) {
                    sum += j;
                    cnt++;
                }
            }

            if (cnt == n && sum == s) ans++; 
        }

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

C++: include <iostream>
using namespace std;
int dfs(int n, int s, int x){
   int sum=0;
   if(n==0 && s==0) return 1;
   if(n>0){
       for(int i =x; i<10; i++){
           if(s-i>=0)  sum+=dfs(n-1, s-i, i+1);
       }
   }
   return sum;
}

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

C++: #define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>

using namespace std;

int n = 0;
int s = 0;
static int ans;

void check(int atai, int num, int count){
	if (num > s || atai > s) {
		if (count == n && atai == s) {
			ans++;
		}
		return;
	}
	check(atai + num, num + 1, count + 1);
	check(atai, num + 1, count);
}


int main(int argc, char **argv)
{
	while (cin >> n >> s) {
		ans = 0;
		if (n == 0 && s == 0) {
			break;
		}
		check(0, 0, 0);
		cout << ans << endl;
	}
}

C++: #include <iostream>

using namespace std;

int ans;
int sum;

void dfs(int i,int n,int s){
    if(n==0){
        if(sum==s){
            ans++;
        }
        return;
    }
    if(i==10)return;
    dfs(i+1,n,s);
    dfs(i+1,n-1,s+i);
}

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

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

//map<pair<pair<int,int>,int>,int> memo; 
int memo[256][256][256];

int BT( int N, int S, int d, int p, int s )
{
	if ( d==N )
		return s==S ? 1 : 0;
	if ( s+(N-d)*p>S)
		return 0;

	if ( memo[d][p][s]>=0 )
		return memo[d][p][s];
	int ans = 0;
	for ( int i=p; i<=S; i++ )
		ans += BT(N,S,d+1,i+1,s+i);
	return memo[d][p][s]=ans;
}

int main()
{
	while ( true )
	{
		for ( int i=0; i<256*256*256; i++ )
			memo[0][0][i] = -1;

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

		cout << BT(n,s,0,0,0) << endl;

	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int ans,sum;

void dfs( int i, int s, int n ) {
  
  if ( s == sum && n== 0 ) {
    ans++;
    return;
  }

  if ( i == 10 || n == 0 ) return;


  dfs(i+1,s+i,n-1);
  dfs(i+1,s,n);
}

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

C++: #include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int n,s;
	while(cin>>n>>s,n&&s){
		if(n>10||s>45){
			cout<<0<<endl;
			continue;
		}
		int min = (int)pow(10.0,n-2);
		int lim = (int)pow(10.0,n);
		stack<int> st;
		vector<int> res;
		vector<bool> vis(lim,false);
		st.push(0);
		vis[0]=true;
		while(!st.empty()){
			int top = st.top();
			int tmp=top;
			int cur=0;
			while(tmp>0){
				cur+=tmp%10;tmp/=10;
			}
			st.pop();
			if(top>min&&cur==s){
				res.push_back(top);
			}else{
				if(top*10>=lim) continue;
				for(int i=top%10+1;i<10;++i){
					if(!vis[top*10+i]){
						vis[top*10+i]=true;
						st.push(top*10+i);
					}
				}
			}
		}
		cout<<res.size()<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

int depth = 0;
int sum = 0;

int dfs (int currs, int currd, int j)
{
	int count = 0;
	int i;

	if (currd == depth ){
		if (sum == currs ){
			return 1;
		}else{
			return 0;
		} // end if
	} // end if
	
	for (i = min(j, sum ); i >= 0; --i){
		currs += i;
		count += dfs (currs, currd + 1, i - 1 );
		currs -= i;
	} // end for

	return count;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.si", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int n, s;
		int res = 0;
		stringstream ss(str);
		ss >> n >> s;

		if (n == 0 && s == 0){
			break;
		} // end if
		
		depth = n;
		sum = s;

		res = dfs (0, 0, 9 );

		cout << res << endl;
	} // end while
	
	return 0;
}

C++: #include <iostream>

using namespace std;;

int n, s, ans;

void dfs(int i, int sum, int num) {
	if (i == n&&sum == s) {
		ans++;
		return;
	}
	for (int j = num; j <= 9; j++) {
		dfs(i + 1, sum + j, j + 1);
	}
	return;
}

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

C++: #include <iostream> 

int main(){
	int a,b,x=0;
	int gh[50];	
	while(std::cin>>a>>b){
		if(a==0&&b==0){
			for(int gf=1;gf<=x;gf++){
		std::cout<<gh[gf]<<std::endl;
	}return 0;
		}
		int d2=0,d3=0,d4=0,d5=0,d6=0,d7=0,d8=0,d9=0;
		int o=0;
		x++;
		for(int d=0;d<10;d++){
			if(a>1&&d<=10-a){
				for(d2=d+1;d2<10;d2++){
			if(a>2&&d2<=10-a+1){
				for(d3=d2+1;d3<10;d3++){
			if(a>3&&d3<=10-a+2){
				for(d4=d3+1;d4<10;d4++){
			if(a>4&&d4<=10-a+3){
				for(d5=d4+1;d5<10;d5++){
			if(a>5&&d5<=10-a+4){
			for(d6=d5+1;d6<10;d6++){
			if(a>6&&d6<=10-a+5){
			for(d7=d6+1;d7<10;d7++){
			if(a>7&&d7<=10-a+6){
				for(d8=d7+1;d8<10;d8++){
			if(a>8&&d8<=10-a+7){
				for(d9=d8+1;d9<10;d9++){
		if(a==9&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==8&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==7&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==6&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==5&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==4&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==3&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==2&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
		}
		
			}if(a==1&&b==d){
			o++;
		}
		}
		gh[x]=o;
	}
	
	return 0;
}