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 <vector>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

int tt[20][20];
int dp[20][20][20];
int W,H;

int rec(int x,int y,int px){
	if( x < 0 || x >= W ) return 0;
	if( tt[y][x] == 1 ) return 0;
	if( tt[y][x] == 2 && x != px ) return 0;
	
	if( y >= H-1 ) return 1;
	
	
	if( dp[x][y][px] != -1 ) return dp[x][y][px];
	int ans = 0;
	if( tt[y][x] == 2 ){
		ans += rec(x,y+2,x);
	}else{
		ans += rec(x,y+1,x);
		ans += rec(x+1,y+1,x);
		ans += rec(x-1,y+1,x);
	}
	return dp[x][y][px] = ans;
}

int main(){
	while(cin >> W >> H&&(W||H)){
		memset(dp,-1,sizeof(dp));
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++)
				cin >> tt[i][j];
		}
		int ans = 0;
		for(int i = 0 ; i < W ; i++){
			ans += rec(i,0,0);
		}
		cout << ans << endl;
		//return 0;
		
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <fstream>
#include <numeric>
#include <algorithm>

using namespace std;

int main(int argc, char **argv) {
  int x, y, field[15 * 15], route[15 * 15], rsum;

  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    rsum = 0;
    memset(route, 0, sizeof(int) * x * y);
    for (int i = 0; i < y; i++)
      for (int j = 0; j < x; j++)
        cin >> field[i * y + j];
    for (int i = 0; i < x; i++) {
      int f = field[i];
      if (!f)
        route[i] = 1;
    }

    for (int i = 1; i < y; i++)
      for (int j = 0; j < x; j++) {
        int f = field[i * y + j];
        if (f == 0) {
          for (int k = -1; k <= 1; k++)
            if ((j + k >= 0 && j + k < x) &&
                ((k == 0 && field[(i-1) * y + j+k] == 2) ||
                 (field[(i-1) * y + j+k] != 2)))
              route[i * y + j] += route[(i-1) * y + j+k];
        } else if (f == 1) {
          route[i * y + j] = 0;
        } else if (f == 2 && i + 2 < y) {
          route[(i+2) * y + j] = route[(i-1) * y + j];
        } else if (f == 2) {
          rsum += route[(i-1) * y + j];
        }
      }
    for (int i = 0; i < x; i++)
      rsum += route[(y-1) * y + i];

    cout << rsum << endl;
    /* FOR DEBUG                                                                                                                                                                                                                                               
    for (int i = 0; i < y; i++) {                                                                                                                                                                                                                              
      for (int j = 0; j < x; j++) {                                                                                                                                                                                                                            
        cout << route[i * y + j];                                                                                                                                                                                                                              
        cout << ' ';                                                                                                                                                                                                                                           
      }                                                                                                                                                                                                                                                        
      cout << endl;                                                                                                                                                                                                                                            
    }                                                                                                                                                                                                                                                          
    */
  }
  return 0;
}

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

void solve(int f[20][20] , w , h ){
    int dp[20][20] = {0};
    for(int x=1 ; x <= w ; x++ ){
        dp[1][x] = 1;
    }

    for(int y=1 ; y <= h-1 ; y++ ){
        for(int x=1 ; x <= w ; x++ ){
            if( f[y][x] == 0 ){
                if( f[y+1][x-1] == 0 ) dp[y+1][x-1] += dp[y][x];
                if( f[y+1][x]   == 0 ) dp[y+1][x]   += dp[y][x];
                if( f[y+1][x+1] == 0 ) dp[y+1][x+1] += dp[y][x];
                if( f[y+1][x]   == 2 ) dp[y+1][x]   += dp[y][x];
            }else if( f[y][x] == 2 ){
                if( f[y+2][x] == 0 || f[y+2][x] == 2 ){
                    dp[y+2][x] += dp[y][x];
                }
            }
        }
    }
    int ans = 0;
    for(int x=1 ; x <= w ; x++ ){
        ans += dp[h][x] + dp[h+1][x];
    }
    return ans;
}

int main(){
    int w,h;

    while( cin >> w >> h , w||h ){
        int f[20][20] = {0};
        for(int y=1 ; y <= h ; y++ ){
            for(int x=1 ; x <= w ; x++ ){
                cin >> f[y][x];
            }
        }

        int ans = solve( f , w , h );
        cout << ans << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  while(1){
    int w,h,mp[20][20]={},dp[20][20] ={};
    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<w;i++) dp[0][i] = 1;

    int ans=0;    
    for(int i=0;i<h-1;i++)
      for(int j=0;j<w;j++) {
	if(mp[i][j] !=0) break;
	for(int k=-1;k<=1;k++){
	  int nx=j+k,ny=i+1;
	  if(nx<0||nx>=w) continue;
	  while(k==0 && mp[ny][nx]==2) ny+=2;
	  if(mp[ny][nx]!=0) continue;
	  dp[ny][nx]+= dp[i][j];
	}
      }
    for(int i=h-1;i<=19;i++)
      for(int j=0;j<w;j++) ans+=dp[i][j];
    cout << ans <<endl;
  }
  return 0;
}