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>
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(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 && memo[ty][nx] == 0){
	  saiki(nx,ty);
	  if(memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
	}
	else if(mp[ty][nx] == 0 && memo[ty][nx] > 0){
	  memo[y][x] += memo[ty][nx];
	  ans+= 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>
#include <cstring>
using namespace std;

int X, Y;
int map[20][20], dp[20][20][20];

int rec(int x, int y, int prevx){

  if(x < 0 || x > X-1) return 0;
  if(map[y][x] == 1) return 0;
  if(y >= Y-1) return 1;
  if(dp[y][x][prevx]) return dp[y][x][prevx];

  int ret = 0;
  if(map[y][x] == 0){
    ret = rec(x-1, y+1, x) + rec(x, y+1, x) + rec(x+1, y+1, x);
  }
  if(map[y][x] == 2 && prevx == x){
    ret = rec(x, y+2, x);
  }

  return dp[y][x][prevx] = ret;

}

int main(){

  while(cin >> X >> Y, X||Y){

    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < Y; i++){
      for(int j = 0; j < X; j++) cin >> map[i][j];
    }

    int ans = 0;
    for(int i = 0; i < X; i++)
      ans += rec(i, 0, i);

    cout << ans << endl;
  }

}

C++: #include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int W, H;
	while(cin >> W >> H, W) {
		int b[15][20] = { 0 };
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				cin >> b[i][j];
			}
		}

		int dp[15][20] = { 0 };
		for(int i = 0; i < W; i++) {
			if(b[0][i] != 1)
				dp[0][i] = 1;
		}

		for(int i = 0; i < H - 1; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] == 0) {
					for(int d = -1; d <= 1; d++) {
						if(j + d < 0 || W <= j + d) continue;
						if(b[i + 1][j + d] == 0 || b[i + 1][j + d] == 2 && d == 0)
							dp[i + 1][j + d] += dp[i][j];
					}
				}
				else if(b[i][j] == 2) {
					dp[i + 2][j] += dp[i][j];
				}
			}
		}

		int ans = 0;
		for(int i = H - 1; i <= H; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] != 1)
					ans += dp[i][j];
			}
		}
		cout << ans << endl;
	}
}

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

int main(){
	int w,h,x,y;
	char map[15][15];
	int dp[15][15];
	int ans;
	
	while(cin>>w>>h,w!=0){
		for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			cin>>map[x][y];
			dp[x][y]=0;
		}
		}

		for(x=0;x<w;x++) if(map[x][0]!='1') dp[x][0]=1;

		for(y=0;y<h-1;y++){
		for(x=0;x<w;x++){
			if(map[x][y]=='0'){
				if(map[x][y+1]!='1') dp[x][y+1]+=dp[x][y];
				if(0<x && map[x-1][y+1]=='0') dp[x-1][y+1]+=dp[x][y];
				if(x<w-1 && map[x+1][y+1]=='0') dp[x+1][y+1]+=dp[x][y];
			}else if(map[x][y]=='2'){
				if(y<h-2 && map[x][y+2]!='1') dp[x][y+2]+=dp[x][y];
			}
		}
		}
		
		ans=0;for(x=0;x<w;x++){
			if(map[x][h-2]=='2') ans+=dp[x][h-2];
			ans+=dp[x][h-1];
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, c[15][15], dp[15][15];
int main() {
	while(scanf("%d%d", &W, &H), H) {
		memset(c, 0, sizeof(c));
		memset(dp, 0, sizeof(dp));
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) scanf("%d", &c[i][j]);
		}
		for(int i = 0; i < W; i++) {
			if(c[0][i] == 0) dp[0][i] = 1;
		}
		for(int i = 1; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(c[i][j] == 1) continue;
				if(i != H && c[i - 1][j] == 0) dp[i][j] = dp[i - 1][j];
				if(i != H && c[i][j] == 0 && j != 0 && c[i - 1][j - 1] == 0) dp[i][j] += dp[i - 1][j - 1];
				if(i != H && c[i][j] == 0 && j + 1 != W && c[i - 1][j + 1] == 0) dp[i][j] += dp[i - 1][j + 1];
				if(i > 1 && c[i - 2][j] == 2) dp[i][j] += dp[i - 2][j];
			}
		}
		int ret = 0;
		for(int i = 0; i < W; i++) {
			ret += dp[H - 1][i];
			if(c[H - 2][i] == 2) ret += dp[H - 2][i];
		}
		printf("%d\n", ret);
	}
}