Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		X, _ := strconv.Atoi(buf[0])
		Y, _ := strconv.Atoi(buf[1])
		if X == 0 && Y == 0 {
			break
		}
		tbl := make([][]int, Y+2)
		field := make([][]int, Y+2)
		for i := range field {
			field[i] = make([]int, X+2)
			tbl[i] = make([]int, X+2)
			for j := range field[i] {
				field[i][j] = 2
				tbl[i][j] = 0
			}
		}
		buf_ := make([][]string, Y)
		for i := range buf_ {
			scanner.Scan()
			buf_[i] = strings.Split(scanner.Text(), " ")
		}
		for i := 1; i <= Y; i++ {
			for j := 1; j <= X; j++ {
				field[i][j], _ = strconv.Atoi(buf_[i-1][j-1])
				switch field[i][j] {
				case 0:
					if i == 1 {
						tbl[i][j] = 1 // スタートy=1
					} else {
						if field[i-1][j-1] != 2 {
							tbl[i][j] += tbl[i-1][j-1] // 左上からやってくる
						}
						if field[i-1][j] != 2 {
							tbl[i][j] += tbl[i-1][j] // 真上からやってくる
						}
						if field[i-1][j+1] != 2 {
							tbl[i][j] += tbl[i-1][j+1] // 右上からやってくる
						}
						if field[i-2][j] == 2 {
							tbl[i][j] += tbl[i-2][j] // ジャンプしてくる
						}
					}
				case 1:
					tbl[i][j] = 0 // 障害物あり
				case 2:
					if field[i-1][j] != 2 {
						tbl[i][j] += tbl[i-1][j] // 真上からくる
					}
					if field[i-2][j] == 2 {
						tbl[i][j] += tbl[i-2][j] // ジャンプ台からジャンプしてくる
					}
				}
			}
		}
		sum := 0
		for i := 1; i <= X; i++ {
			sum += tbl[Y][i] // とびこさないでゴール
			if field[Y-1][i] == 2 {
				sum += tbl[Y-1][i] // 飛び越してゴール
			}
		}
		fmt.Println(sum)
	}
}

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

constexpr int MAX = 1000001;

int main() {
    int X, Y;
    while(cin >> X >> Y, X) {
        vector<vector<int>> c(Y+1, vector<int>(X));
        for(int i=0; i<Y; ++i) {
            for(int j=0; j<X; ++j) {
                cin >> c[i][j];
            }
        }
        vector<vector<int>> dp(Y+1, vector<int>(X));
        for(int i=0; i<X; ++i) {
            dp[0][i] = c[0][i] == 0;
        }
        for(int i=0; i<Y-1; ++i) {
            for(int j=0; j<X; ++j) {
                if(c[i][j] == 1) {
                    continue;
                } else if(c[i][j] == 2) {
                    dp[i+2][j] += dp[i][j];
                } else {
                    int dx[3] = {-1, 0, 1};
                    for(int k=0; k<3; ++k) {
                        int nx = j + dx[k];
                        if(nx < 0 || X <= nx || dx[k] != 0 && c[i+1][nx] == 2) {
                            continue;
                        }
                        dp[i+1][nx] += dp[i][j];
                    }
                }
            }
        }
        int res = 0;
        for(int i=0; i<2; ++i) {
            for(int j=0; j<X; ++j) {
                if(c[Y-1+i][j] != 1) {
                    res += dp[Y-1+i][j];
                }
            }
        }
        cout << res << endl;
    }
}

C++: #include <iostream>
#define MAX 15

using namespace std;

int a,b,cnt,ans;
int ski[MAX + 1][MAX];

int compute(int y,int x){

  if( a - 1 <= y ) return ++cnt;

  if( ski[y][x] == 2 ) compute( y + 2 , x );
  else if( ski[y + 1][x] == 2 ) compute( y + 3 , x );
  if( ski[y][x] != 2 ){
    if( !ski[y + 1][x - 1] && ( 0 <= x - 1 && x - 1 < b ) ) compute( y + 1 , x - 1 );
    if( !ski[y + 1][x + 1] && ( 0 <= x + 1 && x + 1 < b ) ) compute( y + 1 , x + 1 );
    if( !ski[y + 1][x] ) compute( y + 1 , x );
  }
  
  return cnt;
}



