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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int x, y;
int field[16][16];
int dp[16][16];

int main(){
	while (cin >> x >> y&&x + y){
		REP(i, 16){
			REP(j, 16){
				dp[i][j] = 0;
				field[i][j] = 0;
			}
		}
		REP(i, y)REP(j, x)cin >> field[i][j];
		REP(j, x){
			if (field[0][j] == 0)dp[0][j] = 1;
		}
		REP(i, y - 1){
			REP(j, x){
				if (field[i][j] == 0){
					if (field[i + 1][j] != 1)dp[i + 1][j] += dp[i][j];
					if (j - 1 >= 0 && field[i + 1][j - 1] == 0){
						dp[i + 1][j - 1] += dp[i][j];
					}
					if (j + 1 < x&&field[i + 1][j + 1] == 0){
						dp[i + 1][j + 1] += dp[i][j];
					}
				}
				else if (field[i][j] == 2){
					if (i + 2 <= y - 1 && dp[i + 2][j] != 1){
						dp[i + 2][j] += dp[i][j];
					}
					else{
						dp[i + 1][j] += dp[i][j];
					}
				}
			}
		}
		int ans = 0;
		REP(j, x)ans += dp[y - 1][j];
		cout << ans << endl;
	}
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20];
int memo[20][20];
int ans;
int count;

int saiki(int x,int y) {
  count++;
  // cout << x <<" "<<y <<endl;
  int dx[3] = {-1,0,1};
  int dy[3] = {1,1,1};
  
  if(y >= h-1) ans++,memo[y][x]++;
  
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x;
      int ny = dy[i]+y;
      if(nx <0|| nx >= w || memo[ny][nx] == -1||mp[ny][nx] == 1) continue;
      
      if(memo[ny][nx] > 0 && mp[ny][nx] == 0) {
	ans += memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }  
      else if(x == nx && mp[ny][nx] == 2 && memo[ny][nx] > 0) {
	ans += memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	if(memo[ny][nx] > 0) memo[y][x] += memo[ny][nx];
      } 
      else if(nx==x && mp[ny][nx] == 2){
	int ty = ny;
	while(mp[ty][nx] == 2) ty+=2;
	if(mp[ty][nx] == 0)saiki(nx,ty);
	if(memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
      }
    }
    if(memo[y][x] == 0) memo[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] = 0;
	mp[i][j] = 0;
      }
    
    for(int i=0;i<h;i++) 
      for(int j=0;j<w;j++) 
	cin >> mp[i][j];


    ans = 0;
    count = 0;
    for(int i=0;i<w;i++) {
      if(mp[0][i] !=1) saiki(i,0);
    }
    
    /*
    for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) 
      cout << memo[i][j]<<" ";
    cout << endl;
    } 
    */
  
    int ans2 = 0;
    for(int i=0;i<w;i++) 
      if(memo[0][i] > 0) ans2+=memo[0][i];
    
    cout << ans << endl;
    //    cout << ans2 << endl;
    //cout << count << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
 
int fld[17][17];
int cnt[17][17];
 
int main(){

    int X,Y,S;
    while(cin >> X >> Y, X || Y ) {

      for(int y = 0 ; y< 17 ; y++)
        for(int x = 0 ; x< 17 ; x++){
            fld[y][x] = 3;
            cnt[y][x] = 0;
        }
 
        for(int y = 0 ; y < Y ; y++)
	  for(int x= 1 ; x <= X ; x++){
            cin >> fld[y][x];
            cnt[y][x] = ( (y == 0 && fld[y][x] == 0 )? 1 : 0 );
	  }
 
        for(int y = 0 ; y < Y - 1 ; y++ )
	  for(int x = 1 ; x <= X  ; x++ ){
            if(fld[y][x] == 0){
	      if(fld[y + 1][x + 1] == 0) cnt[y + 1][x + 1] += cnt[y][x];
	      if(fld[y + 1][x - 1] == 0) cnt[y + 1][x - 1] += cnt[y][x];
	      if(fld[y + 1][x] != 1) cnt[y + 1][x] += cnt[y][x]; 
            }
            if( fld[y][x] == 2 && fld[y + 2][x] != 1 ){
	      cnt[y + 2][x] += cnt[y][x];
            }
	  }
 
        S = 0;
        for(int y=Y-1; y< Y+2; y++)
	  for(int x=1  ; x<=X  ; x++)
            S+=cnt[y][x];
 
 
        cout << S << endl;
    }
 
    return 0;
}

C++: #include<iostream>
using namespace std;
int dp[20][20][2];
int x[20][20];
int H, W;
void A(int a, int b, int c, int d) {
	if (x[a][b] == 2) {
		if (d != 0) { return; }
		if (c == 1) { return; }
		if (c == 0) {
			if (x[a + 2][b] == 1) { return; }
			dp[a + 2][b][0] += dp[a][b][c];
			return;
		}
	}
	if (x[a + 1][b + d] == 1) { return; }
	if (x[a + 1][b + d] == 2 && d != 0) { return; }
	if (x[a][b] == 0) {
		if (d == 0) {
			dp[a + 1][b + d][0] += dp[a][b][c];
		}
		else {
			dp[a + 1][b + d][1] += dp[a][b][c];
		}
	}
}
int main() {
	while (true) {
		cin >> W >> H;
		if (H == 0 && W == 0) { break; }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j];
			}
		}
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 20; j++) {
				dp[i][j][0] = 0;
				dp[i][j][1] = 0;
			}
		}
		for (int i = 1; i <= W; i++) {
			if (x[1][i] == 0) {
				dp[1][i][0] = 1;
			}
		}
		for (int i = 1; i <= H - 1; i++) {
			for (int j = 1; j <= W; j++) {
				A(i, j, 0, -1);
				A(i, j, 0, 0);
				A(i, j, 0, 1);
				A(i, j, 1, -1);
				A(i, j, 1, 0);
				A(i, j, 1, 1);
			}
		}
		int sum = 0;
		for (int j = H; j < 20; j++) {
			for (int i = 1; i <= W; i++) {
				sum += dp[j][i][0] + dp[j][i][1];
			}
		}
		cout << sum << endl;
	}
	return 0;
}