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 INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(a, b);
    while (a) {
        vvi data(a, vi(b));
        rep(i, a) {
            rep(j, b) {
                cin >> data[i][j];
            }
        }
        
       // cout << "=======" << endl;
        vvi dp(a+1, vi(b, 0));
        rep(i, b) {
            if (!data[0][i]) {
                dp[0][i] = 1;
            }
        }
        

        rep(i, a-1) {
            rep(j, b) {
                if (!data[i][j]) {
                    for (int k = -1; k < 2; k++) {
                        if (data[i+1][j+k] == 2) {
                            if (!k) {
                                dp[i+1][j] += dp[i][j];
                            }
                        } else if (!data[i+1][j+k]) {
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                } else if (data[i][j] == 2) {
                    dp[i+2][j] += dp[i][j];
                }
            }
        }
/*
        rep(i, a+1) {
            rep(j, b) {
                cout << dp[i][j] << " ";
            }cout << endl;
        }*/

        int ans = 0;
        rep(i, b) {
            ans += dp[a][i] + dp[a-1][i];
            /*
            if (data[a-1][i] == 1) {
                //cout << dp[a][i] << " ";
                ans += dp[a][i];
            } else {
                //cout << dp[a-1][i] << " ";
                ans += dp[a-1][i];
            }
            */
        }
        cout << ans << endl;
        cin >> a >> b;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
void saiki(int x,int y){
  if(y >= h-1) memo[y][x]++;
  else {
    for(int i=-1;i<=1;i++) {
      int nx = x+i, ny = y+1;
      if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
      if(nx <0|| nx >= w ||mp[ny][nx] == 1) continue;

      if(memo[ny][nx]>0&&mp[ny][nx]==0) memo[y][x] += memo[ny][nx];
      else if(mp[ny][nx] == 0)saiki(nx,ny),memo[y][x] += memo[ny][nx];

    }
    if(memo[y][x] == 0) mp[y][x] = 1;
  }
}
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
     
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
  
    for(int i=0;i<w;i++)
      if(mp[0][i] !=1) saiki(i,0);
     
    int cnt = 0;
    for(int i=0;i<w;i++)cnt+=memo[0][i];
    cout <<cnt<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MAX = 17;
int in[MAX][MAX], X,Y,data[MAX][MAX],ans;
int dx[4] = {-1,0,1};


void init(){
  memset(data,0,sizeof(data));
  memset(in,-1,sizeof(in));
  ans = 0;
}


void solve(){
  for(int i = 1; i <= Y; i++)
    for(int j = 1; j <= X; j++){
      for(int k = 0; k < 3; k++)
	if(in[i][j] == 0){
	  int f = j+dx[k];
	  if(i-1 > 0 && 0 < f && f <= X){
	    if(in[i-1][f] != 2) data[i][j] += data[i-1][f];
	    // if(i-2 > 0 && in[i-1][f] == 2) data[i][j] += data[i-2][f];
	  }

	}else if(in[i][j] == 2){
	  if(i-1 > 0) data[i][j] += data[i-1][j];
	  if(i+2 <= Y) data[i+2][j] += data[i][j];
	  break;
	}
	/*
	if(i-1 > 0 && j+dx[k] > 0 && j+dx[k] <= X && in[i][j] != 1 && in[i-1][j+dx[k]] != 2){
	  if(in[i][j] == 2) data[i][j] = data[i-1][j];
	  else data[i][j] += data[i-1][j+dx[k]];
	}
      if(i-2 > 0 && in[i-2][j] == 2 && in[i][j] != 1) data[i][j] += data[i-2][j];
	*/
    }

  for(int j = 1; j <= X; j++){
    if(Y-1 > 0 && in[Y-1][j] == 2) ans+=data[Y-1][j];
    ans+=data[Y][j];
  }
  cout << ans << endl;
}

void print(){
  for(int i = 1; i <= Y; i++){
    for(int j = 1; j <= X; j++)
      cout << data[i][j]<< " ";
    cout << endl;
  }
}
int main(){
  while(cin >> X >> Y && X+Y){
    init();
    for(int i = 1; i <= Y; i++)
      for(int j = 1; j <= X; j++)
	cin >> in[i][j];
    
    for(int i = 1; i <= X; i++)
      if(in[1][i] == 0) data[1][i] = 1;

    solve();
    //print();
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class point {
public:
	long long num;
	int block;
	point() :num(0), block(1) {}
};
int main() {
	int X, Y;
	while (cin >> X >> Y&&X != 0) {
		vector<vector<point> > map(X + 2, vector<point>(Y + 2));
		for (int y = 1; y <= Y; ++y) {
			for (int x = 1; x <= X; ++x) {
				cin >> map[x][y].block;
			}
		}
		for (int i = 1; i <= X; ++i) {
			map[i][1].num = 1;
		}
		for (int y = 1; y < Y; ++y) {
			for (int x = 1; x <= X; ++x) {
				if (map[x][y].block == 0) {
					for (int k = -1; k <= 1; ++k) {
						if (map[x + k][y + 1].block == 0 || (map[x + k][y + 1].block == 2 && k == 0) ) {
							map[x + k][y + 1].num += map[x][y].num;
						}
					}
				}
				else if (map[x][y].block == 2) {
					map[x][min(Y, y + 2)].num += map[x][y].num;
				}
			}
		}
		long long ans = 0;
		for (int i = 1; i <= X; ++i) {
			ans += map[i][Y].num;
		}
		cout << ans << endl;
	}
	return 0;
}