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 <cstring>
#include <cstdio>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int x, y, c[50][50], dp[50][50];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y-1) rep(j,x) {
    if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (tj < 0 || tj >= x) continue;
        //if (c[ti][tj] == 1) continue;
        //if (c[ti][tj] == 2 && z != 1) continue;
        //dp[ti][tj] += dp[i][j];
        if (c[ti][tj] == 0) dp[ti][tj] += dp[i][j];
        else if (c[ti][tj] == 2 && z == 1) dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2 && c[i+2][j] != 1) {
      dp[i+2][j] += dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  rep(j,x) res += dp[y][j] + dp[y-1][j];
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

C++: #include <cstdio>
#include <cstring>
int w,h;
int f[22][22];
int dp[22][22];
int dx[] = {-1,0,1};
int solve(int x,int y){
  if(f[x][y] == 1) return 0;
  if(y >= h)return 1;
  if(f[x][y] == 1) return 0;
  if(dp[x][y] >= 0) return dp[x][y];
  if(f[x][y] == 2)return dp[x][y] = solve(x,y + 2);

  int ret = 0;
  for(int i = 0; i < 3; i++){
    int nx = x + dx[i];
    if(!f[nx][y+1] || (!dx[i] && f[nx][y+1] == 2)){
      ret += solve(nx,y+1);
    }
  }
  return dp[x][y] = ret;
}
int main(void){
  while(1){
    scanf("%d%d",&w,&h); if(!w) break;
    memset(f,-1,sizeof(f));
    memset(dp,-1,sizeof(dp));
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	scanf("%d",&f[j][i]);
      }
    }
    int ans = 0;
    for(int j = 1; j <= w; j++){
      ans += solve(j,1);
    }
    printf("%d\n",ans);
  }
}

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

int main() {
	int x, y;
	while (cin >> x >> y ,x,y) {
		vector<vector<int>> course(y + 2, vector<int>(x + 2, 0));
		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				cin >> course[i][j];
			}
		}

		vector<vector<int>> path(y + 2, vector<int>(x + 2, 0));
		//?????????????????????????????????1????????????
		for (int i = 1; i <= x; i++) {
			if (course[1][i] != 1) path[1][i] = 1;
		}

		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				//????????????????????´????????????????????´??????????????????????????????????????????
				//?????????????§????????????????????????´?????????????????????????????£????????°?????´????????????????????????
				if (course[i][j] == 0) {
					if (course[i + 1][j + 1] == 0) path[i + 1][j + 1] += path[i][j];
					if (course[i + 1][j] != 1) path[i + 1][j] += path[i][j];
					if (course[i + 1][j - 1] == 0) path[i + 1][j - 1] += path[i][j];
				}
				//?¬???????????????´???????????£????????°????????????????????????????????????
				//?????????????????£????????§??´??????????????´???????????????(?????£?????????????????????????????´???????????????)
				if (course[i][j] == 2 && course[i + 2][j] != 1) {
					path[i + 2][j] += path[i][j];
					if (i + 2 > y && i != y) path[y][j] += path[i][j];
				}
				//???????????´???????????????????????????????????????
				if (course[i][j] == 1) {/*do anything*/ }
			}
		}

		cout << accumulate(path[y].begin() + 1, path[y].end() - 1, 0) << endl;

	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  while(true){
    int xsize,ysize;
    cin>>xsize>>ysize;
    if(!xsize&&!ysize)break;
    int course[xsize+2][ysize];
    for(int y=0;y<ysize;y++){
      for(int x=0;x<xsize;x++){
	cin>>course[x+1][y];
      }
    }
    int pattern[xsize+2][ysize+1];
    for(int y=0;y<ysize;y++){
      for(int x=0;x<xsize+2;x++){
	if(y) pattern[x][y] = 0;
	else if(course[x][y]) pattern[x][y] = 0;	    
	else pattern[x][y] = 1;
      }
    }
    pattern[0][0] = 0;
    pattern[xsize+1][0] = 0;
    int count = 0;
    for(int y=0;y<ysize;y++){
      for(int x=1;x<xsize+1;x++){
	if(course[x][y]==0){
	  if(y==ysize-1) count+=pattern[x][y];
	  else{
	    if(course[x-1][y+1]==0)
	      pattern[x-1][y+1] += pattern[x][y];
	    if(course[x][y+1]!=1)
	      pattern[x][y+1] += pattern[x][y];
	    if(course[x+1][y+1]==0)
	      pattern[x+1][y+1] += pattern[x][y];
	  }
	}
	if(course[x][y]==2){
	  if(y==ysize-2) count+= pattern[x][y];
	  else if(y==ysize-1) count+= pattern[x][y];
	  else pattern[x][y+2] += pattern[x][y];
	}
      }
    }
    cout<<count<<endl;
  }
  return 0;
}

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

int w, h, c[15][15];
int res;

void dfs(int x, int y) {
	if (y <= h-1 && c[y][x] == 1) return;
	if (y >= h-1) {
		++res;
		return;
	}
	if (c[y][x] == 0) {
		for (int i = 0; i < 3; ++i) {
			int nx = x + i - 1, ny = y + 1;
			if (0 <= nx && nx < w && ((x == nx && c[ny][nx] == 2) || c[ny][nx] == 0)) dfs(nx, ny);
		}
	}
	if (c[y][x] == 2) dfs(x, y+2);
	return;
}

int main(void) {
	while (cin >> w >> h, w && h) {
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) cin >> c[i][j];
		}
		res = 0;
		for (int i = 0; i < w; ++i) {
			if (c[0][i] == 0) dfs(i, 0);
		}
		cout << res << endl;
	}
	return 0;
}