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 dx[] = {-1,0,1},dy[] = {1,1,1};
void saiki(int x,int y) {
  if(y >= h-1) memo[y][x]++;
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x, 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) 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];
      }
    }
    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++)
      if(memo[0][i] > 0) cnt+=memo[0][i];
    cout <<cnt<<endl;
   }
   return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int prev[3]={-1,0,1};
	int x,y,i,j;
	
	for(;;)
	{
		cin >> x >> y ;
		if(x==0 && y==0)
			break;
		int map[20][20]={0};
		int ansmap[20][20]={0};
		int ans=0;
		for(i=0;i<y;i++)
		{
			for(j=0;j<x;j++)
			{
				cin >> map[i][j] ;
			}
		}
		for(i=0;i<x;i++)
		{
			ansmap[0][i]=1;
		}
		for(i=0;i<y;i++)
		{
			for(j=0;j<x;j++)
			{
				if(map[i][j]==0 && i<y-1)
				{
					for(int k=0;k<3;k++)
					{
						if(j+prev[k]>=0 && j+prev[k]<x)
						{
							if(map[i+1][j+prev[k]]==0)
								ansmap[i+1][j+prev[k]]+=ansmap[i][j];
							else if(map[i+1][j+prev[k]]==2 && prev[k]==0)
								ansmap[i+1][j+prev[k]]+=ansmap[i][j];
						}
					}
				}
				else if(map[i][j]==2)
				{
					ansmap[i+2][j]+=ansmap[i][j];
				}
				else if(map[i][j]==1)
					ansmap[i][j]=0;
			}
		}
		for(i=-1;i<1;i++)
		{
			for(j=0;j<x;j++)
			{
				ans+=ansmap[x+i][j];
			}
		}
		cout << ans << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int W, H, mas[16][16];
  while( cin >> W >> H, W){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cin >> mas[i][j];
      }
    }
    vector< vector< int > > dp( H + 1, vector< int >(W, 0));
    for(int i = 0; i < W; i++){
      if(mas[0][i] != 1) dp[0][i] = 1;
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(dp[i][j] == 0) continue;
        if(mas[i][j] == 0){
          for(int k = -1; k <= 1; k++){
            if(j + k < 0 || j + k >= W) continue;
            if((i == H - 1 && k == 0) || (k == 0 && mas[i + 1][j + k] == 2) || (i != H - 1 && mas[i + 1][j + k] == 0)){
              dp[i + 1][j + k] += dp[i][j];
            }
          }
        } else if(mas[i][j] == 2){
          if(i >= H - 2 || mas[i + 2][j] != 1){
            dp[max(H, i + 2)][j] += dp[i][j];
          }
        }
      }
    }

    int ret = 0;
    for(int i = 0; i < W; i++){
      ret += dp[H][i];
    }
    cout << ret << endl;
  }
}

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

int maps[20][20];
int course[20][20];
int X, Y;

int way(int y, int x){
  if(y >= Y) return 1;
  else if(course[y][x] > 0) return course[y][x];
  else if(maps[y][x] == 1) return 0;
  else if(maps[y][x] == 2 && maps[y + 2][x] != 1) return course[y][x] = way(y + 2, x);
  else{
    int SUM = 0;
    for(int i = 0; i < 3; i++){
      int ny = y + 1;
      int nx = x - 1 + i;
      if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
	int flug = 1;
	if(i != 1 && maps[ny][nx] == 2) flug = 0;
	if(flug) SUM += way(ny, nx);
      }
    }
    return course[y][x] = SUM;
  }
} 

int main(){
  while(1){
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    for(int i = 1; i <= Y; i++){
      for(int j = 1; j <= X; j++){
	cin >> maps[i][j];
	course[i][j] = 0;
      }
    }
    int cnt = 0;
    for(int i = 1; i <= X; i++){
      if(maps[0][i] != 1) cnt += way(1, i);
    }
    cout << cnt << endl;
  }
}