int main(void){

  while( cin >> a >> b , a || b ){

    for( int i = 0 ; i < a ; i++ )
      for( int j = 0 ; j < b ; j++ )
	cin >> ski[i][j];

    ans = 0;
    for( int i = 0 ; i < b ; i++ ){
      cnt = 0;
      if( !ski[0][i] ){
	int c = compute( 0 , i );
	//	cout << c << endl;
	ans += c;
      }
    }
    cout << ans << endl;


  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main() {
	int y, x;
	while (1) {
		cin >> y >> x;
		if (y + x == 0) break;
		int d[20][20];
		rep(i, 0, y) {
			rep(j, 0, x) {
				cin >> d[i][j];
			}
		}
		int dp[20][20] = { 0 };
		rep(i, 0, x) {
			if (d[0][i] == 0) dp[0][i] = 1;
		}
		rep(i, 0, y) {
			rep(j, 0, x) {
				if (d[i][j] == 1) continue;
				if (d[i][j] == 2) {
					dp[i + 2][j] += dp[i][j];
					continue;
				}
				rep(k, -1, 2) {
					if (j + k < 0 || j + k >= x || d[i + 1][j + k] != 0) continue;
					dp[i + 1][j + k] += dp[i][j];
				}
				if (d[i + 1][j] == 2) {
					dp[i + 1][j] += dp[i][j];
				}
			}
		}
		/*cout << endl;
		rep(i, 0, y + 2) {
			rep(j, 0, x) {
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}*/
		int ans = 0;
		rep(i, 0, x) {
			ans += dp[y - 1][i] + dp[y][i] + dp[y + 1][i];
		}
		cout << ans << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int a[20][20],dp[20][20];
int main(){
	int h,w;
	while(cin>>w>>h&&h+w){
		lol(i,h)lol(j,w)cin>>a[i][j];
		lol(i,h)lol(j,w){
			dp[i][j]=0;
			if(a[i][j]==1)continue;
			if(i){
				if(a[i-1][j]==0)dp[i][j]=dp[i-1][j];
				if(i>1)if(a[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				if(a[i][j]==0){
					if(j>0)if(a[i-1][j-1]==0)dp[i][j]+=dp[i-1][j-1];
					if(j<w-1)if(a[i-1][j+1]==0)dp[i][j]+=dp[i-1][j+1];
				}
			}
			else dp[i][j]=1;
		}
		int ans=0;
		lol(j,w){
			ans+=dp[h-1][j];
			if(h>=2)if(a[h-2][j]==2)ans+=dp[h-2][j];
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int dx[] = {-1,0,1};

int main(){
	int w,h;

	while( cin >> w >> h , w||h ){
		int f[20][20] = {0};
		for(int y=1 ; y <= h ; y++ ){
			for(int x=1 ; x <= w ; x++ ){
				cin >> f[y][x];
			}
		}

		int dp[20][20] = {0};
		for(int x=1 ; x <= w ; x++ )
			dp[1][x] = 1;
		for(int y=1 ; y <= h-1 ; y++ ){
			for(int x=1 ; x <= w ; x++ ){
				if( f[y][x] == 0 ){
					for(int i=0 ; i < 3 ; i++ ){
						int mx = x + dx[i];
						int my = y + 1;
						if( mx < 1 || mx > w || my < 1 || my > h ) continue;
						if( f[my][mx] == 0 ) 
							dp[my][mx] += dp[y][x];
						if( dx[i] == 0 && f[my][mx] == 2 ) 
							dp[my][mx] += dp[y][x];
					}
					/*if( f[y+1][x-1] == 0 ) dp[y+1][x-1] += dp[y][x];
					if( f[y+1][x]   == 0 ) dp[y+1][x]   += dp[y][x];
					if( f[y+1][x+1] == 0 ) dp[y+1][x+1] += dp[y][x];
					if( f[y+1][x]   == 2 ) dp[y+1][x]   += dp[y][x];*/
				}else if( f[y][x] == 2 && f[y+2][x] != 1 ){
					dp[y+2][x] += dp[y][x];
				}
			}
		}
		int ans = 0;
		for(int x=1 ; x <= w ; x++ ){
			ans += dp[h][x] + dp[h+1][x];
		}
		cout << ans << endl;
	}
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[20][20],f,j,i,k;
	long long int g,h[20][20];
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		for(i=0;i<s;i++) h[0][i]=1;
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) scanf("%d",&d[i][j]);
		}
		for(i=0;i<s;i++){
			if(d[0][i]==1) h[0][i]=0;
		}
		for(i=1;i<a;i++){
			for(j=0;j<s;j++) h[i][j]=0;
		}
		for(i=0;i<a;i++){
			for(j=0;j<s;j++){
				if(i!=0&&d[i+1][j]==1&&d[i][j]==2){
					if(i+2<a) h[i+2][j]+=h[i][j];
					else h[i+1][j]+=h[i][j];
				}
				if(h[i][j]!=0){
					if(d[i][j]==0) if(j!=0) if(d[i+1][j-1]==0) h[i+1][j-1]+=h[i][j];
					if(j!=s){
						if(d[i][j]==0) if(d[i+1][j+1]==0) h[i+1][j+1]+=h[i][j];
						if(d[i+1][j]==0||d[i+1][j]==2) h[i+1][j]+=h[i][j];
					}
				}
			}
		}
		g=0;
		for(j=0;j<s;j++) g+=h[a-1][j];
		/*printf("\n\n");
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) printf("%d ",h[i][j]);
			printf("\n");
		}*/
		printf("%d\n",g);
	}
	return 0;
}