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[18][18];
int memo[18][18];
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 && mp[y][x] != 1)) ans++,memo[y][x]++;//,cout <<"ok"<<endl;  
  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||ny <0||nx >= w|| ny>=h || memo[ny][nx] == -1) continue;
      
      if(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;
	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<h;i++) 
      for(int j=0;j<w;j++) 
	cin >> mp[i][j];


    for(int i=0;i<=15;i++) 
      for(int j=0;j<=15;j++) 
	memo[i][j] = 0;
    /*
      for(int i=0;i<h;i++) {
      for(int j=0;j<w;j++) 
      cout << mp[i][j];
      cout << endl;
      }
    */

    ans = 0;
    count = 0;
    for(int i=0;i<w;i++) {
      if(mp[0][i] !=1) saiki(i,0);
    }

    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 w,h;
int mp[20][20],memo[20][20];
void saiki(int x,int y){
  if(y >= h-1) memo[y][x]++;
  else 
    for(int i=-1;i<=1;i++) {
      int nx = x+i, ny = y+1;
      if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
      if(nx <0|| nx >= w ||mp[ny][nx] != 0) continue;
      if(memo[ny][nx]==0) saiki(nx,ny);
      memo[y][x] += memo[ny][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++)cnt+=memo[0][i];
    cout <<cnt<<endl;
  }
  return 0;
}

C++: // AOJ 0203
#include <iostream>
#include <cstring>

using namespace std;
 
int main(void)
{
    int w, h;
    while (cin >> w >> h, w){
        int field[32][32];
        for (int y = 1; y <= h; y++){
            for (int x = 1; x <= w; x++){
                cin >> field[y][x];
            }
        }
        int dp[32][32];
        memset(dp, 0, sizeof(dp));

        for (int x = 1; x <= w; x++){
            if (field[1][x] == 0){
                dp[1][x] = 1;
            }
        }
        for (int y = 1; y <= h; y++){
            for (int x = 1; x <= w; x++){
                if (field[y][x] == 1){
                    continue;
                }
                if (field[y][x] == 2){
                    dp[y + 2][x] += dp[y][x];
                    continue;
                }
                if (field[y + 1][x - 1] == 0){
                    dp[y + 1][x - 1] += dp[y][x];
                }
                if (field[y + 1][x] != 1){
                    dp[y + 1][x] += dp[y][x];
                }
                if (field[y + 1][x + 1] == 0){
                    dp[y + 1][x + 1] += dp[y][x];
                }
            }
        }
 
        int ret = 0;
        for (int y = h - 1; y <= h; y++){
            for (int x = 1; x <= w; x++){
                if (y == h - 1){
                    if (field[y][x] == 2) ret += dp[y][x];
                    continue;
                }
                else {
                    ret += dp[y][x];
                }
            }
        }
        cout << ret << endl;
    }
 
    return 0;
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
int dx[] = {-1,0,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 = x+dx[i], ny = y+1;
      if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
      if(nx <0|| nx >= w ||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);
	memo[y][x] += memo[ny][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 width, height, m[15][15];
	while (cin >> width >> height, width && height) {
		for (int y = 0; y < height; ++y)
			for (int x = 0; x < width; ++x)
				cin >> m[y][x];

		int sum = 0, pattern[15][15] = {0};
		for (int x = 0; x < width; ++x)
			pattern[0][x] = 1;

		for (int y = 0; y < height-1; ++y)
			for (int x = 0; x < width; ++x)
				if (m[y][x] == 0) {
					if (x - 1 >= 0 && m[y+1][x-1] == 0) pattern[y+1][x-1] += pattern[y][x];
					if (x + 1 < width && m[y+1][x+1] == 0) pattern[y+1][x+1] += pattern[y][x];
					if (m[y+1][x] != 1) pattern[y+1][x] += pattern[y][x];
				}
				else if (m[y][x] == 2) {
					if (y + 2 == height) sum += pattern[y][x];
					else if (m[y+2][x] != 1) pattern[y+2][x] += pattern[y][x];
				}

		for (int x = 0; x < width; ++x)
			sum += pattern[width-1][x];

		cout << sum << endl;
	}
	return 0;
}