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 <cstring>
using namespace std;

const int MAX = 15;
const int dx[] = {-1, 0, 1};
int X, Y;
int c[MAX + 2][MAX + 2], dp[MAX + 2][MAX + 2];

int main()
{
    while(cin >> X >> Y && X) {
        for(int i = 1; i <= Y; i++)
            for(int j = 1; j <= X; j++)
                cin >> c[i][j];

        memset(dp, 0, sizeof(dp));
        for(int j = 1; j <= X; j++) 
            dp[1][j] = (c[1][j] == 0) ? 1 : 0;
        
        for(int i = 2; i <= Y; i++) {
            for(int j = 1; j <= X; j++) {
                if(c[i][j] == 0) {
                    for(int k = 0; k < 3; k++)
                        if(c[i - 1][j + dx[k]] == 0)
                            dp[i][j] += dp[i - 1][j + dx[k]];
                } else if(c[i][j] == 1) {
                    dp[i][j] = 0;
                } else {
                    dp[i][j] += dp[i - 1][j];
                    dp[i + 2][j] = dp[i][j];
                }
            }
        }
        
        int ans = 0;
        for(int j = 1; j <= X; j++) 
            ans += dp[Y + 1][j] + dp[Y][j];

        cout << ans << endl;
        
    }
}

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

int grid[20][20];

inline bool isAtObstacle(int x, int y) {
  return grid[y][x] == 1;
}

inline bool isAtSkiJump(int x, int y) {
  return grid[y][x] == 2;
}

int main() {
  int n, m;
  
  while(cin >> n >> m && n) {
    fill(grid[0], grid[0]+400, 0);
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	cin >> grid[i][j];
      }
    }
    
    long long dp[20][20][2] = {};
    
    for(int j=0; j<m; j++) {
      if(grid[0][j]==0) { dp[0][j][0] = 1; }
    }
    
    for(int i=0; i<n-1; i++) {
      for(int j=0; j<m; j++) {
	
	// there is no case such that skier is at obstacle.
	if(isAtObstacle(j, i)) continue;
	
	// A skier is at a ski jump.
	if(isAtSkiJump(j, i)) {
	  if(i+2>n-1) dp[n-1][j][0] += dp[i][j][0];
	  else {
	    if(!isAtObstacle(j, i+2)) {
	      dp[i+2][j][0] += dp[i][j][0];
	    }
	  }
	}
	
	// skiing without jump.
	else {
	  // from the upper left
	  if( j-1 >= 0
	      && !isAtObstacle(j-1, i+1)
	      && !isAtSkiJump (j-1, i+1) ) {
	    dp[i+1][j-1][1] += dp[i][j][0] + dp[i][j][1];
	  }
	  
	  // from the above
	  if( !isAtObstacle(j, i+1) ) {
	    dp[i+1][j][0] += dp[i][j][0] + dp[i][j][1];
	  }
	  
	  // from the upper right
	  if( j+1 < m
	      && !isAtObstacle(j+1, i+1)
	      && !isAtSkiJump (j+1, i+1) ) {
	    dp[i+1][j+1][1] += dp[i][j][0] + dp[i][j][1];
	  }
	}
	
      }
    }
    
    int ans = 0;
    for(int i=0; i<m; i++) {
      ans += dp[n-1][i][0] + dp[n-1][i][1];
    }
    
    cout << ans << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
	int X,Y;
	while(true){
		long long int ans=0;
		cin>>X>>Y;
		if(X+Y==0) break;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>c[i][j];
			}
		}
		for(int i=1;i<=X;i++){
			if(c[1][i]==1){
				dp[1][i]=0;
			}
			if(c[1][i]==0){
				dp[1][i]=1;
			}
			if(c[1][i]==2){
				dp[1][i]=1;
				dp[3][i]=1;
			}
		}
		for(int i=2;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==1) dp[i][j]=0;
				else if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i-1][j-1+k]!=2){
							dp[i][j]+=dp[i-1][j-1+k];
						}
					}
				}
				else{
					if(c[i-1][j]!=2){
						dp[i][j]+=dp[i-1][j];
					}
					dp[i+2][j]+=dp[i][j];
				}
			}
		}
		for(int i=Y;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				ans+=dp[i][j];
			}
		}
		for(int i=1;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>

int main()
{
    int x, y;
    int dx[3] = {-1, 0, 1};
    
    while (std::cin >> x >> y) {

        if (x == 0 && y == 0) break;

        int field[20][20] = {{0}}, dp[20][20] = {{0}};
        
        for (int i = 0; i < 20; ++i) {
            for (int j = 0; j < 20; ++j) {
                field[i][j] = 1;
            }
        }
        
        for (int i = 1; i <= y; ++i) {
            for (int j = 1; j <= x; ++j) {
                std::cin >> field[i][j];
            }
        }

        for (int i = 1; i <= x; ++i) {
            if (field[1][i] == 0) dp[1][i] = 1;
        }
        
        //calc
        int ans = 0;

        for (int i = 1; i <= y; ++i) {
            for (int j = 1; j <= x; ++j) {
                
                switch (field[i][j]) {
                    case 0:
                        for (int k = 0; k < 3; ++k) {
                            int px = j + dx[k], py = i + 1;
                            
                            if ((field[py][px] == 2 && k == 1) || field[py][px] == 0) {
                                dp[py][px] += dp[i][j];
                            }
                        }
                        break;
                    case 2:
                        //y-1
                        if (i == y -1) ans += dp[i][j];
                        if (dp[i + 2][j] != 1) dp[i + 2][j] += dp[i][j];
                        break;
                    default:
                        break;
                }
            }
        }

        for (int i = 1; i <= x; ++i) {
            ans += dp[y][i];
        }

        std::cout << ans << std::endl;
    }

    return 0;
}