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 <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
    int X,Y;
    while(true){
        long long int ans=0;
        cin>>X>>Y;
        if(X+Y==0) break;
        for(int i=1;i<=Y;i++){
            for(int j=1;j<=X;j++){
                cin>>c[i][j];
            }
        }
        for(int i=1;i<=X;i++){
            if(c[1][i]==1){
                dp[1][i]=0;
            }
            if(c[1][i]==0){
                dp[1][i]=1;
            }
            if(c[1][i]==2){
                dp[1][i]=1;
                dp[3][i]=1;
            }
        }
        for(int i=2;i<=Y;i++){
            for(int j=1;j<=X;j++){
                if(c[i][j]==1) dp[i][j]=0;
                else if(c[i][j]==0){
                    for(int k=0;k<3;k++){
                        if(c[i-1][j-1+k]==0){
                            dp[i][j]+=dp[i-1][j-1+k];
                        }
                    }
                }
                else{
                    if(c[i-1][j]==0){
                        dp[i][j]+=dp[i-1][j];
                    }
                    dp[i+2][j]+=dp[i][j];
                }
            }
        }
        for(int i=Y;i<=Y;i++){
            for(int j=1;j<=X;j++){
                ans+=dp[Y][j];
				if (c[Y - 1][j] == 2) ans += dp[Y - 1][j];
            }
        }
        for(int i=1;i<=Y+1;i++){
            for(int j=1;j<=X;j++){
                dp[i][j]=0;
            }
        }
        printf("%lld\n",ans );
    }
}

C++: #include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int dp[15][16];
int fld[15][15];
int main(){
      int x,y;
      while(cin>>x>>y&&(x||y)){
            REP(i,y)REP(j,x)cin>>fld[j][i];
            memset(dp,0,sizeof(dp));
            REP(i,x)if(fld[i][0]==0)dp[i][0]=1;
            REP(i,y-1){
                  REP(j,x){
                        if(fld[j][i]==0){
                              for(int k=-1;k<=1;k++){
                                    if(j+k<0||j+k>=x)continue;
                                    //cout<<j+k<<" "<<i+1<<" "<<j<<" "<<i<<endl;
                                    if(fld[j+k][i+1]==0){
                                          //cout<<j+k<<" "<<i+1<<" "<<j<<" "<<i<<endl;
                                          dp[j+k][i+1]+=dp[j][i];
                                    }
                                    else if(fld[j+k][i+1]==2&&k==0)dp[j+k][i+1]+=dp[j][i];
                              }
                        }else if(fld[j][i]==2){
                              int to=min(y,i+2);
                              if(to==y||fld[j][to]!=1)dp[j][to]+=dp[j][i];
                        }
                  }
                  //REP(k,x)cout<<dp[k][i+1]<<" ";cout<<endl;
            }
            //REP(i,y+1)REP(j,x)printf("%2d%c",dp[j][i],j==x-1?'\n':' ');
            int ans=0;
            REP(i,2)REP(j,x)ans+=dp[j][y-i];
            cout<<ans<<endl;
      }
}

C++: // 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {1, 1, 1};
int dy[] = {-1, 0, 1};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int board[20][20], dp[30][30];
 
signed main() {
    int W, H;
    while(cin >> W >> H, W || H) {
        memset(board, 0, sizeof(board));
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                cin >> board[i][j];
            }
        }

        memset(dp, 0, sizeof(dp));
        for(int i=0; i<W; i++) if(board[0][i] == 0) dp[0][i] = 1;

        int ans = 0;
        for(int i=0; i<H - 1; i++) {
            for(int j=0; j<W; j++) {
                if(board[i][j] == 1) continue;
                for(int k=0; k<3; k++) {
                    if(board[i][j] == 2 and k != 1) continue;
                    int dbl = (board[i][j] == 2 ? 2 : 1);

                    int ni = i + dx[k] * dbl, nj = j + dy[k];
                    if(ni < 0 or nj < 0 or nj >= W) continue;
                    if(board[ni][nj] == 1) continue;
                    if(board[ni][nj] == 2 and k != 1) continue;

                    if(ni < H - 1) {
                        dp[ni][nj] += dp[i][j];
                    }
                    else {
                        ans += dp[i][j];
                    }
                }
            }
        }

        cout << ans << endl;
    }
    return 0;
}