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 main() {
????????int x, y;
????????int skimap[15][15] = {};//x = j y = i
????????int dp[15][15] = {};//x = j y = i
????????while (cin >> x >> y, x * y) {//
????????????????int flyover = 0;
????????????????for (int i = 0; i < y; i++) {
????????????????????????for (int j = 0; j < x; j++) {
????????????????????????????????cin >> skimap[i][j];
????????????????????????}
????????????????}
????????????????for(int i = 0; i < x;i++){
????????????????????????if (skimap[0][i] == 0)dp[0][i] = 1;
????????????????}
????????????????for (int i = 0; i < y - 1; i++) {
????????????????????????for (int j = 0; j < x; j++) {
????????????????????????????????if (skimap[i][j] == 0) {
????????????????????????????????????????if (j - 1 >= 0) {
????????????????????????????????????????????????if (skimap[i + 1][j - 1] == 0) {
????????????????????????????????????????????????????????dp[i + 1][j - 1] += dp[i][j];
????????????????????????????????????????????????}
????????????????????????????????????????}
????????????????????????????????????????if (skimap[i + 1][j] != 1)dp[i + 1][j] += dp[i][j];
????????????????????????????????????????if (j + 1 < x) {
????????????????????????????????????????????????if (skimap[i + 1][j + 1] == 0) {
????????????????????????????????????????????????????????dp[i + 1][j + 1] += dp[i][j];
????????????????????????????????????????????????}
????????????????????????????????????????}
????????????????????????????????}
????????????????????????????????else if (skimap[i][j] == 1) {
????????????????????????????????????????continue;
????????????????????????????????}else {
????????????????????????????????????????if (i + 2 < y) {
????????????????????????????????????????????????dp[i + 2][j] = dp[i][j];
????????????????????????????????????????}else {
????????????????????????????????????????????????flyover += dp[i][j];
????????????????????????????????????????}
????????????????????????????????}
????????????????????????}
????????????????}
????????????????int sum = flyover;
????????????????for (int i = 0; i < x; i++) {
????????????????????????sum += dp[y - 1][i];
????????????????}
????????????????cout << sum << endl;
        for (int i = 0; i < y; i++){
            for(int j = 0; j < x; j++){
                dp[i][j] = 0;
                skimap[i][j] = 0;
            }
        } 
????????}
????????return 0;
}

C++: #include<iostream>
#include<stack>

int field[15][15];
int w,h;
int dfs(int x0,int y0);

int main()
{
	while(1)
	{
		std::cin>>w>>h;
		if(w==0&&h==0)break;
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				std::cin>>field[x][y];
			}
		}
		
		int count=0;
		for(int x=0;x<w;x++)
		{
			if(field[x][0]==0)
			{
				count+=dfs(x,0);
			}
		}
		std::cout<<count<<std::endl;
	}
	return 0;
}

int dfs(int x0,int y0)
{
	std::stack<std::pair<int,int> > stk;
	int count=0;
	stk.push(std::pair<int,int>(x0,y0));
	while(!stk.empty())
	{
		int x=stk.top().first,y=stk.top().second;
		
		stk.pop();
		
		if(y>=h-1&&field[x][y]!=1)
		{
			count++;
		}
		else
		{
			if(field[x][y]==2)
			{
				stk.push(std::pair<int,int>(x,y+2));
			}
			else if(field[x][y]==0)
			{
				if(x>0&&field[x-1][y+1]==0){stk.push(std::pair<int,int>(x-1,y+1));}
				if(x<w-1&&field[x+1][y+1]==0){stk.push(std::pair<int,int>(x+1,y+1));}
				if(field[x][y+1]!=1){stk.push(std::pair<int,int>(x,y+1));}
			}
		}
	}
	return count;
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
using namespace std;
int main(){
	int X,Y,c[15][15],land[15][15],ans;
	while(cin>>X>>Y,X){
		rep(i,Y)rep(j,X)cin>>land[i][j],c[i][j]=i==0&&land[i][j]!=1;
		rep(i,Y-1)rep(j,X)if(land[i+1][j]!=1){
			if(land[i+1][j]==2)c[i+1][j]+=land[i][j]==0?c[i][j]:0;
			else rep(d,3)if(ck(j+d-1,X)&&land[i][j+d-1]==0)
			c[i+1][j]+=c[i][j+d-1];
			if(i>0&&land[i-1][j]==2)c[i+1][j]+=c[i-1][j];
		}
		ans=0;
		rep(i,X)ans+=c[Y-1][i]+(Y>1&&land[Y-2][i]==2?c[Y-2][i]:0);
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int x, y;
	while(cin >> x >> y && (x||y) ) {
		int b[15][15] = {};
		rep(i,y) {
			rep(j,x) {
				cin >> b[i][j];
			}
		}
		int ret[20][20] = {};
		rep(i,x) {
			if(b[0][i] == 0) {
				ret[0][i+1] = 1;
			}
		}
		rep2(i,1,y) {
			rep(j,x) {
				if(b[i][j] == 0) {
					ret[i][j+1] += ret[i-1][j] + ret[i-1][j+1] + ret[i-1][j+2];
					rep2(k,-1,1) {
						if(b[i-1][j+k] == 2) ret[i][j+1] -= ret[i-1][j+k+1];
					}
				} else if(b[i][j] == 2) {
					ret[i+2][j+1] += ret[i-1][j+1];
				}
			}
		}
		// debug
		rep(i,y+2) {
			rep(j,x) {
				cout << ret[i][j+1] << " ";
			}
			cout << endl;
		}

		int ans = 0;
		rep2(i,y-1,y+2) {
			rep(j,x) {
				ans += ret[i][j+1];
			}
		}
		cout << ans << endl;
	}
}

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){
  //printf("(%d,%d)\n",x,y);
  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);
  }
}