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;

int solve(int mx,int n,int s){
	if(n == 0){
		if(s == 0){
			return 1;
		}
		else{
			return 0;
		}
	}
	if(mx == 0 && s > 0){
		return 0;
	}
	if(s == 0){
		if(n == 1){
			return 1;
		}
		else{
			return 0;
		}
	}
	
	int t = solve(mx-1,n,s);
	int u = s >= mx ? solve(mx-1,n-1,s-mx) : 0;
	return t + u;
}

int main(){
	int n,s;
	while(cin >> n >> s,n != 0){
		cout << solve(9,n,s) << endl;
	}
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int n, s;
int ans = 0;

void dfs(int pos, int sum,int count) {
	if (count == n&&sum == s) {
		ans++;
		return;
	}
	if (pos == 10 || count == n)return;
	dfs(pos + 1, sum + pos,count+1);
	dfs(pos + 1, sum,count);
}

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

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

int work(int n, int s, int x){
	if(n == 1 && s == x)
		return 1;

	if(x<0)
		return 0;

	if(n>0)
		if(s>=0)
			return work(n-1,s-x,x-1) + work(n,s,x-1);
		
	return 0;
}

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

C++: #include <iostream>

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int table[ 11 ][ 50 ] = { };

  for ( int i = 0; i < 0x800; ++i )   /* 0x800: (10000000000)_2 (10 zeros) */
  {
    int sum = 0;
    int ctr = 0;
    int cur = -1;

    while ( true )
    {
      int __tmp = i >> ++cur;

      if ( !__tmp ) break;
      if ( __tmp & 1 )
      {
        sum += cur;
        ++ctr;
      }
    }

    table[ ctr ][ sum ]++;
  }

  while ( true )
  {
    int n, s;

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

    cout
      << ( n >= 0 && n <= 10
           && s >= 0 && s <= 45 ? table[ n ][ s ]
                                : 0 ) << endl;
  }

  return ( 0 );
}

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

int main(){
int a[15][200]{};
a[0][0]=1;
for(int b=0;b<=100;b++){
	for(int c=100;c>=b;c--){
		for(int d=10;d!=0;d--){
			a[d][c]+=a[d-1][c-b];
		}
	}
}
int x,y;
while(cin>>x>>y,x|y){
	printf("%d\n",a[x][y]);
}
}

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

int n,s;

int solve(int now,int last,int count){
    if(count==n&&now==s){
        return 1;
    }
    if(count==n||now>s){
        return 0;
    }
    int co=0;
    for(int i=last+1;i<10;i++){
        co+=solve(now+i,i,count+1);
    }
    return co;
}
int main()
{
    
    while(cin>>n>>s){
        if(n==0&&s==0)break;
        int count=0;
        for(int i=0;i<n;i++){
            
            count+=solve(i,i,1);
        }
        cout<<count<<endl;
    }
    return 0;
}

C++: #include <iostream>
//#include <fstream>
using namespace std;
int ans,n,s;
 
void dfs(int sum,int cnt,int i){
	if(cnt==n&&sum==s){
        ++ans;
        return;
    } else if(cnt==n||i>=10){
        return;
    }
	dfs(sum+i,cnt+1,i+1);
    dfs(sum,cnt,i+1);
};
 
int main(){
    while(cin>>n>>s){
		if(n==0&&s==0){
			break;
		}
        ans=0;
        dfs(0,0,0);
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int dfs (const int depth, const int sum, 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
	++currd;
	
	for (i = j; i <= min(9,sum); ++i){
		currs += i;
		count += dfs (depth, sum, currs, currd, i+1);
	} // end for

	return count;
}
 

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

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

		if (n == 0 && sum == 0){
			break;
		} // end if
		
		res = dfs (n, sum, 0, 0, 0 );

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

C++: #include <iostream>
using namespace std;
int sp(int num,int s,int n)
{
    if(!num&!s)return 1;
    if(n>9)return 0;
    return sp(num-1,s-n,n+1)+sp(num,s,n+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<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,s;
int Sum_of_Integers(int i,int sum,int v);
int main(){
  while(1){
    cin >> n >> s;
    if(!n && !s)break;
    int k = Sum_of_Integers( 0 , 0 , -1 );
    if(k == 0){
      cout << k << endl;
    }else {
      cout << k << endl;
    }
  }
}
int Sum_of_Integers(int i,int sum,int v){
  int ret = 0;
  if(i > n || sum > s)return 0; // あふれたとき
  if(i == n && sum == s)return 1;
  for(int j=v+1;j<=s;j++){
    if(sum+j<=s)ret += Sum_of_Integers( i + 1, sum + j , j );
  }
  return ret;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int n,s,ans;
    int dp[11][101]={0};
    dp[0][0]=1;
    for (int i=0;i<10;++i) {
        for (int j=i;j>=0;--j) {
            for (int k=0;k+i<=100;++k) {
                dp[j+1][k+i]+=dp[j][k];
            }
        }
    }
    for (;;) {
        scanf("%d %d",&n,&s);
        if (n==0 && s==0) break;
        printf("%d\n",dp[n][s]);
    }
    return 0;
}

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

int main() {

  int d[11][101] = {0};

  for ( long long int i = 0; i < ( 1 << 10 ); i++ ) {
    long long int k = i;
    long long int cnt = 0;
    long long int sum = 0;
    long long int j = 0;
    while( k > 0 ) {
      if ( k % 2 ) {
	sum += j;
	cnt++;
      }
      j++;
      k /= 2;
    }
    d[cnt][sum]++;
  }

  long long int n, s;

  while( cin >> n >> s, n ) {
    cout << d[n][s] << endl;
  }

  return 0;

}

C++: #include<iostream>
using namespace std;
int n,s,cnt;
void dfs(int m,int num,int sum);
int main(){
	while(cin>>n>>s,n || s){
		cnt=0;
		dfs(1,0,0);
		cout<<cnt<<endl;
	}
	return 0;
}

void dfs(int m,int num,int sum){
	if(m>9 && (num==n || num==n-1) && sum==s)cnt++;
	if(m>9)return;
	dfs(m+1,num+1,sum+m);
	dfs(m+1,num,sum);
}