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 ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {1,1,1,1};
const int dx[] = {-1,0,1,0};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y;
  while(cin >> x >> y&&x&&y){
    vector<vector<ll>> grid(x+1,vector<ll>(y+1,0));
    vector<vector<ll>> dp(x+3,vector<ll>(y+3,0));
    rep(i,y){
      rep(j,x){
        cin >> grid[j][i];
      }
    }
    rep(i,x){
      dp[i][0] = grid[i][0] == 0;
    }
    rep(i,y){
      rep(j,x){
        if(grid[j][i] == 0){
          rep(k,3){
            int nx = j+dx[k],ny = i+dy[k];
            if(value(j+dx[k],i+dy[k],x,y)){
              if(grid[nx][ny] == 0){
                dp[nx][ny] += dp[j][i];
              }
              else if(grid[nx][ny] == 2 && k == 1){
                dp[nx][ny] += dp[j][i];
              }
            }
          }
        }
        else if(grid[j][i] == 2 && grid[j][i+2] != 1){
          dp[j][i+2] += dp[j][i];
        }
      }
    }
    ll ans = 0;
    rep(i,x){
      ans += dp[i][y]+dp[i][y-1];
    }
//     cout << endl;
//     rep(j,y+1){
//       rep(i,x){
// //         ans += dp[i][y];
//         cout << dp[i][j]<< " ";
//       }
//       cout << endl;
//     }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	for(;;){
		int x, y;
		int map[100][100];
		int dp[100][100];
		
		cin >> x;
		cin >> y;
		if(x == 0 && y == 0){
			break;
		}
		
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				cin >> map[i][j];
			}
		}
		
		//ツ鳴催渉可づ可暗ェツ氾板湘」ツづ個療アツづ個づつィツづィツ青板づーツ個按津ィ
		//0:ツ暗堋督ョツ嘉つ能
		//1:ツ湘。ツ害ツ閉ィ
		//2:ツジツδδδ督プツ妥、
		
		for(int i = 0; i < x; i++){
			if(map[0][i] == 0){
				dp[0][i] = 1;
			}
			else{
				dp[0][i] = 0;
			}
		}
		for(int i = 1; i < y; i++){
			for(int j = 0; j < x; j++){
				//ツ配ツ療アツ外ツアツクツセツスツづーツづ「ツづ淞づヲツつ、
				if(j == 0){
					if(map[i][j] == 1){
						dp[i][j] = 0;
					}
					else if(map[i][j] == 0){
						if(map[i-1][j] == 2 ||map[i-1][j+1] == 2){
							if(map[i-1][j] == 2 || map[i-1][j+1] == 2){
								if(map[i-1][j] == 2){
									dp[i][j] = dp[i-1][j+1];
								}
								if(map[i-1][j+1] == 2){
									dp[i][j] = dp[i-1][j];
								}
								if(map[i-1][j] == 2 && map[i-1][j+1] == 2){
									dp[i][j] = 0;
								}
							}
						}
						else{
							dp[i][j] = dp[i-1][j] + dp[i-1][j+1];
							
						}
						if(map[i-2][j] == 2){
							
							dp[i][j] += dp[i-2][j];
						}
					} 
					else if(map[i][j] == 2){
						dp[i][j] = dp[i-1][j];
						
						if(map[i-2][j] == 2){
							
							dp[i][j] += dp[i-2][j];
						}
					}
				}
				//ツつサツづェツ暗按外
				else{
					if(map[i][j] == 0){
						if(map[i-1][j] == 2 || map[i-1][j-1] == 2 || map[i-1][j+1] == 2){
							if(map[i-1][j] == 2){
								dp[i][j] = dp[i-1][j+1] + dp[i-1][j-1];
							}
							if(map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j] + dp[i-1][j+1];
							}
							if(map[i-1][j+1] == 2){
								dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
							}
							if(map[i-1][j] == 2 && map[i-1][j+1] == 2){
								dp[i][j] = dp[i-1][j-1];
							}
							if(map[i-1][j] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j+1];
							}
							if(map[i-1][j+1] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j];
							}
							if(map[i-1][j+1] == 2 && map[i-1][j] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = 0;
							}
						}
						else{
							dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + dp[i-1][j+1];
						}
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					}
					else if(map[i][j] == 1){
						dp[i][j] = 0;
					}
					else if(map[i][j] == 2){
						dp[i][j] = dp[i-1][j];
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					}
				}
			}
		}
		
		int ans = 0;
		/*
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				cout<<dp[i][j] << " " << flush;
			}
			cout << endl;
		}
		*/
		
		for(int i = 0; i < x; i++){
			ans += dp[y-1][i];
		}
		
		for(int i = 0; i < x; i++){
			if(map[y-2][i] == 2){
				ans+= dp[y-2][i];
			}
		}
		
		cout << ans << endl;
	}
}

C++: #include<stdio.h>

int main(void){
	int X,Y;
	
	while(scanf("%d%d", &X, &Y) && X && Y){
		int masu[32][32]={0};
		int co[32][32]={0};
		int ans = 0;
		for(int i = 0; i < Y; i++){
			for(int j = 0; j < X; j++){
				scanf("%d", &masu[i][j]);
			}
		}
		
		for(int i = 0; i < X; i++){
			if(!masu[0][i])co[0][i] = 1;
		}
		
		for(int i = 0; i < Y-1; i++){
			for(int j = 0; j < X; j++){
				if(masu[i][j] == 0){
					if(masu[i+1][j] != 1)co[i+1][j] += co[i][j];
					if(masu[i+1][j+1] == 0)co[i+1][j+1] += co[i][j];
					if(masu[i+1][j-1] == 0 && j-1 > -1)co[i+1][j-1] += co[i][j];
				}else if(masu[i][j] != 1){
					co[i+2][j] += co[i][j];
				}
			}
		}
		
		for(int i = 0; i < X; i++){
			ans += co[Y-1][i];
		}
		for(int i = 0; i < X; i++){
			ans += co[Y][i];
		}
		printf("%d\n",ans);
	}
	return 0;
}